Nothing Found :(
JSE - Tilemap
10th May 2021  
Wasn't expecting to be doing this, today..

-=-=-

// The Wall // Use your mouse to graffiti the wall! // by Jayenkai // Created 2021/5/10 Symbol 0,"0__5_9AB?5AB?C5B.C,5@B.59AB.C5AB,C,5B,"; Graphics 1024,1024,0 SetTilemapSize(64,64) x=0;y=0 Repeat y=0 Repeat SetTile(x,y,0) SetTileCol(x,y,(x+y)%8) y=y+1 Until y>=64 x=x+1 Until x>=64 Repeat CLS 40,40,80 scx=Sin(Mills()*0.025)*1024 scy=0-Cos(Mills()*0.0134)*1024 WrapTilemap 0-scx,0-scy x=Floor(((MouseX()+16)+scx)/32) y=Floor(((MouseY()+16)+scy)/32) If MouseDown() SetTileCol(x,y,8) endif Flip Forever
Open JSE


I've tried a whole bunch of things to get everything running a little bit smoother, but between my terrible drawing functions, and the whole "hey, it's a script, and it's parsing it.. What can you do?" speed of JSE, it's kinda crummy when it comes to drawing backgrounds.

Until today!!
Kinda.. Mostly..

A tilemap engine.
Don't expect miracles, but do allow yourself to doodle some backgrounds and whatnot.
You can specify a size for the tilemap, up to 256x256 tiles in size, though it's not currently very well optimised for anything above 64x64.
Set tiles with SetTile(x,y,Symbol)
SetTileColor(x,y,Colour) can be used, using the Symbol colours.
SetTileRotation(x,y,Angle), SetTileOffset(x,y,OffsetX,OffsetY), SetTileAlpha(x,y,Alpha)
There's also a really handy SetTileData(x,y,"Whatever you want") thing, too..

You can then read tiles back with GetTile(x,y), GetTileData(x,y), GetTileColor, GetTileRotation, etc.

All tiles are 32x32 pixels in size.., a standard Symbol sprite.
Drawing is a little bit quirky, but when you say DrawTilemap(x,y), the x,y value will be the middle of the top-left tile..
That means if you DrawTilemap(0,0), then DrawImg(32,32,PlayerSprite) the Player will be offset, and standing on the tile at 1,1..
.. if that makes sense..?
Aaah, maths!!!

DrawTilemap (and the accompanying WrapTilemap) both respect Scale and Alpha
I'd like to add Rotation, but that screws the numbers up even more. We'll see if I can manage it, in the future.
I now need to add a bunch of collision style functions to work with everything, I reckon.
If you've any suggestions, be sure to let me know.

Views 7, Upvotes 0
Jse
Site credits : Jayenkai put all his heart and soul into everything you can see on this site.
(c) Jayenkai 2017 and onwards, site design Rychan. RSS feed
Blog - JSE - Tilemap - AGameAWeek