Log In  

I'm really struggling with this one...I'm trying to vertical scroll a map (shooter style) and wall tiles in that map collide with the player stop them BUT ALSO push the player down if appropriate.

I got the mget() and fget() stuff kinda of working as I'd hoped but detection seems wishy washy.

I have code for map collisions that works well when the map isn't scrolling, and I tried to translate that over but with the map moving, it didn't work well at all. Especially when it comes to pushing the player down off screen if they are blocked by a wall tile.

I'm hoping someone might have made a cart that uses this type of technique or a snippet that I can reference.

My fallback (as always) is just using a bunch of objects and move them individually (to get the scrolling) but I'm trying not to do that so a) I learn something, and b) because moving a bunch of objects in sync never works and always looks choppy.

Any thoughts, examples, or similar shared stories is appreciated.

P#65407 2019-06-26 14:38

What about:

  • check player/map collision as usual
  • shift map down: map_shift+=1
  • check if player is now colliding with walls
    (player y position is: pos.y-map_shift)
  • if yes, it can only be due to the map shift
  • shift pos.y down
  • check if player position is below screen
  • if yes, kill player

That should work fairly well using standard map collision code.

I got the mget() and fget() stuff kinda of working as I'd hoped but detection seems wishy washy.
wishy washy map collision? how come?

P#65411 2019-06-26 18:38 ( Edited 2019-06-26 18:46)

Thanks, yeah...I know the flow. I think my tile checking is weird when considering side walls going left/right, blocking horz movement but not vertical, etc. It feels like I have too much collision checking going on, but maybe not.

I've just been staring at this for a few days and keep hitting different walls...was hoping someone had handy code that I could see and compare against my own.

I'll keep banging away

P#65412 2019-06-26 18:56

Did you look pico collide.p8 sample?
I used that as the baseline for Nuklear Klone and it is very solid.

Mini sample - enjoy :)

Cart #femojazeda-0 | 2019-06-26 | Code ▽ | Embed ▽ | No License

P#65413 2019-06-26 19:28 ( Edited 2019-06-26 20:01)

Cool. Thanks the quick share. I'll dig in and see what I can learn. Hopefully can combine what I've tried and got working with this and get something awesome. Thanks!

P#65418 2019-06-27 01:35

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-29 00:48:48 | 0.011s | Q:19