Not quite sure what you mean? So it only draws the visible area, rather than everything? If so, I intend to do that later.
Current progress is slightly wonky collision detection (walls are "solid"):
OK, I've made the map draw just the "local area" (which has the side effect of letting me change the viewport, so it doesn't have to be full screen!) with:
but now scrolling is horribly jerky.
The draw coordinates (sx, sy) are off. Probably want to flr() the map coordiantes (celx, cely) ,too. Additionally draw 17 rows and columns, because some tiles might be partially off screen.
Aha! It worked! Well, the sx,sy anyway - flr() on the celx,cely doesn't seem to make a difference.
Now to work on the collision detection. Is there a way to define a "hitbox" for my character sprite? At the moment I can clip through stuff if I don't line up!
map() probably ignores the non integer part on that.
For actor/actor collision detection with hitboxes I really liked this tutorial:
In that example only collision detection is shown, but collision handling should not be too hard.
For actor/wall collision you should check out zep's example. He uses fixed size characters in that example, but it should be easyly adabtable to differently sized hitboxes.
Fresh eyes this morning, and I've managed this.
Still some issues - I don't like the "kludge" where I have to offset the sprite. Have I missed something? I want it to line up exactly without moving the sprite over to account for being a square out!
Still, closer than it was before. Also, status area at the bottom in place now. If you walk over the yellow cross panels it triggers.
And collisions are fixed! Well, wall collisions, anyway. I need to provide similar logic for the "warp" panels though.
Things feel like they're progressing! Next task is to have things to interact with.
Well, it's been a little while but I've done a lot of rewriting. I wanted to add doors and switches, with the ultimate aim being to have the switches trigger the doors to open and close, and realised I was duplicating a lot of code: creating three types of object, checking for collisions on three types of objects, drawing three types of object...
So I combined them all!
[Please log in to post a comment]