Page 1 of 2

My First Attempt At A Platformer Engine

Posted: Fri Dec 20, 2013 7:20 pm
by Light-Dark
Hello, this is my first attempt at a platformer engine for the NES. I used the sound engine from the Nerdy Nights tutorials. The source is included along with a ROM, please feel free to mention anything I may be doing wrong or poorly :)
NES Platformer.zip

Re: My First Attempt At A Platformer Engine

Posted: Fri Dec 20, 2013 8:48 pm
by blargg

Code: Select all

DEX
CPX #$00
BNE ReadController1Loop
The CPX is redundant here.

Also, you sould be able to use lowercase for instructions. Less activity on the shift key.

Re: My First Attempt At A Platformer Engine

Posted: Sat Dec 21, 2013 6:32 am
by tepples
It was hard to get past the first room until I realized I could go left then right to skip the room with the pit under the low ceiling.

Are you intending for jumping to use jetpack-style physics or actual jumping?

Re: My First Attempt At A Platformer Engine

Posted: Sat Dec 21, 2013 10:33 am
by Light-Dark
tepples wrote:It was hard to get past the first room until I realized I could go left then right to skip the room with the pit under the low ceiling.
You could also fall down the pit and end up at the top of the screen as well :P. I intend on implementing some sort of Room coordinate system ala-Battlekid. My idea is that depending on what side of the screen you exit on it will increment or decrement the room x,y values and then calculate the room index using index = room_x + (room_y*Max_x).
tepples wrote: Are you intending for jumping to use jetpack-style physics or actual jumping?
At some point actual jumping will be implemented, it's jetpack-style for now.

Re: My First Attempt At A Platformer Engine

Posted: Sat Dec 21, 2013 3:58 pm
by rainwarrior
I'm noting a short grey glitch mid-screen when dying. Are you trying to set the palette while rendering is off? (It should only be written during vblank to avoid this.)

Re: My First Attempt At A Platformer Engine

Posted: Sat Dec 21, 2013 6:58 pm
by Light-Dark
rainwarrior wrote:I'm noting a short grey glitch mid-screen when dying. Are you trying to set the palette while rendering is off? (It should only be written during vblank to avoid this.)
Thanks! the palette is now set during VBlank.

Re: My First Attempt At A Platformer Engine

Posted: Sun Aug 10, 2014 10:29 pm
by Light-Dark
Okay so over the past 6 months or so I've completely rewritten this engine from the ground up.
Main.nes
Updated ROM
(128.02 KiB) Downloaded 313 times
Some new features to the new and improved engine are:
- AI
- Status Bar
- Better jumping physics
- Better background collision detection and resolution
- Different background collision properties ( An example of this is in the water area of the demo wher the water makes you fall slower and some of it moves you to the right as if there is a current).

If anyone wants to pop open an emulator hex editor mess around with things like background collision and AI during run time here are some memory locations and info:

$0700-$071A = AI Memory
Each AI is 9 bytes in size: y,x,sprattributes,sprite#,Health,xVel,yVel,Action,Frame
The action byte, for those who are wondering, basically controls which action "script" is jumped too in the global AI action jump table.
(0 = do nothing, 1 = move left and right, 2 = move up and down, 3 = move in a Zig zag wave, 4 = move in a sine wave)
$0600-$06FF = Background Collision table
Setting bit 7 makes a tile solid, setting bit 0 makes the tile water-like (more resistance to movement than air), bit 1 makes the tile move the player to the right, bit 2 to the left.

When you load the ROM the screen will start black, just press start to begin ( it's in the "menu" state and I haven't really implemented a basic menu/title screen yet). Controls are pretty much like any other platformer on the NES d-pad to move left and right and a to jump. Pressing start and select currently modify the action byte of one of the AI's because I was doing some tests. Lastly when you go to the screens right of the starting area, which ultimately go nowhere, you'll notice the graphics are all messed up. That is intentional and not a glitch as I was testing to see if my tileset swapping between different screens functions correctly.

So yeah enjoy I guess!

Re: My First Attempt At A Platformer Engine

Posted: Sun Aug 10, 2014 10:54 pm
by Kasumi
Hmm... I dunno, are you looking for feedback?

I'd like to know what kind jump physics you're going for. Currently it seems you're after a jetpack type movement, because it's reversed from a typical jump.

Edit: HAH! I read the rest of the topic. Jetpack style it is. Still, I might slow it down a tad for a more jetpack feel. Possibly take a look at the Yoshi's Island flutter mechanics. I've also managed to kind of hover by mashing A, which supports that the player has a jetpack, but it's very difficult to do this, if this is meant to be a mechanic and not a glitch.

If you hold A button while pressing start, you can just kinda chill in the air.
Edit: Oh, I maybe found out why. $0434 seems to be in charge of how much time is left to hover. At reset it decrements from 0 and wraps through $FF. So you can't float indefinitely as I first thought. Just for a very long time.

Similarly, holding left against walls while a new screen loads allows you to jump off walls. (Jump off the pit in the start while holding left+A. The screen you should fall on allows you to go back up to the first screen, but then you fall to the second screen etc.) Holding down while landing allows you to hover a pixel off the ground. I assume you've begun a crouching state that causes this, since it also prevents you from jumping.

Not bad progress, though.

Re: My First Attempt At A Platformer Engine

Posted: Sun Aug 10, 2014 11:31 pm
by Light-Dark
Thank you for the feedback! Yeah I've kind of moved away from the jetpack style as I have learned more about 6502 programming over the months. I fixed the bug where you can jump off walls and woops I accidentally left some old code in my d-pad down routine (it isn't supposed to do anything) :oops:. I haven't been able to replicate the floating via holding start and A yet.

Re: My First Attempt At A Platformer Engine

Posted: Sun Aug 10, 2014 11:35 pm
by Kasumi
Being more specific, I mean start the rom. (black screen, game is in menu mode.) Hold A. Don't let go. Press start.

Not holding A+start after the game has begun.

Re: My First Attempt At A Platformer Engine

Posted: Sun Aug 10, 2014 11:43 pm
by Light-Dark
Kasumi wrote:Being more specific, I mean start the rom. (black screen, game is in menu mode.) Hold A. Don't let go. Press start.

Not holding A+start after the game has begun.
Weird. I'm doing just that in FCEUX,Jnes and Nestopia and everything is functioning as intended; no hovering. Just to be on the safe side though I'll make sure when the game changes state that it clears the controller input byte and resets all the jumping related bytes.

Re: My First Attempt At A Platformer Engine

Posted: Sun Aug 10, 2014 11:59 pm
by Kasumi
Just so you know I'm not crazy: http://i.imgur.com/3kbQ2pA.gif

Re: My First Attempt At A Platformer Engine

Posted: Mon Aug 11, 2014 12:16 am
by Light-Dark
Kasumi wrote:Just so you know I'm not crazy: http://i.imgur.com/3kbQ2pA.gif

Hmmmm, I notice your emulator is in PAL mode ( you're not supposed to see the sprites in the upper left). Have you tried setting it to NTSC? Here try this:
Main.nes
(128.02 KiB) Downloaded 273 times

Re: My First Attempt At A Platformer Engine

Posted: Mon Aug 11, 2014 5:32 am
by tokumaru
Light-Dark wrote:I notice your emulator is in PAL mode
"PAL mode" is a setting that affects timing, not resolution. Both PAL and NTSC consoles generate 240 lines of picture, emulators that crop scanlines in NTSC mode are just (poorly) attempting to simulate the clipping that commonly happens in NTSC TVs, but the amount of picture that's cut varies from TV to TV and you shouldn't rely on that happening. Also, all emulators I know of that crop scanlines allow you to configure how much is cropped.
( you're not supposed to see the sprites in the upper left)
There should be no sprites in the upper left! =) The correct place to hide unused sprites is after scanline 239, past the end of the picture. A Y coordinate of anything between 239 and 255 will completely hide a sprite. The X coordinate doesn't matter.

Re: My First Attempt At A Platformer Engine

Posted: Mon Aug 11, 2014 7:51 am
by Light-Dark
tokumaru wrote:
Light-Dark wrote:I notice your emulator is in PAL mode
"PAL mode" is a setting that affects timing, not resolution. Both PAL and NTSC consoles generate 240 lines of picture, emulators that crop scanlines in NTSC mode are just (poorly) attempting to simulate the clipping that commonly happens in NTSC TVs, but the amount of picture that's cut varies from TV to TV and you shouldn't rely on that happening. Also, all emulators I know of that crop scanlines allow you to configure how much is cropped.
Okay I see, my bad.
tokumaru wrote:
( you're not supposed to see the sprites in the upper left)
There should be no sprites in the upper left! =) The correct place to hide unused sprites is after scanline 239, past the end of the picture. A Y coordinate of anything between 239 and 255 will completely hide a sprite. The X coordinate doesn't matter.
Thank you! That issue has been fixed, sprites that aren't supposed to be displayed are no longer displayed.