News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_eto

Tutorial how to write a platformer or action game - on 8bit computers?

Started by eto, 23:24, 31 January 24

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

eto

So, I never developed a platformer type of game - but I was thinking about it many times. Is there a tutorial or Youtube video or maybe even a book from the 80s that discusses that, especially with the limitation sof 8 bit computers in mind? I found some stuff which is for modern PCs but that doesn't really help me as they usualy use a framework/library that solves a lot of issues.

The pure technical stuff like Sprites, sounds and so on is clear - not that I would already know it - but I know how to find the information. I am more thinking about the game logic and the interaction between the player and the scenery - or even better: how things in the game interact with each other.

e.g.

  • falling down ends on a platform, but from below I can jump through it
  • making jumps look natural (e.g. like Mario does, not linear like many
  • some things are e.g. lethal when I hit the first pixels, other things only will e.g. activate, when I entered a few pixels into a tile
  • how to orchestrate it, that everything can have impact on each other - e.g. in BruceLee where not only can I hit an enemy, the enemies also properly hit (and kill) each other
  • "intelligent" enemies - how to program that they hunt the player when they see him - or run away
  • events, where e.g. collecting a key opens a door.

When thinking about a game I constantly get to those points where I have no clue on how to do that - at least not in a reusable fashion.

I'm not sure if I will ever dive into that adventure - but I'd love to get a bit a better understanding how this could work on the CPC.

And if there is something out there that I could read or watch, that would be awesome.

andycadley

Often it's just a matter of breaking down the problem and going with the simplest solution. For example, the platforms you can jump through but not fall through - just a matter of only checking for a collision with them when falling. Realistic jumping - just apply some level of gravity to a character and use it to modify their vertical velocity (using fixed point arithmetic helps here).

Other things like interactions can always start off simple, everything just operates on very basic collision. Then as the game develops you can tweak the collision boundaries to get the kind of behaviour you'd like to make the game feel right.

AI can be reasonably trivial, plenty of 8 and 16 bit games just have enemies follow a rigid pattern. Even things that seem complex are often based on very simple rules - the Pacman ghosts are a classic example of this.

And whilst modern game development tutorials often use tools that do a lot for you, they're often full of useful tidbits on game design philosophy. All of which can still be relevant when writing games for older platforms. I'd recommend the Game Makers Toolkit videos on YouTube, as well as Displaced Gamers series of Behind The Code videos (which are mostly digging into NES games but still quite informative about how old school games work behind the scenes).

None of that can really compare to just giving it a go. Even a little bit of coding knowledge will get you a long way. Don't get over-ambitious for your first projects, just try some ideas out and figure what works for you best. Learning through doing is often the best way to find the patterns you prefer.

MoteroV4

Hi, yes, the Professor Retroman has several courses on YT about videogames programming in CPC, especially with the CPCTelera framework and under ASM.
https://www.youtube.com/@ProfesorRetroman/playlists

Although they are in Spanish, you can see a subtitled translation.

Also from CPCRetrodev you can download most of the source code of the whole games presented. All the games made by the students are made with SDCC Z80 Compiler.

As an ex. of simple platforms, I remember "Miss Input" (2019), with source code and commented.
http://cpcretrodev.byterealms.com/juegos/
Released cpc games: Memtrainer, El Gerente (Remake)

IndyUK

Hi

I think @andycadley is absolutely right in saying that you should break it down into smaller parts. When I did my test platformer in BASIC I simply wrote the various mechanics in BASIC just so I could get a handle on how they needed to work. I know that platformers can look quite simple but believe me when you start you'll soon realise how complex they can become, especially when you begin to add more functionality. One of the first things I looked at was the simple left/right movement and the platform collision. The TEST(x,y) command in BASIC was perfect for this but does slow the program down.

Here's the link to my page where I've attached the source code if you want to take a look. Word of warning, it's not very clean as I crammed in quite a bit and is slow as a snail but, I really enjoyed the process of learning.

https://www.cpcwiki.eu/forum/programming/my-2d-platformer-in-basic/msg212410/#msg212410

Good luck!

Anthony Flack

You do just have to break everything down, and down, and down. But then once you've got all the little pieces working it doesn't take long to build things up, and up, and up.

If an operation is kind of complex I find it sometimes helps to write down what I want to achieve in plain English first, step by step, in the compiler using ;comments. eg.

; find the difference in X between player and enemy
; find the difference in Y between player and enemy
; compare Xdif to Ydif to find which is larger
; X is larger - go to horizontal attack
; Y is larger - go to vertical attack

etc.

Then once I've described it, I go through and fill in the code underneath each comment, and as a bonus I end up with well-commented code which my debugging future self will thank me for.

Anthony Flack

Also, here is some basic information you should find helpful for platform games. And other games.

Create a list of game objects with a standard data structure, x and y value, frame, whatever other standard variables you need, laid out in a tidy little data structure you can step through. Each object also includes a 2 byte address stored in its data which is the address of its update function. Every update, you step through your object list and call all the update functions. Maybe you want a different one for player and enemies, it depends. You can have more than one list.

Use this to construct a state machine for your player and your enemies. The state machine runs different code depending on what "state" the character is in (eg jumping, walking, attacking, standing still). You only have to run the bit of logic that relates to the state that the object is currently in, and it can tell itself to jump to a different state whenever it needs to by over-writing the value of its update function.

To make a character jump smoothly, you need to store the y position of your character with 16 bit precision. So you'll have to use the 16 bit add function. But just take the high byte when it comes time to draw the sprite. The low byte is for sub-pixel precision. You'll also need a velocity value. This is added to your y position each frame. The constant force of gravity (make it as strong as you like) is added to your velocity value each frame.* The curve takes care of itself.

By using a state machine you can keep track of whether you're on the ground or in the air. When you're on the ground, your state code can check if you hit the jump button, and if you do, set your initial velocity and change your state to in the air. Don't run the gravity maths when you're on the ground.

When you're in the air, check for platforms overhead when your velocity is less than zero, and check underneath when your velocity is greater than zero. And DO run the gravity maths; add velocity to position, add gravity to velocity.

Most reliable way to do collisions with platforms is to hold the level data in a tilemap; you create a function that can turn a pixel co-ordinate into a co-ordinate on your tile map (likely using a lookup table) so you can retrieve the tile value and find out whether it's air or ground or spikes or whatever.

* Um I think that's right, if up direction = negative co-ordinate. Or reverse polarity if you find yourself falling upwards...

ervin


SRS

I'd say, use the MPAGD-Tool to make your first platformers, it'll teach you how to plan objects, enemies etc, and it will give you a nice assembler listing to learn how it works.
https://jonathan-cauldwell.itch.io/multi-platform-arcade-game-designer

There are lots of example games, and some tutorials how to use it on *tube.


After having created some games with it you should have a greater understanding about the mechanics behind platformers.

reidrac

You can also read the source code!

Some good games from the last few years have been released as open source. Some are in ASM, but some are written in C.
Released The Return of Traxtor, Golden Tail, Magica, The Dawn of Kernel, Kitsune`s Curse, Brick Rick and Hyperdrive for the CPC.

If you like my games and want to show some appreciation, you can always buy me a coffee.

Powered by SMFPacks Menu Editor Mod