Skip to content

Commit

Permalink
trolloz
Browse files Browse the repository at this point in the history
  • Loading branch information
cantrem committed Dec 18, 2011
1 parent 21e230e commit a59e19f
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 44 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified fanta-is-awesome/bin/com/siegedog/hava/engine/Node.class
Binary file not shown.
Binary file added fanta-is-awesome/data/img/sprites/penis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package com.siegedog.hava.derpygame;

import com.siegedog.hava.engine.RenderNode2D;

public class DoNothingPickup extends PickupNode
{
// fields


RenderNode2D renderNode;

// ctors

public DoNothingPickup(int posX, int posY, int sizeX, int sizeY)
{
super("imma do nothing", posX, posY, sizeX, sizeY);

renderNode = new RenderNode2D("data/img/sprites/penis.png", 32, 32);
addNode(renderNode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public GameplayScreen(FancyGame game) {
map = new TileMap("level", PIXELS_PER_METER, this);
map.loadCollisions("data/tiledmap/collisions.txt", world);
boxDebugRenderer = new Box2DDebugRenderer(true, true, true);
root.addNode(new DoNothingPickup(15,40,3,3));

// So far, just a thingy to let us drag the world around
//gameInput = new GameInput(game, this);
Expand Down
103 changes: 62 additions & 41 deletions fanta-is-awesome/src/com/siegedog/hava/derpygame/PickupNode.java
Original file line number Diff line number Diff line change
@@ -1,68 +1,89 @@
package com.siegedog.hava.derpygame;

import java.util.List;

import com.siegedog.hava.engine.*;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.physics.box2d.Contact;
import com.badlogic.gdx.physics.box2d.ContactImpulse;
import com.badlogic.gdx.physics.box2d.ContactListener;
import com.badlogic.gdx.physics.box2d.Manifold;
import com.badlogic.gdx.physics.box2d.MassData;

public class PickupNode extends BoxNode
{
// fields

BoxNode box;
ContactListener listener;

// public methods

// ctors

public PickupNode(String name, int posX, int posY, int sizeX, int sizeY)
@Override
public void update(float delta)
{
super(null, null);
setPosition(posX, posY);
setDimensions(sizeX, sizeY);
if (world.getContactCount() == 0)
{
System.out.println("no contacts");
return;
}

world.setContactListener(listener = new ContactListener() {
List<Contact> contacts = world.getContactList();
for (Contact c : contacts)
{
BoxNode o1 = (BoxNode)c.getFixtureA().getUserData();
BoxNode o2 = (BoxNode)c.getFixtureB().getUserData();

@Override
public void beginContact(Contact contact) {
Object o1 = contact.getFixtureA().getUserData();
Object o2 = contact.getFixtureB().getUserData();

LRR player = null;
PickupNode pickup = null;
if(o1 instanceof LRR && o2 instanceof PickupNode )
{
player = (LRR)o1;
pickup = (PickupNode)o2;
}
else
{
if(o2 instanceof LRR && o1 instanceof PickupNode)
{
player = (LRR)o2;
pickup = (PickupNode)o1;
}
}
LRR player = null;
PickupNode pickup = null;
if(o1.getParent() != null && o1.getParent() instanceof LRR)
{
player = (LRR)o1.getParent();
}
if(o2.getParent() != null && o2.getParent() instanceof LRR)
{
player = (LRR)o2.getParent();
}
if(o1 instanceof PickupNode)
{
pickup = (PickupNode)o1;

if(player != null && pickup != null)
{
player.applyPickup(pickup);
}
}

@Override
public void endContact(Contact contact) {
if(o2 instanceof PickupNode)
{
pickup = (PickupNode)o2;

}

@Override
public void postSolve(Contact contact, ContactImpulse impulse) {


if(player != null)
{
System.out.println("player found");
}

@Override
public void preSolve(Contact contact, Manifold oldManifold) {
if(pickup != null)
{
System.out.println("pickup found");
}

if(player != null && pickup != null)
{
//player.applyPickup(pickup);
}
});
}

}


// ctors

public PickupNode(String name, int posX, int posY, int sizeX, int sizeY)
{
super(null, null);

setPosition(posX, posY);
setDimensions(sizeX, sizeY);

this.body.setGravityScale(0);
}
}
7 changes: 6 additions & 1 deletion fanta-is-awesome/src/com/siegedog/hava/engine/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public class Node {
protected ArrayList<Node> children = new ArrayList<Node>();
protected Node parent;
protected Node parent = null;

// LinkedList<Message> messages = new LinkedList<Message>();
protected static final ArrayList<RenderNode2D> renderNodes = new ArrayList<RenderNode2D>();
Expand Down Expand Up @@ -40,6 +40,11 @@ public String getName() {
return name;
}

public Node getParent()
{
return parent;
}

/*
protected final Node qc(Class c) {
for (Node node : children)
Expand Down

0 comments on commit a59e19f

Please sign in to comment.