Jump to content
IGNORED

Plaform game engine


NRV
 Share

Recommended Posts

Hi, this a platform game engine that I did mostly in 2010. Recently I added the enemy logic, the laser barriers animation and some other details.
I hope people can find it useful to look at the code, or maybe use it as the basis for a game.

What I implemented is a system a little more complex than what you normally see in the A8. Most movements have a different speed and acceleration defined, and some of these values use fixed point math. For example you can define the speed for walking, jumping, falling, swimming, climbing, and the accelerations used to reach those values. Also you can hold the jump input for higher jumps and use some air control.
Right now you shoot with the button and jump moving the joystick up. I don't like this much, but I wanted to test having both options for this prototype.
I normally play in a pc using the keyboard, so maybe the values are a little too sensitive for a real joystick.

There is a PAL version, but is a little different than the NTSC one. I did translate the speed and acceleration values, but it seems applying them 50 times per second has not the same accumulated effect, that at 60 fps (it feels more "floaty"). Also, there is a precision problem trying to translate the smaller values (should use more bytes).

Here, a video:



The engine is pretty efficient, most of the time in the frame is free as you can see here:

post-11240-0-03247800-1503898642_thumb.png

For example, the enemy logic only updates one enemy per frame, looking if the player is near and then shooting in the correct direction (if the cooldown and the number of enemy missiles allows it).

Other details:
- Most collisions tests are char based and assume a player with the current size, but they can be changed for bigger players. Only the collision between the player (P0) and any danger, use the hardware registers.
- The player logic use a system of states to know how to move and what collisions to check (over platform, jumping, falling, climbing and in water). The color of the player changes according to the state and also to what he hits, but this was for debugging.
- The camera speed is based on the distance to the player, so is smoothed out a little.
- Most objects coordinates in the level use 2 bytes and are translated to screen coordinates before rendering. With a moving camera you need to update your player/missile graphics, not only when they move, but also when the camera does it.

The level was done in Envision PC (the "reborn" version) and is easy to modify, but there is not much error checking, so beware. Code was done in mads and tested in Altirra, as always.

The condition to "win" this demo is collecting all coins and destroying all enemies (the clock stops then). My record for this is 1:16.1 in NTSC, but I died once :)

open_plat.zip

  • Like 30
Link to comment
Share on other sites

Looks and plays totally cool. As heaven said, the physics are really great. Keep the Player's look, name it "Super Mario Blocks" and release it :-)

 

Do you know MADS' ".PROC/ENDP" statement? It allows for very nicely defined local labels, so you don't need the prefixes:

 

.proc CheckCreateEnemyMissile

; check for a free missile index
ldx #2
lda TabMissileOwner,x
beq found_one_free

ldx #3
lda TabMissileOwner,x
bne exit

found_one_free
lda #>[ENEMY_MISSILE_SPEED_X]
sta TabMissileSpeedX_H1,x
lda #<[ENEMY_MISSILE_SPEED_X]
sta TabMissileSpeedX_L1,x

lda m_enemyShootDirection

 

exit
rts
.endp

 

Still you can jump into where you need with "CheckCreateEnemyMissile.found_one_free"

  • Like 2
Link to comment
Share on other sites

It makes me think also in Adventure 3.. if Adventure were a platform game :)

 

 

Looks and plays totally cool. As heaven said, the physics are really great. Keep the Player's look, name it "Super Mario Blocks" and release it :-)

 

Do you know MADS' ".PROC/ENDP" statement? It allows for very nicely defined local labels, so you don't need the prefixes:

 

.proc CheckCreateEnemyMissile

; check for a free missile index
...
rts
.endp

 

Still you can jump into where you need with "CheckCreateEnemyMissile.found_one_free"

 

Yes! .. in fact I learned it from you, when looking at your example code to create a 1MB cartridge, directly from a mads source.

I used .proc a lot when moving the projectM presentation to use a cartridge, but this one here is very old code.

Another thing very useful when using .proc, was the option to set a specific assembly address, for when you need to move your code from the cartridge to normal ram.

 

 

  • Like 2
Link to comment
Share on other sites

Nice, reminds me a little of WTBOY

 

Nice.

The "infinite" jump is in the code, but commented, the "wall grab/slide" should be easy to do, and something like the big wheels could be done easily by animating chars in the font (but maybe using 2, 3 or 4 fonts interleaved in the screen).

 

I believe one of my inspirations at that point of time, was something like star guard:

 

 

Also doing something with a fraction of the options in n++ (and a little less hardcore), would be nice.. kind of a modern lode runner.

 

  • Like 9
Link to comment
Share on other sites

  • 3 months later...
  • 3 months later...

Hi,

 

I am just getting back into 6502 programming after about 35 years so any help would be appreciated. Here is what I am doing with the open plat engine. I have create a sprite using player 1,2,3 for color. It's dimensions are 8 x 21. I updated the draw player routine to support drawing the sprite. For all the area's of the code I could recognize I updated any values to match the sprite and made some of them constants. I am using the same screen dimensions as the sample but have provided my own character set.

 

The first thing I see is when the character walks off the right side of a platform he goes out a full character width before he begins his fall. Also when I move him all the way to the right he goes past the window right limits after the tiles have scrolled. Can someone shed some light on if I have missed a setting or something.

Link to comment
Share on other sites

Hi,

 

I am just getting back into 6502 programming after about 35 years so any help would be appreciated. Here is what I am doing with the open plat engine. I have create a sprite using player 1,2,3 for color. It's dimensions are 8 x 21. I updated the draw player routine to support drawing the sprite. For all the area's of the code I could recognize I updated any values to match the sprite and made some of them constants. I am using the same screen dimensions as the sample but have provided my own character set.

 

The first thing I see is when the character walks off the right side of a platform he goes out a full character width before he begins his fall. Also when I move him all the way to the right he goes past the window right limits after the tiles have scrolled. Can someone shed some light on if I have missed a setting or something.

The PM's are only the graphical representation of your player, internally the code assumes (is hard coded right now, if I remember correctly) that you are moving an object of 4x8 pixels (1 char).

So you would need to update the size of the internal "collision" object through the code..

 

I would need to take a look for possible unknown problems, but at least change this code, in pro_P1.asm:

 

; set size in pixels

ldx #4

stx m_playerSizeX

dex

stx m_playerSizeXMinusOne

ldx #8

stx m_playerSizeY

dex

stx m_playerSizeYMinusOne

 

jsr InitPlayerInfo

...

 

Is not that simple anyway, because with a sprite so big you need to add more collision checks, to avoid going through small objects (the collision checks right now are done only in the corners of the player).

You would understand if you try it :)

The other solution is that your level doesn't use walls or platforms that are smaller than the player.

 

Regards.

Link to comment
Share on other sites

Hi,

 

Thanks for the explanation of your code base. It is very helpful.

 

I did create a PLR_WIDTH and PLR_HEIGHT set of constants and applied them in the area you outlined along with any other places in the code where they would be considered. I will look into adding more collisions points maybe 3 for top and bottom and 4 for left and right and see if that yields the desired results.

 

Regards

Link to comment
Share on other sites

  • 2 weeks later...

Hi NVR,

 

I would like to ask your permission to use your code base as part of a set of videos I am looking to put together on Game Programming on the Atari. This set of videos has two purposes, first to help me further my understanding of the code and concepts and two to hopefully invite people to join with comments and suggestions which should help others and me further our understanding.

 

Thanks again for the great engine.

  • Like 1
Link to comment
Share on other sites

Hi NVR,

 

I would like to ask your permission to use your code base as part of a set of videos I am looking to put together on Game Programming on the Atari. This set of videos has two purposes, first to help me further my understanding of the code and concepts and two to hopefully invite people to join with comments and suggestions which should help others and me further our understanding.

 

Thanks again for the great engine.

Sure, go ahead.

 

It's here to be used :)

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Hi All

 

Here is a link to the git repository of my updates to NRV's Open_Plat engine. It's is in the early stages but it does load as a XEX and does run in Altirra. My latest attemp has been to create moving platforms in the game and I do have a platform moving. The animation is very coarse so I was hoping that someone can take a look as offer some suggestions.

 

Also there is a bare bones implementation for sound using RMT. I need to find some better effects and music but that also seems impossible. I have looked and tried to convert SAP to RMT with no luck using ASAPCONV. If anyone knows how to do this with SAP or WAV files that would be a big help.

 

Lastly, I have tried different ways to implement a VBI routine again with no luck. Any help there would also be appreciated.

 

 

Here is the link to the repository.

 

https://github.com/TattooRose/Scroller.git

 

Thanks in advance

  • Like 3
Link to comment
Share on other sites

I need to find some better effects and music but that also seems impossible. I have looked and tried to convert SAP to RMT with no luck using ASAPCONV. If anyone knows how to do this with SAP or WAV files that would be a big help.

 

Lastly, I have tried different ways to implement a VBI routine again with no luck. Any help there would also be appreciated.

 

ASAPCONV should work fine for that, but of course only if the original file was RMT and not CMC, TMC or ...

Can you be more precise about what/where you are trying to use/setup the VBI and what is not working?

Link to comment
Share on other sites

I haven't looked at your changes, but in my original version I change the NMI handler to point to the only DLI, and the VBI is not enabled.

You can put your code inside that DLI if your only interest is doing some changes once per frame (like calling RMT's update).

Is there a xex with your changes in there?

 

I don't think you want to play digital sound, so forget about wav's for now.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...