Strategy game (move object(s))
#1
Posted 01 January 2011 - 06:29 PM
Here is a question: How let objects move to a point in a strategy game (mouse clicks, and a object go (not go from a point to another point (direct), but go from one point to another (go as you can go with the function/button "move fixed").
hope you can help me.
#2
Posted 01 January 2011 - 08:02 PM
Here is a question: How let objects move to a point .... (mouse clicks, and a object go ... from one point to another)
Just remember the mouse-click position ins the instance itself and use those in the above command.
#3
Posted 01 January 2011 - 09:27 PM
Here is a question: How let objects move to a point .... (mouse clicks, and a object go ... from one point to another)
?
Just remember the mouse-click position ins the instance itself and use those in the above command.
Thanks, exactly that I want to have.
#4
Posted 01 January 2011 - 09:28 PM
You're welcome.Thanks, exactly that I want to have.
#5
Posted 03 January 2011 - 12:59 PM
#6
Posted 03 January 2011 - 01:49 PM
Set speed to Zero and do not execute that "move towards point" command anymore.How do I get it to stop when it gets to the point the user pressed (can not it this way)?
The easiest way is to check if you are near to the goal (use "point_distance(...)") to determine if you should stop.
Another way is to change the "speed:" in that command depending on the distance you still need to go :
min(point_distance(x,y,TargetX,TargetY),3)The "TargetX" and "TargetY" need ofcourse to be replaced with the same variables as you sued for the "X:" and "Y:" arguments, and the "3" should be replaced what you currently have as the "speed:" argument
Hope that helps.
#7
Posted 03 January 2011 - 06:14 PM
Set speed to Zero and do not execute that "move towards point" command anymore.
How do I get it to stop when it gets to the point the user pressed (can not it this way)?
The easiest way is to check if you are near to the goal (use "point_distance(...)") to determine if you should stop.
Another way is to change the "speed:" in that command depending on the distance you still need to go :min(point_distance(x,y,TargetX,TargetY),3)The "TargetX" and "TargetY" need ofcourse to be replaced with the same variables as you sued for the "X:" and "Y:" arguments, and the "3" should be replaced what you currently have as the "speed:" argument
Hope that helps.
Did not quite understand what you meant.
#8
Posted 03 January 2011 - 09:35 PM
Which part ? Suggestion #1 or suggestion #2 ? And what do you not understand ?Did not quite understand what you meant.
#9
Posted 05 January 2011 - 01:53 PM
Suggestion #1 and #2: Not understand how I shall use it.Which part ? Suggestion #1 or suggestion #2 ? And what do you not understand ?Did not quite understand what you meant.
#10
Posted 05 January 2011 - 03:29 PM
For the first action, the variable you are checking is
point_distance(x,y,TargetX,TargetY)TargetX and TargetY are the x and y co-ordinates of whatever you are moving towards, for example if you are moving towards an object called 'apple' the x co-ordinate would be 'apple.x'
What it does is that if the object is further than 8 pixels away, the object will keep moving towards the target at 4 pixels a step. If it is closer, it stops.
However, the numbers can be different to 8 and 4. Play around a bit and see what works.
P.S. Don't check the relative boxes.
Edited by nukemaster, 05 January 2011 - 03:30 PM.
#11
Posted 06 January 2011 - 05:19 PM
#12
Posted 05 April 2011 - 03:05 PM
#13
Posted 05 April 2011 - 06:26 PM
When you "click" the mouse you copy (in the "mouse" -> "global mouse" -> "global left button" or "global left pressed" event) the "mouse_x" and the "mouse_y" contents into two instance-local variables, and use those two variables in the "point_distance(...)" and "move_towards_point(...)" commands.How can I get coordinates to where the user clicked into the "point_distance ()"
I would suggest you use the "xstart" and "ystart" variables, as hey are already present in the instance.
Hope that clarifies it /helps.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











