3. Attacking and Collisions

https://www.youtube.com/watch?list=PLhIbBGhnxj5JcbfoxS_CWTnImRL_wB_Wg&v=kpjqweJv_0g&feature=emb_logo

Focus on attacks and collisions in the game. In the game, we'll have two instances of collision. That is:

  1. The player colliding with asteroids

  2. Bullet colliding with asteroids (attacks)

Player colliding with asteroids

In GameMaker, collision occurs when one object's hitbox (collision mask) overlaps with another object's hitbox. To set this up, it's quite simple. We simply go to the desired sprite and find the Collision Mask with all the configurations for it.

In the settings, we have a few different options for the Type of Collision Mask that we can set for our sprite. These range from a rectangle that surrounds the entire sprite to precise masks that check the state of each pixel individually.

Notably, since collisions are quite a costly in computational power, having precise hitboxes for such a could affect the performance of the game. Hence, I've prioritised efficiency to avoid our game lagging and chosen a custom diamond shaped hitbox to fit our triangular ship. This obviously doesn't cover the entire sprite especially with the wings exposed, but it makes more sense for gameplay and feels more fair than having a square hitbox that is larger than the ship.

As there can be multiple asteroids on the screen at one time, it is More efficient for 1 plate

Last updated