Log In  

Hi there,

I'm looking to make a procedurally generated level using chunks of the map (16x16 cells per chunk).

I've basically added a random number from 1-3 (the amount of chunks i currently have made) into a table, which I'm then calling later with a for loop and the map function.

Something's not going right, the chunks are completely out of whack :(

There's some initial code in the _init at the top for the table, but the problem (I think), lies in the _draw code at the bottom (clearly labelled as problematic).

Any clues?

Cheers

Tim

Cart #53264 | 2018-06-04 | Code ▽ | Embed ▽ | No License

P#53265 2018-06-04 06:13 ( Edited 2018-06-04 21:20)

That tileset!!!
That sprite animation!!
:_]

What I would do (if I understood what you are trying to do...):

  • limit camera move to shift map by fractional map "chunk" units (e.g. cam.x%(8*3))
  • replace outer left/right map columns by your chunks
  • display map (flr(cam.x/8/3),...)
  • shift whole map (left or right)
  • repeat
P#53271 2018-06-04 14:00 ( Edited 2018-06-04 18:10)

Thanks for this. Not sure I totally understand what you're suggesting, but I'll take a bit more time to process it.

I'll try to explain a little clearer what I'm going for:
So I'd like the camera and character to just pan along as normal, but rather than using the entire map, I'd like it to randomly populate the level with pieces of the map (16x16) so it's different everytime. Would your suggestion achieve this?

I'm used to doing this stuff in Gamemaker Studio so I think a lot of it is just figuring out how Pico-8 likes things done.

Regarding the tileset and animation, thanks! I'm an animator so that part comes easy :)

P#53273 2018-06-04 15:53 ( Edited 2018-06-04 19:53)
1

I started from scratch (using your tileset) and got your infinite scrolling from pre-made tileset working:

Cart #53276 | 2018-06-04 | Code ▽ | Embed ▽ | No License
1

The core idea is to use 3 screens (left/middle/right).
When map is about to get outside leftmost or rightmost screen, shift the map viewport and drop/create left/right screen as needed.
(as it might be confusing - I am using the initial map strip to create reusable 3 chunks out of it!!)

What is left to the reader :)

  • hide tileset poping on the right side (you need to work with 17*17 map chunks)
  • up/down slices (e.g need something like 9 screens buffers or rework the program to work with partial chunks)
  • optimization: copying slices and screens must be done via memcpy
  • stable levels: that is, you need to remap absolute map position into an array of pre-selected chunks (not random as I did)

Hope it helps!

P#53277 2018-06-04 16:50 ( Edited 2018-06-04 20:55)

Oh wow, look at you go!

Thanks heaps for this, should be very helpful.

I'll admit, it's all a little intimidating, but I'll wrap my head around it.

Thanks again.

Tim

P#53278 2018-06-04 17:20 ( Edited 2018-06-04 21:20)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-04-19 17:37:23 | 0.012s | Q:19