M
Molakar
Guest
I'm creating a manager game where a part of the game will focus around the creation of tactics using a waypoint system for the "players" you control. I've successfully experimented with making the "player" move from their starting position to a set of coordinates by letting them create their own path (if I recall correctly it was the mp_grid_path function) but now I want to take it one step further and have you, the manager, create a path for your players to follow.
Imagine something like Football Manager but instead of plotting out where on the football field the players shall position themselves I want to move my players using a system of waypoints. What I've thought up is a "tactics screen" where you place the waypoints for each player and then save them, when the corresponding "simulation room" loads the waypoints for each player also loads. The players then follow their respective route until completion.
Below is a quick sketch of what I'd imagine.
I've made a room with obstacles, made a copy of that room and then added a "_tactics" to the end of the name. My idea is to have manager enter the "tactics room", fiddle with the tactics, save it and then watch it all play out in the "simulation room" (the one without the "_tactics" at the end of its name).
I have an object called "obj_player_icon", that is what you see in the lower right corner of the image of the tactics screen. The object has the following events:
Create event
Alarm [0]
Alarm[1]
I also have three "mouse-events"
Left pressed
Global Left Pressed
Global Right Pressed (this was mostly to check if everything worked, it "starts" the player when the RMB is pressed and the player is selected)
For the object I use as waypoints ("obj_chkpnt") I have a Collision event that checks if obj_chkpnt collides with obj_player and if they do I destroy the waypoint so that the player can move towards the next waypoint. This was just added because I wanted to test how my player would move with multiple waypoints instead of just moving to a final destination. I'm guessing I have to come up with some other way to remove the waypoints from the array when in the simulation room.
So, where I'm at now is that I've checked that everything works and it does. The player moves towards the waypoints in order (doesn't matter which waypoint is closest, it always goes for the first placed waypoint, exactly like I want it to behave) and the waypoints gets destroyed when the player touches them. But I am unsure how to proceed to "transfer" the tactic made in one room so I can simulate the movement in another room? Do I need like a controller object or something like that that I store the arrays in and then access them in the room where I simulate everything?
TL;DR:
I have two identical rooms (room A and B) and want to use one room for making tactics with waypoints and the other room for simulating how those tactics are carried out by "players". So waypoints from room A have to be stored in an array that the "player" can access when in room B but I don't know how to do it.
I'm using IDE Version 2.2.3.436.
Imagine something like Football Manager but instead of plotting out where on the football field the players shall position themselves I want to move my players using a system of waypoints. What I've thought up is a "tactics screen" where you place the waypoints for each player and then save them, when the corresponding "simulation room" loads the waypoints for each player also loads. The players then follow their respective route until completion.
Below is a quick sketch of what I'd imagine.
I've made a room with obstacles, made a copy of that room and then added a "_tactics" to the end of the name. My idea is to have manager enter the "tactics room", fiddle with the tactics, save it and then watch it all play out in the "simulation room" (the one without the "_tactics" at the end of its name).
I have an object called "obj_player_icon", that is what you see in the lower right corner of the image of the tactics screen. The object has the following events:
Create event
Code:
player_selected = false; //Player object initially starts out as deslected
array_x[0] = 0;
array_y[0] = 0;
markers = 0;
count = 0;
Alarm [0]
Code:
if markers > count
{
grid = mp_grid_create(0, 0, (room_width/8), (room_height/8), 8, 8);
path = path_add();
mp_grid_add_instances(path, obj_wall,1);
mp_grid_path(grid,path, x, y, array_x[count], array_y[count], 1);
path_start(path, 3, path_action_stop, 1);
alarm[1] = 1;
}
else
if markers = count
{
count = 0;
markers = 0;
}
Alarm[1]
Code:
if obj_player_icon.x = array_x[count] and obj_player_icon.y = array_y[count]
{
count ++;
alarm[0] = 1;
}
else
{
alarm[1] = 1;
}
I also have three "mouse-events"
Left pressed
Code:
//Selects player with press of LMB if player is not selected
//Changes sprite from spr_player to _spr_player_selected
if player_selected = false
{
player_selected = true;
sprite_index = spr_player_selected;
}
//If player is selected deselct player and change back sprite from spr_player_selected to spr_player
else
{
player_selected = false;
markers = 0;
sprite_index = spr_player;
}
Global Left Pressed
Code:
//If player is selected create a checkpoint/"marker" where mouse pointer is
//Store mouse coordinates in array called [markers]
if player_selected = true
{
array_x[markers] = mouse_x;
array_y[markers] = mouse_y;
markers ++;
instance_create_layer(mouse_x, mouse_y, "Checkpoints", obj_chkpnt); //Places waypoint on map
}
Global Right Pressed (this was mostly to check if everything worked, it "starts" the player when the RMB is pressed and the player is selected)
Code:
//If player is selected, deslect when RMB is pressed
//Change back to deselected sprite (spr_player)
if player_selected = true
{
player_selected = false;
alarm[0] = 1;
sprite_index = spr_player; //changes sprite from selected (spr_player_selected) to deselected (spr_player)
}
For the object I use as waypoints ("obj_chkpnt") I have a Collision event that checks if obj_chkpnt collides with obj_player and if they do I destroy the waypoint so that the player can move towards the next waypoint. This was just added because I wanted to test how my player would move with multiple waypoints instead of just moving to a final destination. I'm guessing I have to come up with some other way to remove the waypoints from the array when in the simulation room.
Code:
instance_destroy(); //Destroy obj_chkpnt when obj_player touches it
So, where I'm at now is that I've checked that everything works and it does. The player moves towards the waypoints in order (doesn't matter which waypoint is closest, it always goes for the first placed waypoint, exactly like I want it to behave) and the waypoints gets destroyed when the player touches them. But I am unsure how to proceed to "transfer" the tactic made in one room so I can simulate the movement in another room? Do I need like a controller object or something like that that I store the arrays in and then access them in the room where I simulate everything?
TL;DR:
I have two identical rooms (room A and B) and want to use one room for making tactics with waypoints and the other room for simulating how those tactics are carried out by "players". So waypoints from room A have to be stored in an array that the "player" can access when in room B but I don't know how to do it.
I'm using IDE Version 2.2.3.436.