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:
I'm using Game Maker Studio 1.4
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;
}