Page 1 of 1

Anyone have programs containing best practices?

Posted: Tue Mar 17, 2020 10:50 pm
by NeverCameBack
I realize there are probably way better ways to do things than I'm currently doing.
My platformer physics engine isn't working right.
I'm stuck on trying to make a multi screen game - I'm using a variable called "CurrentScreen", starts at 0, when A is pressed, turns to 1, 2.. etc. When "CurrentScreen" is compared to 0, 1, 2, etc., It should run the code to only display that screen #. For some reason parts of the old screen are blending into the first.

Are there any good sample .asm files that you know of, or would be willing to share? I figure maybe I can learn some better techniques from looking through a working project.

Re: Anyone have programs containing best practices?

Posted: Sun Mar 22, 2020 2:17 am
by Pokun
Exactly how is it a mutli-screen game? If parts of the old screen blends in it sounds like you either didn't draw the new screen properly or you are accidentally doing some kind of split-screen effect.

If every level/room is one screen and you don't need to scroll, the scroll X and Y registers ($2005) should always be 0. When you switch screen you just turn off rendering and draw the new screen on the same nametable. You might want to clear the nametable first (by filling it with empty tiles, like the SPACE character) if you don't draw on empty tiles.

You can also alternate between the two nametables (or 4 nametables if you use 4-screen mirroring). In that case you need to change both a scroll register and the active nametable number ($2000). This way you can switch a screen instantly without having to turn off rendering. As long as the second screen is already drawn.

If you want smooth scrolling between the screens like in Zelda you need to learn how to scroll properly. Nerdy Nights covers that. There is an example ROM included.

Re: Anyone have programs containing best practices?

Posted: Tue Mar 24, 2020 10:02 pm
by NeverCameBack
It'll be a multiscreen game in the sense that selecting A will take you to one pathway of screens, B will be a different.. And just text and hopefully some music. Thanks for the advice. I'm currently trying to get my head around the music section of Nerdy Nights - my scrolling could use some work too, but as of now I don't think I'll be making a plat-former right away.

By best practices, I was hoping maybe someone had more "nerdy nights" type .asm files.
Maybe one showing some sprite jump physics.
Another showing enemy generation on the screen.
Like the common things these NES games have done over and over. I was wondering if someone had broken each one down into how to professionals generally accomplished these. Maybe no sample files of the sort exist, but thought to ask.

Re: Anyone have programs containing best practices?

Posted: Sat Mar 28, 2020 12:20 pm
by Pokun
Oh I see. You just mean there are multiple scrollable areas, AKA "screens". Now it makes sense.
That Nerdy Nights sound tutorial teaches a lot of things which takes time to melt but it is a very useful tutorial. I wish there were more of this kind of stuff.

There are not a lot of examples out there unfortunately. Making them takes a lot of free time after all. You could look at disassemblies of commercial games or look at the source code of released homebrew like the Lizard demo.

Making things on the NES is not that far away from making games on any other platform in theory, so you could learn how to make things from other sources as well. Then you just have to figure out how to do it in 6502. Once you understand a principle and are comfortable enough with 6502 that isn't as hard as one might think. First you must know what to look for.

Making a platform game with simple physics like Donkey Kong or Castlevania is quite easy, and you can probably already do that. Those games have fixed movement speed, fixed jump height and fixed jump arcs, so the main problem is making collision.
If you want to make a game like Super Mario Bros that has acceleration-based movement, variable height jumping and mid-air controllable jumps, you need to know some basic physics (dynamics) and fixed point math (which is actually very easy). There are probably tutorials to make such platform games for other platforms so it shouldn't be that hard to learn.

I've been experimenting with action game basics including acceleration-based movement, variable height jumping, mid-air controllable jumps and collision in a demo downloadable from here. The collisions are still not perfect but I think the movement and jumping physics works quite well. Unfortunately I'm not sure where I put the source code to this demo, but if you are struggling with the same things you can probably get some hints from that thread. This article is also a recommended read and it fully applies to NES.

Re: Anyone have programs containing best practices?

Posted: Sat Mar 28, 2020 12:37 pm
by NeverCameBack
Hey thanks a lot for those links - I will be sure to check out your jump physics engine, and also the Lizard demo. That is basically what I was wondering here, so my question is answered. The techniques in NerdyNights is what I've been learning from so far. It is encouraging and exciting to know that game development principals aren't so different between platforms. I'm hoping to get a solid foundation by making a playable NES game. I am not a coder by trade or even by hobby, so assembly is for the most part the first language I'm learning, aside from some industrial automation stuff.