Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Hello Everyone!

So today I had pretty much the whole day to put some work into my game. I managed to add some BULLETS for the players gun. This took some time to get right but I eventually got it.

In my GameScreen, I set up a bullet array to manage all the bullets that need to be rendered. At the moment there are no enemies, but I did have to work on bullet collisions with the walls. For this, I used another array in the ContactListener called "bodiestoRemove". This is then iterated through in the GameScreen update() method, and removes all of the bullets which have collided with the walls.

if (fa.getUserData() != null && fa.getUserData().equals("bullet")) {
 bodiesToRemove.add(fa.getBody());
}
if (fb.getUserData() != null && fb.getUserData().equals("bullet")) {
 bodiesToRemove.add(fb.getBody());
}<span></span>

In the above code, I make the assumtion that the bullet has collided with a wall fixture (since there's nothing else to collide with yet).

Then in the GameScreen, I remove the Bullet from the bullet array and destroy the body:

if (contactListener.getBodies().size > 0) {
 for(Body b : contactListener.getBodies()) {
 bullets.removeValue((Bullet) b.getUserData(), true);
world.destroyBody(b);
}
}

I added a Spike block too, which will reset the level if the player comes in contact with it. This was simply a matter of listening for this in the ContactListener.

That's pretty much it. I also made some changes to textures and animations.

The source is available on GitHub here: https://github.com/RobertFOConnor/SpaceDoctor

Here is a short video showing my progress so far:

I hope to continue work on Doors (for linking maps), Enemies, a nice GUI (showing health, ammo, gas, etc.), and much more! :)

Stay tuned, and if you're still working on your game, Good Luck!

- Yellowbyte :)