• 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 [SOLVED]How do i draw sprite tiles through gml

B

bluef

Guest
The code bellow is what i am using
Code:
    if(xi >= 640)
    {
        xi = 0;
        yi += 64;
    
    }
    if(yi >= 640)
    {
        yi = 0;
        xi = 0;
    }
    draw_sprite(curr_draw_bg,0,xi,yi);
    xi = xi + 64;
it draws sprite in each new position and then it dissapears and draws into next. how do i make it so that the sprite that was drawn in last position stays.
 

Amon

Member
Create a new layer called sprite_layer. In your rooms creation code add this.

Code:
for ( xi = 0; xi < 10; xi++ )
{
    for ( yi = 0; yi < 10; yi++ )
    {
        layer_sprite_create("sprite_layer", xi * 64, yi * 64, sprTile1);
    }
}
Change the number "64" to whatever the size of your sprite is i.e. 32 pixels wide or 16 pixels wide etc.

We multiply by 64 in the for/next loop because each sprite tile I use is 64 pixels wide. To get how many tiles would fit in a 640 width room just divide the room width by the size of the tile. So in this example if we divide 640 by 64 we get 10. That means in a room that is 640 pixels wide we can fit 10 64 by 64 pixel tiles in it, same for the height. That's assuming that your tile/sprite is 64x64 pixels in size.
 
Last edited:
B

bluef

Guest
Create a new layer called sprite_layer. In your rooms creation code add this.

Code:
for ( xi = 0; xi < 10; xi++ )
{
    for ( yi = 0; yi < 10; yi++ )
    {
        layer_sprite_create("sprite_layer", xi * 64, yi * 64, sprTile1);
    }
}
Change the number "64" to whatever the size of your sprite is i.e. 32 pixels wide or 16 pixels wide etc.

We multiply by 64 in the for/next loop because each sprite tile I use is 64 pixels wide. To get how many tiles would fit in a 640 width room just divide the room width by the size of the tile. So in this example if we divide 640 by 64 we get 10. That means in a room that is 640 pixels wide we can fit 10 64 by 64 pixel tiles in it, same for the height. That's assuming that your tile/sprite is 64x64 pixels in size.

thanks it works. and i did solve the problem by myself but i guess draw event cant really draw too many sprites from the same code and it satretd flickering when i tried to dounle the number of sprites drawn. but ur solution works perfectly :D
 
Top