If anyone could help with how to do it, That would be much appreciated
Problem with Shooting
#1
Posted 05 January 2011 - 03:40 PM
If anyone could help with how to do it, That would be much appreciated
#2
Posted 05 January 2011 - 05:33 PM
I am creating a game which involves shooting arrows. But i want to know how i can check which direction i am facing to fire which arrow (I have 4 arrow objects, Up, Down, Left and Right)
If anyone could help with how to do it, That would be much appreciated
Create Event:
dire = "";
keypress right:
dire = "right";
keypress left:
dire = "left";
keypress up:
dire = "up";
keypress down:
dire = "down";
Keypress Ctrl:
if (dire == "right") instance_create(x,y,obj_arrow_right) else if (dire == "left") instance_create(x,y,obj_arrow_left) else if (dire == "up") instance_create(x,y,obj_arrow_up) else if (dire == "down") instance_create(x,y,obj_arrow_down)
#3
Posted 05 January 2011 - 06:43 PM
I am creating a game which involves shooting arrows. But i want to know how i can check which direction i am facing to fire which arrow (I have 4 arrow objects, Up, Down, Left and Right)
If anyone could help with how to do it, That would be much appreciated
What batlord said will work. However if you have pro edition then you can use 'direction' and 'image_angle'.
#4
Posted 05 January 2011 - 06:53 PM
This would be better IMO:
if (dire == "right")
{
var obj;
obj=instance_create(x,y,obj_arrow);
with (obj) motion_set(0,4);
}
else if (dire == "left")
{
var obj;
obj=instance_create(x,y,obj_arrow);
with (obj) motion_set(180,4);
}
else if (dire == "up")
{
var obj;
obj=instance_create(x,y,obj_arrow);
with (obj) motion_set(90,4);
}
else if (dire == "down")
{
var obj;
obj=instance_create(x,y,obj_arrow);
with (obj) motion_set(270,4);
}
More lines of code but you don't need to maintain 4 objects.
#5
Posted 05 January 2011 - 07:11 PM
Also there is no need to have 4 arrow objects, its more trouble than what its worth.
This would be better IMO:if (dire == "right") { var obj; obj=instance_create(x,y,obj_arrow); with (obj) motion_set(0,4); } else if (dire == "left") { var obj; obj=instance_create(x,y,obj_arrow); with (obj) motion_set(180,4); } else if (dire == "up") { var obj; obj=instance_create(x,y,obj_arrow); with (obj) motion_set(90,4); } else if (dire == "down") { var obj; obj=instance_create(x,y,obj_arrow); with (obj) motion_set(270,4); }
More lines of code but you don't need to maintain 4 objects.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











