Legacy GM Building a wall by dragging the mouse cursor

Roachant

Member
hello!
I was wondering if anyone can help me.
I'm working on a game where you can build walls to create a room and currently I have it so that you have to place each wall tile one by one.
I found it a bit tedious to do it that way, is there a way I can hold down the mouse button and drag the mouse cursor so that it will build wall tiles all the time while dragging the cursor?
thanks!
Roachant
 

zircher

Member
True, true. That does help since there are dozens a ways to set up your game map.

If you're dropping tiles on a grid, in your game control object you can check for global left pressed and if the tile is empty then fill it with the selected wall tile (assuming you have a selection of tiles to choose from) and on global right pressed if the grid location has a tile in it you can delete that instance.
 

Alvare

Member
As zircher said and also rounding the custom mouse coordinates. I made a replica of re4's inventory system covering that. Could leave a link to that later today if you'd like.
 

Roachant

Member
sorry, here is the code I am using for building items. I hope it's not too confusing! I used Nocturne's old item building tutorial as an example, the items are built with the mask_object.

left mouse click event of mask_object:

if !place_meeting(x,y,obj_Obstacle)
{

var inst = noone;
switch (sprite_index)
{
case spr_plant: inst = instance_create(x,y,obj_plant); break;
case spr_stool: inst = instance_create(x,y,obj_stool); break;
case spr_table: inst = instance_create(x,y,obj_Table); break;
case spr_chair: inst = instance_create(x,y,obj_Chair); break;
case spr_stage: inst = instance_create(x,y,obj_Stage); break;
case spr_bar: inst = instance_create(x,y,obj_Bar); break;
case spr_light1: inst = instance_create(x,y,obj_light1); break;
case spr_cubicle1: inst = instance_create(x,y,obj_cubicle); break;
case spr_toilet: inst = instance_create(x,y,obj_toilet); break;
case spr_lotto: inst = instance_create(x,y,obj_lotto1); break;
case spr_ATM: inst = instance_create(x,y,obj_ATM); break;
case spr_pole: inst = instance_create(x,y,obj_pole); break;
case spr_garbage1: inst = instance_create(x,y,obj_trash_can1); break;
case spr_wall_vertical: inst = instance_create(x,y,obj_wall_topbottom); break;
case spr_wall_horizontal: inst = instance_create(x,y,obj_wall_side); break;
case spr_door: inst = instance_create(x,y,obj_door); break;
case spr_floor_tile: inst = instance_create(x,y,obj_floor_tile); break;
case spr_floor1: inst = instance_create(x,y,obj_Floor); break;
case spr_floor2: inst = instance_create(x,y,obj_Floor_2); break;
}


if (inst!=noone) inst.image_index = image_index;

with (obj_Button_Parent)
{

pressed=false;
image_blend=c_white;
}
global.Money-=cost;
}

As zircher said and also rounding the custom mouse coordinates. I made a replica of re4's inventory system covering that. Could leave a link to that later today if you'd like.
yes please!
 
Top