Log In  

so maybe this is impossible, or maybe theres something similar that works, but i can't seem to come up with an idea

for reference, this is relating to https://www.lexaloffle.com/bbs/?tid=3585

so right now, the grid for the maze is a two dimensional array. i'm creating it with all values set at 1 (wall), then manually setting values for blocks as 0 (for walkable areas)

this is fine for the little 8x8 maze i made manually for the WIP, but won't scale very well for 16x16 dungeons with multiple floors, just the legwork/tokens required is awful to think about. so i'm trying to come up with other ideas on ways to do this

what im thinking is, its easy to draw the maps as sprites, but is there some way to like..read the sprites as data into an array? like if i could parse 16x16 worth of sprite so that each pixel is a datapoint in a 16x16 array, that would save me tons of space (and effort), but im not sure if thats actually possible. i cant come up with any way to do it anyway, but if someone knows of a way to make this happen im all ears

(alternatively if someone has an idea of an easier way to handle this im always curious about clever suggestions)

P#22834 2016-06-13 11:35 ( Edited 2016-06-13 21:05)

wait just by typing that out i might have just answered my own question lol

P#22835 2016-06-13 11:38 ( Edited 2016-06-13 15:38)

you can read memory directly from the spritesheet with peek, or you could use sget(x,y) if you want the actual pixel values.

thismap = {}
for y=0,15 do
  thismap[y] = {}
  for x=0,15 do
    thismap[y][x] = sget(x,y)

if you're only using one bit, 0 or 1 then you could fit a lot more map data in with a bit of work.

but is there a reason you're not using the map for the map though? it would be much simpler.

P#22836 2016-06-13 12:39 ( Edited 2016-06-13 16:39)

I can see it being easier to use sprites if that's what you fancy, I haven't touched the map editor yet and for a small tile based puzzle game I wrote the levels using a table of strings, although a sprite for each level would have worked just as well. If you've got a low token count in your main code it's possible to fit a lot of data in, especially if you bothered compressing it

P#22840 2016-06-13 14:42 ( Edited 2016-06-13 18:42)

I actually did this for my Pebble Crush game. Levels are laid out on sprite sheets using 2x2 sprites (16x16 level size). I even used the level border to hide some level data on it :) Although I used all 16 values per pixel as 16 different level elements.


P#22842 2016-06-13 15:03 ( Edited 2016-06-13 19:03)

i experimented with this while wanting to make a randomly generated dungeon thing. i made rooms in the sprite editor, something like white pixel = wall, green pixel = door etc. then i would randomly pick from the different rooms and write to map :) somewhere along the line i broke the code otherwise i would share it. but it is definitely a way to go about it!

P#22843 2016-06-13 15:57 ( Edited 2016-06-13 19:57)

With Tower of Rhavenna, I went that far, that I mostly use the first cart and aproximately the half of the second one to store binary data, created and compressed by a python based build system. I'm not only using the sprite section, but the other chunks as well, like music and sound effects.

P#22846 2016-06-13 16:58 ( Edited 2016-06-13 20:58)

yep i was an idiot haha. as soon as i posted that post i went 'wait, i just described sget'

already implemented!

P#22847 2016-06-13 17:05 ( Edited 2016-06-13 21:05)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2023-02-07 15:54:14 | 0.011s | Q:20