• 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!

GameMaker Tile Collision CHECKING

P

_Proxy

Guest
hey guys,

i'm making a game where you are on an island surrounded by water. I need help with making the player switch its sprite to swimming when he is not on the ground tile. but when he is on the ground tile he switches back to the normal sprite. I have the switching set up like this:

and btw by tile, i mean tile layer

Code:
if (place_meeting(x, y, obj_ground_collision))
    {
        // Control The Sprite
        image_speed = .75;
        if (len == 0) image_index = 0;

        switch (face)
            {
                case RIGHT:
                        sprite_index = spr_player_right;
                    break;
       
                case LEFT:
                        sprite_index = spr_player_left;
                    break;
       
                case DOWN:
                        sprite_index = spr_player_down;
                    break;
       
                case UP:
                        sprite_index = spr_player_up;
                    break;
            }
    }
else
    {
        image_speed = .75;
        if (len == 0) {image_index = 0;}
        switch (face)
            {
                case RIGHT:
                        sprite_index = spr_player_swim_right;
                    break;
       
                case LEFT:
                        sprite_index = spr_player_swim_left;
                    break;
       
                case DOWN:
                        sprite_index = spr_player_swim_down;
                    break;
       
                case UP:
                        sprite_index = spr_player_swim_up;
                    break;
            }
    }
The problem is that.. I'm a bit lazy and i don't want to place obj_ground_collisions one by one in my rooms. Most tutorials tell me how to move and COLLIDE with a tile but not CHECK a tile.

i could use this to do something like. if the player is not on a ground tile, sprite = normal sprite. But if not, sprite = swimming sprite.




i could use this to do something like. if the player is not on a ground tile, sprite = normal sprite. But if not, sprite = swimming sprite.

i meant
i could use this to do something like. if the player IS ON a ground tile, sprite = normal sprite. But if not, sprite = swimming sprite.
 
Top