【GAMEMAKER】Player Directions

 Information about object: objPlayer

Sprite: sprStand
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
set variable ShotTimer to 0
set variable BulletType to 6
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_index = sprWest;
  BulletType=4;
}
if hspeed<0 && vspeed<0 {
  sprite_index =(sprNorthWest);
  BulletType=3;
}

if hspeed<0 && vspeed>0 {
  sprite_index =(sprSouthWest);
  BulletType=5;
}

if hspeed>0 && vspeed=0 {
  sprite_index =(sprEast);
  BulletType=0;
}
if hspeed>0 && vspeed<0 {
  sprite_index =(sprNorthEast);
  BulletType=1;
}
if hspeed>0 && vspeed>0 {
  sprite_index =(sprSouthEast);
  BulletType=7;
}

if hspeed=0 && vspeed<0 {
  sprite_index =(sprNorth);
  BulletType=2;
}
if hspeed=0 && vspeed>0 {
  sprite_index =(sprSouth);
  BulletType=6;
}

if hspeed!=0 or vspeed!=0 {
  image_single=-1;
} else {
  image_single=1;
}
set variable ShotTimer relative to -1
Collision Event with object objBullet2:
play sound sound0; looping: false
create instance of object objExplode at relative position (0,0)
for all objRestartRoom: set variable restart to true
destroy the instance
Keyboard Event for <Alt> Key:
if expression ShotTimer<0 is true
      create instance of object objOtherBullet at relative position (0,0)
      set variable ShotTimer to 5
Keyboard Event for <Space> Key:
if expression ShotTimer<0 is true
      create instance of object objBullet at relative position (0,0)
      set variable ShotTimer to 25
Key Press Event for X-key Key:
set Alarm 0 to 30

Information about object: objPlayer2
Sprite: sprStand
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
set variable ShotTimer to 0
set variable BulletType to 6
Step Event:
execute code:

hspeed=0;
vspeed=0;

if keyboard_check(ord("D")) hspeed=-4;
if keyboard_check(ord("G")) hspeed=4;
if keyboard_check(ord("R")) vspeed=-4;
if keyboard_check(ord("F")) vspeed=4;

if hspeed<0 && vspeed=0 {
  sprite_index =(sprWest);
  BulletType=4;
}
if hspeed<0 && vspeed<0 {
  sprite_index =(sprNorthWest);
  BulletType=3;
}

if hspeed<0 && vspeed>0 {
  sprite_index =(sprSouthWest);
  BulletType=5;
}

if hspeed>0 && vspeed=0 {
  sprite_index =(sprEast);
  BulletType=0;
}
if hspeed>0 && vspeed<0 {
  sprite_index =(sprNorthEast);
  BulletType=1;
}
if hspeed>0 && vspeed>0 {
  sprite_index =(sprSouthEast);
  BulletType=7;
}

if hspeed=0 && vspeed<0 {
  sprite_index =(sprNorth);
  BulletType=2;
}
if hspeed=0 && vspeed>0 {
  sprite_index =(sprSouth);
  BulletType=6;
}

if hspeed!=0 or vspeed!=0 {
  image_single=-1;
} else {
  image_single=1;
}
set variable ShotTimer relative to -1
Collision Event with object objBullet:
play sound sound0; looping: false
create instance of object objExplode at relative position (0,0)
for all objRestartRoom: set variable restart to true
destroy the instance
Collision Event with object objOtherBullet:
play sound sound0; looping: false
create instance of object objExplode at relative position (0,0)
for all objRestartRoom: set variable restart to true
destroy the instance
Keyboard Event for <Ctrl> Key:
if expression ShotTimer<0 is true
      create instance of object objBullet2 at relative position (0,0)
      set variable ShotTimer to 25

Information about object: objBullet
Sprite: sprBullet
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:

if objPlayer.BulletType=4 sprite_index =(sprBulletW);
if objPlayer.BulletType=3 sprite_index =(sprBulletNW);
if objPlayer.BulletType=5 sprite_index =(sprBulletSW);

if objPlayer.BulletType=0 sprite_index =(sprBulletE);
if objPlayer.BulletType=1 sprite_index =(sprBulletNE);
if objPlayer.BulletType=7 sprite_index =(sprBulletSE);

if objPlayer.BulletType=2 sprite_index =(sprBulletN);
if objPlayer.BulletType=6 sprite_index =(sprBulletS);
set speed to 8 and direction to objPlayer.BulletType*45
Other Event: Outside Room:
destroy the instance

Information about object: objBullet2
Sprite: sprBullet
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:

if objPlayer2.BulletType=4 sprite_index =(sprBulletW);
if objPlayer2.BulletType=3 sprite_index =(sprBulletNW);
if objPlayer2.BulletType=5 sprite_index =(sprBulletSW);

if objPlayer2.BulletType=0 sprite_index =(sprBulletE);
if objPlayer2.BulletType=1 sprite_index =(sprBulletNE);
if objPlayer2.BulletType=7 sprite_index =(sprBulletSE);

if objPlayer2.BulletType=2 sprite_index =(sprBulletN);
if objPlayer2.BulletType=6 sprite_index =(sprBulletS);
set speed to 8 and direction to objPlayer2.BulletType*45
Other Event: Outside Room:
destroy the instance

Information about object: objExplode
Sprite: sprExplodeE
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:

if objPlayer2.BulletType=4 sprite_index =(sprExplodeW);
if objPlayer2.BulletType=3 sprite_index =(sprExplodeNW);
if objPlayer2.BulletType=5 sprite_index =(sprExplodeSW);

if objPlayer2.BulletType=0 sprite_index =(sprExplodeE);
if objPlayer2.BulletType=1 sprite_index =(sprExplodeNE);
if objPlayer2.BulletType=7 sprite_index =(sprExplodeSE);

if objPlayer2.BulletType=2 sprite_index =(sprExplodeN);
if objPlayer2.BulletType=6 sprite_index =(sprExplodeS);
Other Event: Animation End:
destroy the instance

Information about object: objOtherBullet
Sprite: sprBullet
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
set speed to 8 and direction to objPlayer.BulletType*45

Information about object: objRestartRoom
Sprite:
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
set variable restart to false
Alarm Event for alarm 0:
Restart the current room
Alarm Event for alarm 1:
play sound sound1; looping: false
set Alarm 1 to 10
Step Event:
if restart is equal to true
      set Alarm 0 to 30
      set Alarm 1 to 10
      set variable restart to false

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 *