Log In  

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):

Cart #33444 | 2016-12-13 | Code ▽ | Embed ▽ | No License

P#32378 2016-11-10 11:44 ( Edited 2016-12-13 16:02)

P#32379 2016-11-10 11:55 ( Edited 2016-11-10 16:55)

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()

P#32383 2016-11-10 13:47 ( Edited 2016-11-10 18:47)
:: deKay

Thanks - I'm looking for more of a scrolling overworld than a platform game, but there's useful stuff there anyway.

P#32452 2016-11-14 05:41 ( Edited 2016-11-14 10:41)
:: deKay

OK so that was easy so far.

Cart #32457 | 2016-11-14 | Code ▽ | Embed ▽ | No License

P#32458 2016-11-14 06:38 ( Edited 2016-11-14 11:38)
:: deKay

(Moved thread to WIP as it's better suited there now!)

P#32459 2016-11-14 07:05 ( Edited 2016-11-14 12:05)

You should draw the map like it is described in this thread:
https://www.lexaloffle.com/bbs/?tid=2348

P#32469 2016-11-14 13:37 ( Edited 2016-11-15 13:21)
:: deKay

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"):

Cart #32491 | 2016-11-15 | Code ▽ | Embed ▽ | No License

P#32492 2016-11-15 05:23 ( Edited 2016-11-15 10:24)

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.

P#32493 2016-11-15 05:31 ( Edited 2016-11-15 10:31)
:: deKay

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.

Cart #32494 | 2016-11-15 | Code ▽ | Embed ▽ | No License

P#32495 2016-11-15 06:05 ( Edited 2016-11-15 11:05)

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)
P#32496 2016-11-15 06:28 ( Edited 2016-11-15 11:46)
:: deKay

I had them flr()'d but took it out to see if it'd help. It didn't. I'll try your suggestion though.

P#32497 2016-11-15 06:44 ( Edited 2016-11-15 11:44)
:: deKay

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!

P#32498 2016-11-15 07:43 ( Edited 2016-11-15 12:43)

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.

https://www.lexaloffle.com/bbs/?tid=2119

P#32499 2016-11-15 08:09 ( Edited 2016-11-15 13:23)
:: deKay

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.

Cart #32500 | 2016-11-15 | Code ▽ | Embed ▽ | No License

P#32501 2016-11-15 09:26 ( Edited 2016-11-15 14:26)
:: deKay

Haha! Collision detection is not going well. Still trying though :)

P#32502 2016-11-15 11:16 ( Edited 2016-11-15 16:16)
:: deKay

Fresh eyes this morning, and I've managed this.

Cart #32547 | 2016-11-16 | Code ▽ | Embed ▽ | No License

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.

P#32548 2016-11-16 05:03 ( Edited 2016-11-16 10:03)
:: deKay

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.

Cart #32606 | 2016-11-18 | Code ▽ | Embed ▽ | No License

P#32605 2016-11-18 11:11 ( Edited 2016-11-18 16:15)
:: deKay

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!

Cart #32732 | 2016-11-24 | Code ▽ | Embed ▽ | No License

P#32733 2016-11-24 11:46 ( Edited 2016-11-24 16:46)
:: deKay

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!

Cart #33205 | 2016-12-08 | Code ▽ | Embed ▽ | No License

P#33206 2016-12-08 11:00 ( Edited 2016-12-08 16:00)
:: deKay

I have working warps! Wooooooo!

Cart #33444 | 2016-12-13 | Code ▽ | Embed ▽ | No License

P#33445 2016-12-13 11:02 ( Edited 2016-12-13 16:02)

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2019-12-12 06:31 | 0.048s | 4194k | Q:129