yes, there are updates for player and monsters like:
if hit then give them linearImpulse and angularvelocity
etc...
i have now both in the fixed timestep and will see if there are still performance problems....
- updatePlayers:
- if player.dead == true -> eliminate from game
- else: player.update()
- if player.hit == true -> let player whirl around
(player.body gets some physic impulses like setAngularVelocity, applyLinearImpulse)
subtract 1 life, ....
if lifes == 0 player.dead = true
...
- if jump-button pressed == true -> applyLinearImpulse ...
- ...
...
- updateMonsters:
- if monster.dead == true -> eliminate from game
- else: monster.update()
- if monster.hit == true -> whirl monster around
- monster.dead = true
...
- monster.counter == 0 -> set level end = true
- updateBullets:
- if bullet.isExploded == true
- eliminate bullet from game
- send back to bulletPool
- else: bullet.update()
- if bullet.letBurst == true
- start explode-animation
- physics: setLinearVelocity = 0
- if explode-animation_finished == true -> bullet.isExploded = true
- ...
- updateCollectables:
- if collectable.isActive == true -> collectable.update()
- if collectableType == .... setFriction
- if touches wall -> bounce back (applyLinearImpulse)
- ...
- else:
- eliminate from game
- send back to CollectablesPool
- ...
- updateVisuals: move and fade points-visuals
- update ...
- update ...
- update ...
- update level End
- if level end = true switch game_state ....
public interface BeginContact {
public void beginContact(Contact contact, Fixture otherFixture);
}
public interface EndContact {
public void endContact(Contact contact, Fixture otherFixture);
}
public class LevelContacts implements ContactListener {
@Override
public void beginContact(Contact contact) {
Fixture fixA = contact.getFixtureA();
Fixture fixB = contact.getFixtureB();
Object obA = fixA.getBody().getUserData();
Object obB = fixB.getBody().getUserData();
if (obA instanceof BeginContact)
((BeginContact) obA).beginContact(contact, fixB);
if (obB instanceof BeginContact)
((BeginContact) obB).beginContact(contact, fixA);
}
@Override
public void endContact(Contact contact) {
Fixture fixA = contact.getFixtureA();
Fixture fixB = contact.getFixtureB();
Object obA = fixA.getBody().getUserData();
Object obB = fixB.getBody().getUserData();
if (obA instanceof EndContact)
((EndContact) obA).endContact(contact, fixB);
if (obB instanceof EndContact)
((EndContact) obB).endContact(contact, fixA);
}
...
}public class GameObject implements BeginContact {
Body body;
public GameObject setup(World world, OtherStuff otherStuff) {
body = world.createBody(...stuff);
body.setUserData(this);
...
}
@Override
public void beginContact(Contact contact, Fixture otherFixture) {
Gdx.app.log("beginContact", this.toString());
}
...
}Users browsing this forum: No registered users and 2 guests