Menu

Recent Posts

Archives

Tag: Collision_Line

As mentioned in a previous post, Level 4 of the GPC was not a lesson, but rather a series of challenges meant to reinforce what was taught in Level’s 2 and 3. This time, I elected to create a new game rather than modify an existing one.

I settled on a top down shooter/adventure game and added features and flourishes as I went along. I used my earlier conceived true grid movement code, but this time, I used a switch statement instead of a series of if statements (or at least fewer of them):

That was my first time using the collision_line, which I don’t think is covered at all in the GPC, though it might be included in his how-to’s somewhere…I came across it after watching a tutorial video by “GM Wolf” on YouTube:

This would have solved a lot of issues for me…for instance, in a previous project, I had an idea to create a trap comprised of two moving blocks which collided into and bounced off of each other. While everything worked fine, it would occasionally cause the block to get stuck in a wall. This happened because it’s movement caused it to overlap before it detected the collision, thereby getting stuck inside the wall, unable to go anywhere.

I solved this before using the place_meeting function, but was never introduced to the End Step Event, which would have been the right way to do it. Nevertheless, I can think of other uses for collision_line and am glad I learned of it!

All in all, I spent about 2 days (most of the weekend) working on this little mini-game, and here are some of the features I included:

Destructible walls that advance in damage by manipulating the image_index

Enemies that can navigate mazes (using John Janeka’s code from Level 12)

Line of Sight for enemies with projectiles

Health, ammunition and keys global variables that persistent between rooms

Lock and key mechanism

A switch that reveals the exit when touched

Randomized muzzle flare and smoke when firing bullets

Randomized impact splatters when an enemy is hit

Different sounds for each impact

Randomized health power up sprites to add variety using a single object

Exits that allow you to advance to the next room

Capped health at 100%

What I not did include were:

Fail condition/game over when you run out of hitpoints

Start screen

Game Over screen

All in all, it’s a neat little game though unfinished, and good practice for more serious projects to come!