28 lines
826 B
Plaintext
28 lines
826 B
Plaintext
|
// Script assets have changed for v2.3.0 see
|
||
|
// https://help.yoyogames.com/hc/en-us/articles/360005277377 for more information
|
||
|
|
||
|
function keyboard_controller(){
|
||
|
var xMove = keyboard_check(ord("D")) - keyboard_check(ord("A"));
|
||
|
var yMove = keyboard_check(ord("S")) - keyboard_check(ord("W"));
|
||
|
if (xMove != 0 || yMove != 0){
|
||
|
self.sprite_index = sPlayerRun_strip7;
|
||
|
} else {
|
||
|
self.sprite_index = sPlayerIdle_strip4;
|
||
|
}
|
||
|
if (xMove != 0) self.image_xscale = xMove;
|
||
|
self.x += xMove * self.spd;
|
||
|
self.y += yMove * self.spd;
|
||
|
|
||
|
|
||
|
// Shooting Cooldown.
|
||
|
self.cooldown--;
|
||
|
if (self.cooldown <= 0 && mouse_check_button(mb_left)){
|
||
|
self.cooldown = self.cooldownTarget;
|
||
|
audio_play_sound(aBullet, 1, false);
|
||
|
with (instance_create_layer(self.x, self.y, "bullets", oBullet)){
|
||
|
direction = oGun.image_angle;
|
||
|
speed = 8;
|
||
|
}
|
||
|
}
|
||
|
}
|