【GAMEMAKER】Bomb

Information about object: objPlayer
Sprite: sprStand
Solid: false
Visible: true
Depth: -10
Persistent: false
Parent:
Children:
Mask: sprStand
No Physics Object
Create Event:
set variable sprite to sprStand
set variable BombNumber to 0
set variable DetonateNumber to 0
set variable ShotTimer to 0
Step Event:
execute code:

hspeed=0;
vspeed=0;

if keyboard_check(vk_left) hspeed=-4;
if keyboard_check(vk_right) hspeed=4;
if keyboard_check(vk_up) vspeed=-4;
if keyboard_check(vk_down) vspeed=4;

if hspeed<0 && vspeed=0 {
  sprite=sprWest;
}
if hspeed<0 && vspeed<0 {
  sprite=sprNorthWest;
}

if hspeed<0 && vspeed>0 {
  sprite=sprSouthWest;
}

if hspeed>0 && vspeed=0 {
  sprite=sprEast;
}
if hspeed>0 && vspeed<0 {
  sprite=sprNorthEast;
}
if hspeed>0 && vspeed>0 {
  sprite=sprSouthEast;
}

if hspeed=0 && vspeed<0 {
  sprite=sprNorth;
}
if hspeed=0 && vspeed>0 {
  sprite=sprSouth;
}

sprite_index = sprite
if hspeed!=0 or vspeed!=0 {
  image_single=-1;
} else {
  image_single=1;
}
set variable ShotTimer relative to -1
Keyboard Event for <Space> Key:
execute code:

if ShotTimer<0 {
  BombNumber+=1;
  Bombs[BombNumber]=instance_create(x,y,objBomb);
  ShotTimer=10;
}

Keyboard Event for D-key Key:
execute code:

if ShotTimer>0 exit;

if DetonateNumber<BombNumber {
  DetonateNumber+=1;
  while !instance_exists(Bombs[DetonateNumber]) {
    DetonateNumber+=1;
  }

  score=DetonateNumber;

  if floor(random(10))=1 {
    with Bombs[DetonateNumber] instance_change(objDud,false);
    sound_play(Dud);
  } else {
    with Bombs[DetonateNumber] instance_change(objExplode,false);
    sound_play(Explode);
  }
  ShotTimer=5; 

}


Information about object: objBomb
Sprite: sprBomb
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:

No Physics Object


Information about object: objExplode
Sprite: sprExplode
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Collision Event with object objBomb:
for other object: change the instance into object objExplode, not performing events
Other Event: Animation End:

destroy the instance


Information about object: objDud
Sprite: sprDud
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Other Event: Animation End:

destroy the instance 

No comments:

Renowned Water Expert Reynold Aquino Offers Exclusive Water Softener Discounts

Los Angeles, California - November 21, 2024 - World-renowned water expert Reynold Aquino is excited to announce exclusive discounts on prem...

Contact Form

Name

Email *

Message *