• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

place_meeting doesn't seen to work. Could you help?

V

Vesk

Guest
Hi! I'm making a Pac-Man-like game and I wanted to recreate the Pac-Man maze, but I wanted to make it easier for myself, so that when I change the wall placement it would automatically change the way the wall looks. My pac-man sprite as well as my wall sprites are 16px*16px. Here are the wall sprite images:

Here is the room inside the room editor:

And here is how it looks in-game:

Here is my code inside the create event of obj_wall:

Code:
    image_speed = 0;
  
    //see where we have blocks
    up = place_meeting(x, y - 16, obj_wall);
    upright = place_meeting(x + 16, y - 16, obj_wall);
    right = place_meeting(x + 16, y, obj_wall);
    downright = place_meeting(x + 16, y + 16, obj_wall);
    down = place_meeting(x, y + 16, obj_wall);
    downleft = place_meeting(x - 16, y + 16, obj_wall);
    left = place_meeting(x - 16, y, obj_wall);
    upleft = place_meeting(x - 16, y - 16, obj_wall);
  
    //determine how should the wall look
    if(up && upright && right && downright && down && downleft && left && upleft)
    {
        image_index = 3;
    }
    if( (down && up && !left) || (down && up && !right) )
    {
        image_index = 1;
    }
    if( (right && left && !up) || (right && left && !down) )
    {
        image_index = 1;
        image_angle = 90;
    }
    if( (right && down && !downright) || (right && down && !upleft && !left && !up) )
    {
        image_index = 2;
    }
    if( (up && left && !upleft) || (up && left && !downright && !right && !down) )
    {
        image_index = 2;
        image_yscale = -1;
        image_xscale = -1;
    }
    if( (up && right && !upright) || (up && right && !downleft && !left && !down) )
    {
        image_index = 2;
        image_yscale = -1;
    }
    if( (down && left && !downleft) || (down && left && !upright && !up && !right) )
    {
        image_index = 2;
        image_xscale = -1;
    }
I'm using Game Maker Studio 1.4
 
R

Remer1

Guest
You can use the drag and drop function of movement if you want a package man game.The code you have, for me, it is complicated.For temporary fix,you can put the move function in the keyboard events for movement.I will check your code at that time.
 

Simon Gust

Member
You can use the drag and drop function of movement if you want a package man game.The code you have, for me, it is complicated.For temporary fix,you can put the move function in the keyboard events for movement.I will check your code at that time.
This isn't about movement this is an autotiler, though it is kinda hard to decipher. Especially with these auto tile rules and tileset.
 
V

Vesk

Guest
Never mind I solved it. Since in the third if I change the angle I should undo the change in all other ifs.
 
I

icuurd12b42

Guest
are your origins centered on the sprite tiles? that could be the issue. try not to change the angle... make another sprite for that angle. same with scale... youtube search autotile gamemaker for the right way to do autotile
 
V

vaultapple

Guest
hi i am having a similar problem and could use a new set of eyes as well as help.

/// first checks to see if mouse is in a grid square

if (mouse_x >= && mouse_x < x + 200 && mouse_y >= y && mouse_y < y + 200)
{

///then checks to see if object exists inside that square, if there is then exit
///the problem is here where will still create object then there is one in the square

if instance_exists(obj_all_tile_parent)
{
if position_meeting(x >= && x < x + 200 , y >= y && y < y + 200 , obj_all_tile_parent)
{pressed = false exit}}

///then checks to see if no object exists inside that square if there is no object then creates one

instance_create(x, y, global.tile)
pressed = false
exit}
 

Simon Gust

Member
hi i am having a similar problem and could use a new set of eyes as well as help.

/// first checks to see if mouse is in a grid square

if (mouse_x >= && mouse_x < x + 200 && mouse_y >= y && mouse_y < y + 200)
{

///then checks to see if object exists inside that square, if there is then exit
///the problem is here where will still create object then there is one in the square

if instance_exists(obj_all_tile_parent)
{
if position_meeting(x >= && x < x + 200 , y >= y && y < y + 200 , obj_all_tile_parent)
{pressed = false exit}}

///then checks to see if no object exists inside that square if there is no object then creates one

instance_create(x, y, global.tile)
pressed = false
exit}
That could be made simpler I guess
Code:
if (point_in_rectangle(mouse_x, mouse_y, x, y, x+200, y+200))
{
 if (mouse_check_button_pressed(mb_left))
 {
  var square = collision_point(mouse_x, mouse_y, obj_all_tile_parent, false, false);
  if (square == noone) // if no tile is there
  {
   instance_create(x, y, global.tile);
  }
 }
}
Something like this. Not sure why and whose object you are checking x and y respecitve, creating the tile at whose x and y.
 
V

vaultapple

Guest
wow thanks you are a time saver I have spent hours on different versions of code and nothing.
wow thanks again
 
Top