Flashpants
Member
Hi
I'm having an issue designing a satisfactory system whereby a player can drag and define an area within a top-down style game. Within the game, the player can define what a room is used for in an translucent overlay that appears when the player is within "construction mode". The game is designed on a 64 x 64 grid.
Please could you let me know how to best implement the above as I am certain there must be a straightforward way of doing this that I am overlooking.
Note that I do not need to just have a mouse select system that snaps to grid, I need to have the the grid squares that are selected to actually change within the overlay so that the game is aware of what squares have been designated as which rooms. I believe that each square will need some kind of variable attributed to it to allow this.
The only way that I can think of achieving this is using a DS grid - I have tried to overcome this using a DS grid which has allowed me to designate each grid square with a value and to change the appearance and the value of the said square by dragging over it, however there is a huge amount of slowdown using this system which I seem unable to overcome. This is because when the room tile overlay is visible in construction mode, the tiles of every square in the room (which is quite large) needs to be drawn every step (I cannot figure out a way of stopping this). The code that I have used for this is below.
This is in the code in the draw event of the DS grid controller object:
The below is the code that I have put within the mouse controller object step event to define the relevant area being mouse dragged:
Note that although I have attempted to solve this problem with a DS grid, I am very much open to solutions that solve this in another way!
Thank you for any help.
I'm having an issue designing a satisfactory system whereby a player can drag and define an area within a top-down style game. Within the game, the player can define what a room is used for in an translucent overlay that appears when the player is within "construction mode". The game is designed on a 64 x 64 grid.
Please could you let me know how to best implement the above as I am certain there must be a straightforward way of doing this that I am overlooking.
Note that I do not need to just have a mouse select system that snaps to grid, I need to have the the grid squares that are selected to actually change within the overlay so that the game is aware of what squares have been designated as which rooms. I believe that each square will need some kind of variable attributed to it to allow this.
The only way that I can think of achieving this is using a DS grid - I have tried to overcome this using a DS grid which has allowed me to designate each grid square with a value and to change the appearance and the value of the said square by dragging over it, however there is a huge amount of slowdown using this system which I seem unable to overcome. This is because when the room tile overlay is visible in construction mode, the tiles of every square in the room (which is quite large) needs to be drawn every step (I cannot figure out a way of stopping this). The code that I have used for this is below.
This is in the code in the draw event of the DS grid controller object:
Code:
if global.roomView = true // = true when in construction mode
{
for (var row = 0; row<ds_grid_height(global.dsGrid); row++) {
for (var col=0; col<ds_grid_width(global.dsGrid); col++) {
if (global.dsGrid[# col, row] == -1) {
continue;
}
var subimage = global.dsGrid[# col, row];
if subimage = 0
{
draw_sprite(spr_test, subimage, col*64, row*64);
}
}
}
}
The below is the code that I have put within the mouse controller object step event to define the relevant area being mouse dragged:
Code:
if (px != -1 && py != -1) and instance_exists(obj_room1Build)
{
ds_grid_set_region(global.dsGrid, px div 64, py div 64, mouse_x div 64, mouse_y div 64, 1)
}
Thank you for any help.