Moving Along a Path help
#1
Posted 04 May 2012 - 05:01 PM
I am working on a simple board game idea and am running into an issue of how to implement the movements. I want it so I set a path along the entire map (board) with a node on each space. I have a "roll" button that will randomly generate a number from 1-6. Based upon the number, I want the player/cpu to move that many nodes along the path. Is this possible or do I need to do this a different way?
Also, I figure once it gets close to the end of the path (loop back to start) I will have a simple check:
moveTo = rndNum + currentNode;
if ( moveTo >= totalNodes)
{
moveTo = moveTo - totalNodes;
}
Or will the path just loop itself if I have it closed?
Thanks
#2
Posted 04 May 2012 - 05:30 PM
in the alarm event you reset it to 0 again
and initialize the path with speed 0 in the create event and select to restart when it is done.
#3
Posted 21 May 2012 - 06:52 PM
try setting an alarm when you click to a certain number and set path_speed to 4 or something like that
in the alarm event you reset it to 0 again
and initialize the path with speed 0 in the create event and select to restart when it is done.
This topic is exactly what I need. Are the nodes to a path saved in memory? It would be awesome to have built in functionality where you simply can advance a object to the next node or previous node, or any node with simple code. Is this posible now?
#4
Posted 23 May 2012 - 02:27 AM
try setting an alarm when you click to a certain number and set path_speed to 4 or something like that
in the alarm event you reset it to 0 again
and initialize the path with speed 0 in the create event and select to restart when it is done.
This topic is exactly what I need. Are the nodes to a path saved in memory? It would be awesome to have built in functionality where you simply can advance a object to the next node or previous node, or any node with simple code. Is this posible now?
Does anyone know if this is possible?
#5
Posted 23 May 2012 - 10:55 AM
#6
Posted 23 May 2012 - 11:19 AM
path_get_point_x(ind,n) path_get_point_y(ind,n)if you place a node on each, then you should be able to return the cordinates with those .. as for the code, you could move to the next with mp_linear_step or any other of those, when there you increase your current position, and check if this is the target position, if not then target the next node..
@akaru7251: atm it looks like your code jumps directly to the node you will end at, instead of increasing it with 1, moving there and reapeating that untill it have moved its steps.. if you want to move it back to the first then just check if it is on the last one becore increasing it .. if so then place it on the first and don't increase it.
A board editor project I got:mario_party_array_v0_5.gmk
(GM 8.0 pro)
Edited by FoxInABox, 23 May 2012 - 11:28 AM.
#7
Posted 23 May 2012 - 05:34 PM
How about this, make the path go around the entire board and set it to restart at the end and set the path speed to 0. In the player object, put in the create event: spaces_to_be_moved and set that var to 0. When you roll, add that number to the var and set the path speed to whatever. Then in a collision event for the node have it set player.spaces_to_be_moved to -1 and check the relative box. Then in your step event for your player, check var if spaces_to_be_moved = 0 (perform next action) Path speed = 0.@ondesic:
path_get_point_x(ind,n) path_get_point_y(ind,n)if you place a node on each, then you should be able to return the cordinates with those .. as for the code, you could move to the next with mp_linear_step or any other of those, when there you increase your current position, and check if this is the target position, if not then target the next node..
@akaru7251: atm it looks like your code jumps directly to the node you will end at, instead of increasing it with 1, moving there and reapeating that untill it have moved its steps.. if you want to move it back to the first then just check if it is on the last one becore increasing it .. if so then place it on the first and don't increase it.
A board editor project I got:mario_party_array_v0_5.gmk
(GM 8.0 pro)
#8
Posted 23 May 2012 - 06:17 PM
Did I solve your problem?How about this, make the path go around the entire board and set it to restart at the end and set the path speed to 0. In the player object, put in the create event: spaces_to_be_moved and set that var to 0. When you roll, add that number to the var and set the path speed to whatever. Then in a collision event for the node have it set player.spaces_to_be_moved to -1 and check the relative box. Then in your step event for your player, check var if spaces_to_be_moved = 0 (perform next action) Path speed = 0.
@ondesic:path_get_point_x(ind,n) path_get_point_y(ind,n)if you place a node on each, then you should be able to return the cordinates with those .. as for the code, you could move to the next with mp_linear_step or any other of those, when there you increase your current position, and check if this is the target position, if not then target the next node..
@akaru7251: atm it looks like your code jumps directly to the node you will end at, instead of increasing it with 1, moving there and reapeating that untill it have moved its steps.. if you want to move it back to the first then just check if it is on the last one becore increasing it .. if so then place it on the first and don't increase it.
A board editor project I got:mario_party_array_v0_5.gmk
(GM 8.0 pro)
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











