Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
NGPC Platformer Engine - Work in Progress
#1
I have been experimenting with the NGPC C framework, and I am developing a platformer engine with it.  I'll try to document progress and concepts/methodology here.

   

Tiles and sprite are some that I drew up pretty quickly to test functionality, and are not necessarily representative of what I will end up with in a "final" game.  

So far the engine supports a main sprite of 3x3 tiles that is fixed in the center while the level tiles are put into one of the scroll planes.  The scroll plane is then moved left or right, and the next tiles needed are drawn on demand just off-screen, so they seamlessly scroll in when the player moves.

On that note, the scroll plane coordinate manipulation is not obviously integrated into the C framework, at least not as obvious functions.   These variables are defined in ngpc.h and can be set as needed to alter scroll plane coordinates:
SCR1_X
SCR1_Y
SCR2_X
SCR2_Y

These are 8 bit numbers, so only 0-255 are supported, and the plane will loop back onto the screen as the limits are crossed.  Because the coordinates are limited until they loop back, the max width (and I assume the same for height, but did not test) is 32 tiles (256 pixels).  The screen shows 20 tiles (or rather 120 pixels - with a potential for partial tiles on the edges), so there is space to work with on the plane outside of the visible screen.

Without streaming in tiles on demand, you'd be stuck with a level that is limited to 32 tiles wide.

I have done several experiments, and the NGPC is actually pretty capable of quickly redrawing the entire visible screen (i.e. erase and redraw tiles every loop), but I was noticing some flickering in some cases on real hardware when doing so.  It's more efficient, and eliminates flickering, to just draw the next set of tiles just off screen and let them scroll in.  For example, if you're moving right, before the next column of tiles scrolls onto the screen, they get drawn.  This operation only has to draw a column of 19 tiles at a time, instead of redrawing the entire visible screen (20x19=380 total tiles).

I am basically infinitely looping the coordinates of the scroll plane, tracking them, and figuring out the coordinates of the next column (according to the direction the player is moving), read them in the from the level map, and draw them.

At any rate, using tiles on demand is a way to increase the amount of space you can use.  I currently have a level array defined that is 19 rows high by 100 columns wide.  Each position in the array represents a tile.  The value of each tile that needs to be drawn is stored, and 0 is a blank tile that erases the space if it is occupied.  You would be limited by the amount of storage space, but the width of a level used this way does not have to have a fixed limit.

Note, that I think you could reasonably create a Zelda-type game that utilizes the limits of the scroll plane without managing on demand tiles, where each "room" would be made to fit inside the 32x32 tile space, but you would have to design it with that limit in mind.

Next steps, in no particular order are:
-layered character sprite for more than 3 colors
-character sprite animation
-collision mapping and detection
-character jumping

Once those are in place, I'll proceed with enemies and items.

Time will tell if anything comes of this, but I am enjoying working with the NGPC so far.
Reply
#2
great
btw, here is a link to the sources of SQRXZ (platformer) I never finished to code...
https://drive.google.com/open?id=1fZfz22...vP_wClvmC0
Reply
#3
(05-07-2020, 03:26 AM)sodthor Wrote: great
btw, here is a link to the sources of SQRXZ (platformer) I never finished to code...
https://drive.google.com/open?id=1fZfz22...vP_wClvmC0

Thank you for sharing!  I had actually been reviewing the demo that's in your thread to get some inspiration.
Reply
#4
(05-07-2020, 03:26 AM)sodthor Wrote: great
btw, here is a link to the sources of SQRXZ (platformer) I never finished to code...
https://drive.google.com/open?id=1fZfz22...vP_wClvmC0

I'm able to get this to compile without error, but the levels are not drawn correctly.  I think something with memset isn't working on my side even though C900ML.LIB is present. I can comment those out and get the same behavior.
   
Reply
#5
Here's a demo of my progress so far.


Attached Files
.zip   PLATFORMER.zip (Size: 12.38 KB / Downloads: 4)
Reply
#6
yep, sorry. I've found an older version which compile & run: https://drive.google.com/open?id=1VyoTDJ...htYyun0DZ4

I was working on win32/ngpc version and maybe I didn't test it enough on ngp...
Reply
#7
(05-11-2020, 02:48 AM)sodthor Wrote: yep, sorry. I've found an older version which compile & run: https://drive.google.com/open?id=1VyoTDJ...htYyun0DZ4

I was working on win32/ngpc version and maybe I didn't test it enough on ngp...

That one works for me.  Thanks!
Reply
#8
Ok, I've found the problem on the last version.
I updated the file on drive: https://drive.google.com/open?id=1fZfz22...vP_wClvmC0
It includes the VisualStudio 2017 project so you can debug the code (and the z80/sound driver part as well).
Reply
#9
(05-12-2020, 03:55 AM)sodthor Wrote: Ok, I've found the problem on the last version.
I updated the file on drive: https://drive.google.com/open?id=1fZfz22...vP_wClvmC0
It includes the VisualStudio 2017 project so you can debug the code (and the z80/sound driver part as well).

This one is working for me.  Thanks!

Man, just reviewing your code is very educational.  You handle a lot stuff like tile/sprite/palette assignments directly, without relying on the functions in the c library, which is probably way more efficient, but much more difficult to read and understand for a novice!  Big Grin
Reply
#10
I have made some progress on my platformer engine and have been learning a lot, mostly through trial and error.

Some discoveries that are worth noting:
-populating tiles/tile groups can be done very quickly.  I discovered that animations for a sprite are easier for me to manage by populating the associated tiles with updated images when I need a new frame.  In this way I don't have to take up a ton of tiles storing all possible frames of animation.
-anything that is assigned to a given tile (sprite or scroll plane) will update as soon as the tile is updated.  In this way it is possible to have animated tiles within a level.  For example, I have some blowing grass tiles, and I can place however many of these tiles on a level, and all of them animate with a quick update to the single respective tile/tileset.
-I have changed my approach for sprite chain flipping.  I have found it is easier to reassign tiles for each sprite in the chain than it is to reorganize all chained tiles according to the flip.  I am still taking advantage of the built in sprite flipping functionality, so only one direction of each sprite frame is needed.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)