Jump to content


Photo

How to create blocks in-game?


  • Please log in to reply
4 replies to this topic

#1 _228221

_228221

    GMC Member

  • New Member
  • 2 posts

Posted 17 September 2011 - 01:26 AM

I don't even know where to start. When I set Right-Click - Create Instance of object obj_floor, it doesn't create any blocks - to an extent.

It only creates the block on the player when you right click on the player. How would I change it so it creates a block where the mouse is clicked?

And too where I can't create a block on the player, if that's possible.
  • 0

#2 Furritus

Furritus

    Just another Ferret

  • GMC Member
  • 287 posts
  • Version:GM8

Posted 17 September 2011 - 01:31 AM

here:

 if mouse_check_button_pressed(mb_left) && !place_meeting(mouse_x,mouse_y,OBJECTBLOCK)
 {
  instance_create(mouse_x,mouse_y,OBJECTBLOCK);
 }


thats all i can think of righ now
  • 0

#3 _228221

_228221

    GMC Member

  • New Member
  • 2 posts

Posted 17 September 2011 - 01:46 AM

here:

 if mouse_check_button_pressed(mb_left) && !place_meeting(mouse_x,mouse_y,OBJECTBLOCK)
 {
  instance_create(mouse_x,mouse_y,OBJECTBLOCK);
 }


thats all i can think of righ now


Do I apply it to the player in an Execute a piece of code?

'cuz it doesn't work. ):

It still only puts the object over the player, and it isn't aligned to the grid. I should have included that in the first post though...
  • 0

#4 PixelKing

PixelKing

    Your Highness

  • GMC Member
  • 226 posts
  • Version:GM:Studio

Posted 17 September 2011 - 01:49 AM

Make it global right click instead of regular right click and make instance create of the block. :thumbsup:
  • 0

#5 Furritus

Furritus

    Just another Ferret

  • GMC Member
  • 287 posts
  • Version:GM8

Posted 17 September 2011 - 01:57 AM


here:

 if mouse_check_button_pressed(mb_left) && !place_meeting(mouse_x,mouse_y,OBJECTBLOCK)
 {
  instance_create(mouse_x,mouse_y,OBJECTBLOCK);
 }


thats all i can think of righ now


Do I apply it to the player in an Execute a piece of code?

'cuz it doesn't work. ):

It still only puts the object over the player, and it isn't aligned to the grid. I should have included that in the first post though...




instance_create(obj_mouse.x,obj_mouse.y,OBJECTBLOCK);

proly a code to snap it but i use another object... obj_mouse
THEORETICAL CODE
if mouse_x>=x+16 {x+=16;}
if mouse_y>=y+16 {y+=16;}
if mouse_x<=x-16 {x-=16;}
if mouse_y<=y-16 {y-=16;}

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users