• 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 (Request) Tile based drawing

S

Shadowblitz16

Guest
I posting this because I have tried multiple times in the past to extend a script like the one I'm about to show you to allow big tiles to be draw by drawing multiple normal tiles it the right place, offset, and source.

I have this script that draws a single animated tile from a sprite but it is limited to only 16x16 tiles
Code:
/// @description sprite_draw(sprite, index, length, fps, pal, x, y)
/// @param sprite
/// @param index
/// @param frames
/// @param fps
/// @param pal
/// @param x
/// @param y

var _spr = argument[0];
var _ind = argument[1];
var _len = argument[2];
var _fps = argument[3];
var _pal = argument[4];
var _x   = argument[5];
var _y   = argument[6];

//Create frame variable
if (!variable_instance_exists(id, "sprite_frame")) sprite_frame = _ind;

//Wrap tile sheet
if (sprite_frame >= ((sprite_get_width(_spr) / 16) * sprite_get_height(_spr) / 16))
    sprite_frame = 0;

//Incerment tile
sprite_frame += ((_fps / 16) / room_speed)

//Wrap tile
if (sprite_frame >= _ind + _len) 
    sprite_frame = _ind;

//Debug
var test1 = floor(sprite_frame);
var test2 = sprite_get_width(_spr) / 16;

//Get tile x and y
var _tx = (floor(sprite_frame) mod (sprite_get_width(_spr) / 16))  * 16;
var _ty = (floor(sprite_frame) div (sprite_get_width(_spr) / 16))  * 16;

//Draw tile
draw_sprite_part(_spr, 0, _tx, _ty, 16, 16, _x, _y);
it uses a index based system to find the tile you want to draw allowing me to limit the number of parameters it uses.

the pal parameter doesn't do anything right now because I haven't actually added it yet but you get the basic idea.

its suppose to work like the old gameboy graphics system although its far from accurate.

my request is that somebody make a version of this that can draw bigger tiles without the bug of tiles clipping at the edge.

thankyou I hope I can see some interest in my request.
 
Top