• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

[SOLVED] How can I make limited attacks and change sprites?

S

STARxd

Guest
So for the past day I have been trying to figure out how to make a bomb attack but I had no luck. If you can, try to make this as simple as possible because im still new to gamemaker. What I need is that when you press 'spacebar' a bomb will place where the player is, and the sprite (used in the GUI event) at the top left corner will change to a different sprite every time I press it. Once I press 'spacebar' three times the attack will stop working until I respawn. Is there anyway I can do this?

The bombs already work fine, and I have all the sprites I need. I have 'spr_bomb3', 'spr_bomb2', 'spr_bomb1', and 'obj_bomb'

spr_bomb3 will switch to spr_bomb2 then spr_bomb1 and finally no sprite (everytime I push spacebar)
 

obscene

Member
So you only need a variable to track which bomb you are currently on, right?
Code:
global.bomb_number=3;
When you press space, you see which bomb you are on...
Code:
if global.bomb_number>0
  {
  // do stuff
  }
When you create a bomb, decrease bomb number...
Code:
global.bomb_number--;
When you draw your sprite, you see what the number is...
Code:
switch (global.bomb_number)
  {
  case 3:
  draw_sprite(...);
  break;

  case 2:
  draw_sprite(...);
  break;

  etc
  }
When you die, just repeat from the top. Set it back to 3 and continue on.
 
S

STARxd

Guest
Wow! Everything works perfectly! Thank you so much, I couldn't find a tutorial to anything similar to this. I appreciate it a lot! :D
 
Top