Blood and gore are now possible with working Pixel Effects!

Yesterday when I published the update about struggling working with Pixel Effects I sort of fantasized about being able to write an update today to portray my success over the Pixel Effect demon in my code. Victory tastes sweet.

I narrowed the problem down to a logic issue within my game loop. Essentially, the game was removing the Tribute upon death (which is to be expected and desired), which removes the blood effect too because it’s a member variable of the Tribute class.

I solved it by creating an if statement to check for whether or not the Tribute’s blood effect has finished playing before removing the Tribute.


for(Tribute e : em.tributes) {
e.update(delta, player);
if(e.isDead) {
if(!e.blood.isComplete()) {
e.blood.draw(game.batch, delta);
e.blood.allowCompletion();
} else {
em.flagForRemoval(e);
}

} else {
game.batch.draw(e.getCurrentSprite(), e.getX(), e.getY(), e.getWidth(), e.getHeight());
}

This works a lot better now; however, it did introduce a bug where if the minotaur doesn’t fully run through the tribute, sometimes its ghost will persist… I’ll fix this tomorrow. Of course, there is more code which handles the blood effect within the Tribute class, but as always: the source code is readily available on my GitHub repo.

Struggling with Pixel Effects in LibGDX

Today I thought it would be an easy addition to my game to create and add pixel effects, but alas it has proven to be a very frustrating thing indeed.

I’m loading the effect correctly as shown:

blood = new ParticleEffect();
blood.load(Gdx.files.internal("texture/effects/bloodspurt.p"), Gdx.files.internal("texture/effects/"));

But in my game’s render loop where I check to see if that particular tribute is dead and I try to draw the Particle Effect, nothing happens.


for(Tribute e : em.tributes) {
e.update(delta, player);
if(e.isDead) {
em.flagForRemoval(e);
e.blood.start();
e.blood.draw(game.batch, delta);
} else {
game.batch.draw(e.getCurrentSprite(), e.getX(), e.getY(), e.getWidth(), e.getHeight());
}
}

I’m assuming it’s because it’s happening in a render loop and never fully coming to fruition. Adding the allowCompletion() method to the loop doesn’t solve it either…

Does anyone have any ideas or know of a good resource which touches down on this in its source code?

Please let me know in the comments.

The source code is still available on my GitHub, but I haven’t pushed any changes regarding the ParticleEffect implementation.

Labyrinth: now featuring AI and a flexible TiledMap interface

I’ve been meaning to create some medium as to track the development of my projects, so I figured now is as good a time as any to begin doing so. Welcome to Games by Alpacas, a dev blog by yours truly.

Seeing as I’m beginning to document the development in a semi-late stage, I figure it’d be appropriate to explain what exactly Labyrinth is. Labyrinth is a 2D “tile-based” maze crawler based off of the Greek myth of the Labyrinth. According to the myth, young men and women were sent as tributes into the Labyrinth for the Minotaur to feast on. This is a very basic and rudimentary understanding of the myth; however, the that’s just the background of the game. In Labyrinth, you play as the aforementioned Minotaur, hunting down your prey in the enigmatic corridors of the Labyrinth.

Now let’s get this party started.

Today I’ve implemented a basic AI system as well as — what I presume it to be called, — a flexible TiledMap interface. What I mean by that is that the entirety of level design can be completed with the program called Tiled. Character spawn points as well as level design are all encapsulated in the creation of the TiledMap itself within Tiled. Now there is no need to programmatically create and place the game objects in the game as all of the game object creation is handled by the program reading the layers of the TiledMap. The player’s spawn point is on its own separate object layer not unlike how the tribute spawn points are on the tribute layer.

Tiled Interface
The program Tiled creating a Labyrinth map.

The spawn points must be indicated by Rectangles and the origin of the rectangle (the bottom left corner), is where the character will be drawn. As such, it’s important not to draw a spawn point where the character will be stuck in a wall tile.

This change is really exciting as it will now expedite the level creation process as well as open up opportunities for the possibility of accepting player-generated content to play.

I also mentioned the implementation of an AI system. It’s very rudimentary; however, the tributes will detect the player approaching and attempt to run away. They’re not very smart. I will have to look into improving this as I intend to implement a mechanic where the tributes will attempt to escape the Labyrinth.

Feel free to view the source code on my GitHub. If you’re reading this at a later date than it was posted, chances are the source code has changed as I’m still currently working on the project.

Thanks for reading, and stay tuned for future updates on this project as well as some LibGDX tutorials.

A humble dev blog

Follow

Get every new post delivered to your Inbox.