Working on a game with a scrolling overworld, with collisions. Not sure yet what it will become, so basics for now.
v0.20 (2016/12/13):
That framework is a good place to start. I used it for my own game too.
But just as a quick list of functions to lookup and learn about that will help...
camera()
mget()
fget()
map()
Thanks - I'm looking for more of a scrolling overworld than a platform game, but there's useful stuff there anyway.
You should draw the map like it is described in this thread:
https://www.lexaloffle.com/bbs/?tid=2348
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"):
Yes. I assumed you were already working on that, but I still pointed it out because it will probably be helpful to other newcomers, too.
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:
map(loc.x/8,loc.y/8,loc.x,loc.y,16,16) |
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.
map(flr(loc.x/8),flr(loc.y/8),flr(loc.x/8)*8,flr(loc.y/8)*8,17,17) |
I had them flr()'d but took it out to see if it'd help. It didn't. I'll try your suggestion though.
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:
https://www.lexaloffle.com/bbs/?tid=3948
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.
Thanks! Currently looking at displaying messages in a message window at the bottom of the screen (I detoured a bit...), but will get back to collision detection after that.
Haha! Collision detection is not going well. Still trying though :)
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.
Well that took a while, but I have warp detection working correctly now, with the bits in place to allow warping from one to another!
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!
I have working warps! Wooooooo!
[Please log in to post a comment]