F
Freppe
Guest
Hi everyone. I just started using GameMaker a while ago and so far I haven't met any unusual problems, well until now. Everything in my script seems to work well except for the "Slashing" part. The idea is that the attached arm will turn invisible while my sprite begins it's slashing animation. My problem is that even though I set the image_speed to 15 nothing happens. The sprite has no animation otherwise which means its frame speed is set to 0 in the sprite menu. But that shouldn't stop me from changing it right?
Either way here's my code:
Create event:
Step event:
Either way here's my code:
Create event:
Code:
spd = 6;
walkspd = spd;
diagspd = round(spd * ((sqrt(2)) / 2))
cooldown = 0;
hp = 5;
attached = 0;
ammo = 7;
direction = point_direction(x,y,mouse_x,mouse_y);
image_angle = direction;
with (instance_create_layer(x,y,"Instances",obj_arm)) attached = other.id;
Code:
//Movement
direction = point_direction(x,y,mouse_x,mouse_y);
image_angle = direction;
if (keyboard_check(vk_lshift)) {
spd = 2;
with (obj_enemy) sneaking = true;
} else spd = 6;
walkspd = spd;
diagspd = round(spd * ((sqrt(2)) / 2))
rkey = keyboard_check(ord("D"));
lkey = keyboard_check(ord("A"));
ukey = keyboard_check(ord("W"));
dkey = keyboard_check(ord("S"));
hsp = (rkey - lkey) * spd;
vsp = (dkey - ukey) * spd;
//Collisions
if (hsp != 0)
if (place_meeting(x+hsp,y,obj_collision)) {
if (hsp > 0) move_contact_solid(0,hsp);
if (hsp < 0) move_contact_solid(180,-hsp);
hsp = 0;
}
if (vsp != 0)
if (place_meeting(x,y+vsp,obj_collision)) {
if (vsp > 0) move_contact_solid(270,vsp);
if (vsp < 0) move_contact_solid(90,-vsp);
vsp = 0;
}
x += hsp;
y += vsp;
//Diagonal Movement
if (vsp != 0 && hsp != 0) {
spd = diagspd;
} else {
spd = walkspd;
}
//Shooting
var xx = attached.x + lengthdir_x(90,attached.image_angle);
var yy = attached.y + lengthdir_y(90,attached.image_angle);
var originDir = attached.direction;
var originAngle = attached.image_angle
if (mouse_check_button(mb_left) && cooldown < 1 && ammo > 0) {
with (instance_create_layer(xx,yy,"BulletsLayer",obj_bullet)) {
direction = originDir;
image_angle = originAngle;
}
audio_sound_pitch(snd_bullet,random_range(0.9,1.1));
audio_play_sound(snd_bullet,0,0);
cooldown = 40;
ammo--;
with (obj_crosshair) ammo--;
}
if (keyboard_check_pressed(ord("R")) && ammo < 7 && !alarm[0]) {
alarm[0] = 120;
audio_play_sound(snd_reload,2,false);
}
cooldown--;
//Slashing
if (keyboard_check_pressed(ord("F"))) {
attached.image_alpha = 0;
image_speed = 15;
}
if (hp < 1) game_restart();
Attachments
-
71 KB Views: 5