Permalink
Browse files

Merge branch 'master' of github.com:AndreiBarsan/Fanta-is-awesome

  • Loading branch information...
2 parents 0b244a5 + 4e196fc commit d2ec52d764b9fa30333ab2c077a38bf0c598da64 @AndreiBarsan committed Dec 18, 2011
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,16 @@
+package com.siegedog.hava.derpygame;
+
+public class DoNothingPickup extends PickupNode
+{
+ // fields
+
+
+
+ // ctors
+
+ public DoNothingPickup(int posX, int posY, int sizeX, int sizeY)
+ {
+ super("imma do nothing", posX, posY, sizeX, sizeY);
+
+ }
+}
@@ -8,6 +8,9 @@
public class LRR extends Unit {
+ boolean oldLeft = false;
+ boolean left;
+
public LRR(float x, float y, InputNode _inputNode) {
super("Little Red Riding Hewd", x, y, _inputNode, new RenderNode2D(
"data/img/sprites/lrrsm.png", 34, 64));
@@ -16,9 +19,7 @@ public LRR(float x, float y, InputNode _inputNode) {
renderNode.addAnimationByFrameCount("basic", 8, 0.05f);
renderNode.play("basic");
}
-
- boolean oldLeft = false;
- boolean left;
+
@Override
public void update(float delta) {
@@ -35,4 +36,8 @@ public void update(float delta) {
super.update(delta);
}
+ public void applyPickup(PickupNode target)
+ {
+ System.out.println("Found pickup");
+ }
}
@@ -0,0 +1,68 @@
+package com.siegedog.hava.derpygame;
+
+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;
+
+public class PickupNode extends BoxNode
+{
+ // fields
+
+ ContactListener listener;
+
+
+ // ctors
+
+ public PickupNode(String name, int posX, int posY, int sizeX, int sizeY)
+ {
+ super(null, null);
+ setPosition(posX, posY);
+ setDimensions(sizeX, sizeY);
+
+ world.setContactListener(listener = new ContactListener() {
+
+ @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;
+ }
+ }
+
+ if(player != null && pickup != null)
+ {
+ player.applyPickup(pickup);
+ }
+ }
+
+ @Override
+ public void endContact(Contact contact) {
+ }
+
+ @Override
+ public void postSolve(Contact contact, ContactImpulse impulse) {
+ }
+
+ @Override
+ public void preSolve(Contact contact, Manifold oldManifold) {
+ }
+ });
+ }
+}
@@ -55,7 +55,7 @@ public BoxNode(BodyDef bDef, FixtureDef fDef) {
body = world.createBody(bDef);
bodyFixture = body.createFixture(fDef);
-
+ bodyFixture.setUserData(this);
}
public Body getBody() {

0 comments on commit d2ec52d

Please sign in to comment.