Propeller - An Example SGDK-Based Game Engine
Moderator: BigEvilCorporation
-
- Very interested
- Posts: 710
- Joined: Sat Feb 18, 2012 2:44 am
Propeller - An Example SGDK-Based Game Engine
Introducing Propeller, an example game engine for the Sega Genesis written with Stef's SGDK.
https://www.dropbox.com/s/3vc5zc1mpjo97 ... 3.zip?dl=0
https://www.dropbox.com/s/pssd3p3h9fiq1 ... 2.zip?dl=0
https://www.dropbox.com/s/3uwdfa8gqz8iw ... 1.zip?dl=0
https://www.dropbox.com/s/gjtq9sxhyle1z ... 0.zip?dl=0
Some features:
- 8-way scrolling engine with "special tiles" the player can interact with like coins.
- object management system with per-object type collisions
- contains examples of effects, level structure, tile collisions, projectiles, enemy AI, player handling, animation, rotations and distance calculations
- python based tools to generate sin/cos and distance tables
The code is released as-is. It's free and you can do anything with it. It's meant to be used as a learning tool. I see questions about how to do things like scrolling, and I want to be able to give a concrete example instead of just talking about the theory.
As for the future, I don't foresee myself doing any major work on Propeller. I wish for people to take it and use it as a base to build new things.
I will, however, most definitely answer questions about how some parts work. The code isn't super clean or super clear in parts.
Propeller 1.0.0, Feb 13th, 2013
- Works with SGDK 0.92. Haven't tried the latest version yet.
Propeller 1.0.1, Feb 16th, 2013
- Fixed compilation issues with scrolling functions in SGDK 0.93b.
Propeller 1.0.2, Feb 16th, 2013
- Fixed corruption bug when scrolling.
Propeller 1.0.3 Nov 30th, 2014
- updated to SGDK 1.00
EDIT: Dec 16, 2017. Updated the links to the new Dropbox way of sharing.
DJCC
https://www.dropbox.com/s/3vc5zc1mpjo97 ... 3.zip?dl=0
https://www.dropbox.com/s/pssd3p3h9fiq1 ... 2.zip?dl=0
https://www.dropbox.com/s/3uwdfa8gqz8iw ... 1.zip?dl=0
https://www.dropbox.com/s/gjtq9sxhyle1z ... 0.zip?dl=0
Some features:
- 8-way scrolling engine with "special tiles" the player can interact with like coins.
- object management system with per-object type collisions
- contains examples of effects, level structure, tile collisions, projectiles, enemy AI, player handling, animation, rotations and distance calculations
- python based tools to generate sin/cos and distance tables
The code is released as-is. It's free and you can do anything with it. It's meant to be used as a learning tool. I see questions about how to do things like scrolling, and I want to be able to give a concrete example instead of just talking about the theory.
As for the future, I don't foresee myself doing any major work on Propeller. I wish for people to take it and use it as a base to build new things.
I will, however, most definitely answer questions about how some parts work. The code isn't super clean or super clear in parts.
Propeller 1.0.0, Feb 13th, 2013
- Works with SGDK 0.92. Haven't tried the latest version yet.
Propeller 1.0.1, Feb 16th, 2013
- Fixed compilation issues with scrolling functions in SGDK 0.93b.
Propeller 1.0.2, Feb 16th, 2013
- Fixed corruption bug when scrolling.
Propeller 1.0.3 Nov 30th, 2014
- updated to SGDK 1.00
EDIT: Dec 16, 2017. Updated the links to the new Dropbox way of sharing.
DJCC
Last edited by djcouchycouch on Sat Dec 16, 2017 2:10 pm, edited 8 times in total.
-
- Very interested
- Posts: 237
- Joined: Fri Apr 17, 2009 7:35 pm
- Location: USA
Nice work! This kind of thing is a boon to the community.
It's good to see this kind of thing come from all your own hard work and inquisitiveness. The questions you asked on this board, I also learned from. I think many people will learn from your code.
It's good to see this kind of thing come from all your own hard work and inquisitiveness. The questions you asked on this board, I also learned from. I think many people will learn from your code.
my album - last thursday died last week
-
- Very interested
- Posts: 710
- Joined: Sat Feb 18, 2012 2:44 am
-
- Very interested
- Posts: 710
- Joined: Sat Feb 18, 2012 2:44 am
Fixed compilation issues with scrolling functions in SGDK 0.93b.
https://dl.dropbox.com/u/17303735/Propeller.1.0.1.zip
https://dl.dropbox.com/u/17303735/Propeller.1.0.1.zip
There is one problem. Your engine badly works at iron. As it badly works and at the emulator Fusion 3.51 . After movement down game hangs. Please, correct errors.djcouchycouch wrote:Fixed compilation issues with scrolling functions in SGDK 0.93b.
https://dl.dropbox.com/u/17303735/Propeller.1.0.1.zip
-
- Very interested
- Posts: 710
- Joined: Sat Feb 18, 2012 2:44 am
I've reproduced it on hardware. Will take a look. Seems related to object handling.Mixail wrote:There is one problem. Your engine badly works at iron. As it badly works and at the emulator Fusion 3.51 . After movement down game hangs. Please, correct errors.djcouchycouch wrote:Fixed compilation issues with scrolling functions in SGDK 0.93b.
https://dl.dropbox.com/u/17303735/Propeller.1.0.1.zip
I will wait for corrections, I hope it will succeed.djcouchycouch wrote:I've reproduced it on hardware. Will take a look. Seems related to object handling.Mixail wrote:There is one problem. Your engine badly works at iron. As it badly works and at the emulator Fusion 3.51 . After movement down game hangs. Please, correct errors.djcouchycouch wrote:Fixed compilation issues with scrolling functions in SGDK 0.93b.
https://dl.dropbox.com/u/17303735/Propeller.1.0.1.zip
-
- Very interested
- Posts: 710
- Joined: Sat Feb 18, 2012 2:44 am
-
- Very interested
- Posts: 710
- Joined: Sat Feb 18, 2012 2:44 am
Found the issue. Version 1.0.2 here:
https://dl.dropbox.com/u/17303735/Propeller.1.0.2.zip
The problem:
The UpdateForeground() function in LevelManager.c, which sets up the rows and columns to be drawn by DMA, had a check to see if the plane actually scrolled before updating the background layer. It compared tilepositionX/Y with oldtilepositionX/Y. If there wasn't any scrolling, then the function would return and not do anything. But the DrawForeground() function that is called later in the frame, which does the DMA calls, would run no matter what. It would still do the DMA calls, with unset values, causing garbage data to stomp all over memory causing corrupted tiles. Fun stuff.
Goplanes never showed that problem, which is real strange. The garbage values it used must've stomped unused data. There was one time I ran on hardware where the whole screen blew up. That must've been a time where the garbage values weren't outside used data. It had only happened once.
I tried adding a quick fix to DrawForeground() of also checking to see if the screen actually scrolled before doing the DMA calls, but I'd get missing rows of tiles in Goplanes by flying at certain angles. Instead of investigating that, I just avoid the check all together in UpdateForeground() and compute everything every frame. Seems to have solved the problem.
https://dl.dropbox.com/u/17303735/Propeller.1.0.2.zip
The problem:
The UpdateForeground() function in LevelManager.c, which sets up the rows and columns to be drawn by DMA, had a check to see if the plane actually scrolled before updating the background layer. It compared tilepositionX/Y with oldtilepositionX/Y. If there wasn't any scrolling, then the function would return and not do anything. But the DrawForeground() function that is called later in the frame, which does the DMA calls, would run no matter what. It would still do the DMA calls, with unset values, causing garbage data to stomp all over memory causing corrupted tiles. Fun stuff.
Goplanes never showed that problem, which is real strange. The garbage values it used must've stomped unused data. There was one time I ran on hardware where the whole screen blew up. That must've been a time where the garbage values weren't outside used data. It had only happened once.
I tried adding a quick fix to DrawForeground() of also checking to see if the screen actually scrolled before doing the DMA calls, but I'd get missing rows of tiles in Goplanes by flying at certain angles. Instead of investigating that, I just avoid the check all together in UpdateForeground() and compute everything every frame. Seems to have solved the problem.
-
- Very interested
- Posts: 710
- Joined: Sat Feb 18, 2012 2:44 am
Hi,Mixail wrote:djcouchycouch, please, you can make an example only with the skroll?
I'm afraid I don't have the time to make you a tutorial-like example for the 8 way scrolling. Even if there was, you still need to wrap your head around the basic concepts. There's no way to abstract it so that you can just use it.
The best way is to experiment and start simple. Left-right scrolling of a long level, etc.
The basic idea is to update the plane at the edges of the screen.
Code: Select all
000000000000000000000000[111111]000000000000000000000000
000000000000000000000000[111111]000000000000000000000000
000000000000000000000000[111111]000000000000000000000000
000000000000000000000000[111111]000000000000000000000000
1 is the area seen by the screen
When moving the screen left, you have to update the column of tiles at the left side of the screen. When moving right, update the column of tiles on the right.
That part is pretty straight forward. The tricky parts come when you start crossing plane boundaries. There will be a point where you can't simply draw the next column at the next logical position in memory because you'll start stomping memory.
Planes have a property where they wrap if you scroll too much. If you take a 64x64 map and scroll it horizontally by 65 tiles, you'll start seeing the first column of the map again.
If your level is 128 tiles wide and your plane is 64 tiles wide, when you're scrolling right and you want to draw the 65th tile column of your level, you have to draw it at the 0th column of the plane. Basically (column position % 64).
Code: Select all
|-------- plane width --------||----- plane width (wrapped)--|
|----------------------level width---------------------------|
000000000000000000000000000000[111111]000000000000000000000000
000000000000000000000000000000[111111]000000000000000000000000
000000000000000000000000000000[111111]000000000000000000000000
000000000000000000000000000000[111111]000000000000000000000000
I agree with djcouchycouch.
He gave you usefull information to do your own scroll engine.
Nothing complicate, just as he told you when your level is longer than your plane.
With his explination, try to do a simple scrolling, you'll see, it's no sot hard.
If he modify his engine just to have a simple lateral scroll while you don't really know how it's working, it will be harder for you to do any change when you want.
You have really to understand how it's working to really appreciate the job
He gave you usefull information to do your own scroll engine.
Nothing complicate, just as he told you when your level is longer than your plane.
With his explination, try to do a simple scrolling, you'll see, it's no sot hard.
If he modify his engine just to have a simple lateral scroll while you don't really know how it's working, it will be harder for you to do any change when you want.
You have really to understand how it's working to really appreciate the job