This is designed for a movement system that utilizes image_angle.
Okay, so, here is the movement system I will be using:
STEP EVENT:
image_angle=point_direction(x,y,mouse_x,mouse_y);
if mouse_check_button(mb_right) && canmove=1{
move_towards_point(mouse_x,mouse_y,4)
}
if mouse_check_button(mb_none){
speed=0
}
DRAW EVENT:
draw_sprite_ext(sprite_index,image_index,x,y,image_xscale,image_yscale,image_angle,image_blend,image_alpha);
That will make it so the player points to the mouse, and will move towards it when the right button is pressed. If you use this, make sure the player sprite is facing Right, and it's Origin is centered.
Now, for the shooting.
Here is the code I use, I will explain it shortly:
STEP EVENT:More at indiegaming.org
if mouse_check_button(mb_left) && canshoot=1{
ii=instance_create(x,y,o_bullet);
ii.speed=20;
ii.direction=o_player.image_angle-2+random(4);
ii.image_angle=ii.direction
canshoot=0
alarm[0]=10
}
ALARM 0 EVENT:
canshoot=1
No comments:
Post a Comment