gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > Top view scrolling game?

#132893 - calcprogrammer1 - Sun Jul 01, 2007 5:46 am

I'm trying to make a simple game, a top-down scrolling game for the DS. Think NES Legend of Zelda. I'm using PAlib for now (just learning), and all their demos are too complex...they waste time with fixed point math when trying to explain a simple game...can't they just introduce fixed point AFTER they teach you the basics of the game engine, rather than confuse you totally? I've never heard of fixed point before, just integers, floats, doubles, and strings (the computer C++ types). I managed to make a sprite and get it to move up/down/left/right but I don't get the background stuff (how to create one, what size to make it, how tiling works) or how to scroll it, and how to keep the player on the screen while scrolling.

I'd also like to know how to use scrolling on platform games (again, couldn't understand what the PAlib example was trying to do because all the >> << ?? was getting in the way). Are there any good tutorials for scrolling?
_________________
DS Firmware 1, Datel Games n' Music card / Chism's FW hacked GBA MP v2 CF

There's no place like 127.0.0.1.

#132900 - Azenris - Sun Jul 01, 2007 11:48 am

I don't know any good tutorial links, but i'm having alook. Ill post if I come up with anything.

Just wanted to say you should attempt to learn the fixed point math, its not as complex as it seems at first, maybe there are some dedicated tutorials on it.

Anyway as I said, ill try find some links.
_________________
My Homebrew Games

#132905 - Kyoufu Kawa - Sun Jul 01, 2007 3:27 pm

Heh. Fixed point math looks complex at first, I'm still trying to "get" it. PALib however, fails for wasting time on that.

Fixed point numbers are integers, but used in a special way. The whole << and >> shit is integral to this. It shifts the bit patterns of a given value left or right a certain amount. This is effectively multiplication and division done weefast.

The GBA, as you might have read, does not do floating point math very well. This means you can't have a value of, say... 3.14. Just 3. If you multiply a value by 256 (or rather, shift left 8 bits), you get a lot of extra space to simulate the part after the dot. When you're done, you might sacrifice these decimal places by dividing by 256 or shifting right 8 bits.

This is ofcourse, irrelevant because PALib fails for the earlier mentioned reasons.

I myself am, together with Cearn, writing a game just like you described but without Zelda. Character animation is a joke if you can find a proper tutorial. Might I suggest this GPWiki tute for starters? Ignore the whole class thing, it's supposedly language-agnostic. I'd use a struct myself.

#132909 - keldon - Sun Jul 01, 2007 4:08 pm

Here's an easy way to think of fixed point maths ... multiply 20.00 with 10.00, and what do you get? Now imagine that you had to write that without the decimal points and you'll end up with 2000 * 1000 = 2000000; now add the points back in the same places (two decimals from the right) and you get 20.00 * 10.00 = 20000.00, and you know that isn't right.

What you need to do is shift the number right by two decimals, so 20.00 * 10.00 = 20000.00 >> 2 = 200.00

So then you have the question of how many shifts to use. Well first of all let's call the amount of numbers past the decimal point detail. 10.00 and 20.00 both have two detail decimals, so when you multiply them the new number will have 4 decimals of detail (2*2). But you (for some unknown reason) want only 2 decimals of detail, so you shift right by 2 decimals.

#132918 - Kyoufu Kawa - Sun Jul 01, 2007 6:29 pm

It's not the fixed point part that matters, Keldon. It's the whole getting a character to move around.

#132921 - keldon - Sun Jul 01, 2007 7:08 pm

Kyoufu Kawa wrote:
It's not the fixed point part that matters, Keldon. It's the whole getting a character to move around.

Fair enough, but it was the fixed point maths getting in the way so it made sense to squash that problem. I personally didn't know the term fixed point when I first started using it, I just figured that I needed more precision with integers so I naturally shifted and figured out the calculation rules with it ^_^

Here is an explanation of large map scrolling.

#132945 - calcprogrammer1 - Sun Jul 01, 2007 11:43 pm

Will these map editors for the GBA work with PAlib and the NDS?

I've read up on fixed point, and I sorta get how it works, it's just hard to read the code and figure out the basics of what the game's doing when trying to figure out what the fixed point stuff is for.
_________________
DS Firmware 1, Datel Games n' Music card / Chism's FW hacked GBA MP v2 CF

There's no place like 127.0.0.1.

#133011 - Kyoufu Kawa - Mon Jul 02, 2007 5:22 pm

calcprogrammer1 wrote:
Will these map editors for the GBA work with PAlib and the NDS?
Yes on the NDS part. PALib I don't know for I never used it.

Seriously, I think they're pretty much compatible.

#133023 - gauauu - Mon Jul 02, 2007 7:40 pm

Kyoufu Kawa wrote:

I myself am, together with Cearn, writing a game just like you described but without Zelda.


Aren't we all....

calcprogrammer1 wrote:
I managed to make a sprite and get it to move up/down/left/right but I don't get the background stuff (how to create one, what size to make it, how tiling works) or how to scroll it, and how to keep the player on the screen while scrolling.


The easiest way is to do it in steps...Using those tutorials that people pointed you to, first make a simple background that scrolls around with the directional pad (Without putting a character in it).

Then add a characters sprite, who always stays centered in the middle of the screen. Hey look, it looks like he's walking around, and you've succeeded in "keeping the player on the screen while scrolling".

Then you get into that jump of difficulty where you have the difference between world and screen coordinates. You move the player, and the character's world coordinates should change. Maybe his screen coordinates should change, maybe not. Maybe the screen coordinated should change, maybe not.

#133025 - keldon - Mon Jul 02, 2007 7:45 pm

One thing that I would say is that you might be able to find tutorials on animation at http://devrs.com/gb , they will be written for the DMB but the same principles apply. You may need to use the web archive to view the sites - of course this is all assuming that there aren't any docs on it directly for the GBA.