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):
check out this platformer framework
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()
You should draw the map like it is described in this thread:
https://www.lexaloffle.com/bbs/?tid=2348
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.
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) |
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.
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, 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]



