by date
A platform game from (almost) scratch in 4h48m.
A platform game from (almost) scratch in 4h48m.
| Name: | Jon Frisby | ![]() |
|---|---|---|
| Date Posted: | Dec 17, 2006 | |
| Rating: | 3.0 out of 5 | |
| Public: | YES | |
| Comments: | YES | |
| RSS Feed: | or Subscribe with . | |
| Profile Page: | View profile page for Jon Frisby |
Blog post
A couple days ago, a good friend of mine asked me for some help with a game she's building as a Christmas gift. The game is a platformer, and she's having trouble with it.
I looked over the code and frankly, it was a bit of a mess with some very complicated tricks going on that I didn't quite understand. I attempted to clean it up and get it working to no avail. Then she revealed that she had based it on the platformer mini tutorial and had had the same problems with the stock result of the tutorial. Aha!
So I went through the tutorial. In many respects, the tutorial is quite excellent -- as a guide to how to structure the code and play well with Level Builder, it's very good. Unfortunately the actual code is... Not quite good enough. It is buggy (jumping just didn't seem to work at ALL), prone to encountering quirks of TGB's physics system (sticking to the ceiling, or sticking to the floor when jump is pressed), the play mechanics are awkward, and so forth.
So, I asked my friend "what play mechanics do you WANT", and I proceeded to systematically gut the code. I reimplemented it in a somewhat simpler manner and then proceeded to work around the quirks of TGB's physics and the correct-but-undesirable consequences of using the physics system for movement. For example, if I jump, and I'm moving right, and I hit a platform while going up, I stop moving right and don't resume once I'm above the platform unless I release and re-press the right-arrow. Kind of frustrating when you're actually playing.
When the dust had settled, I had 199 lines of code and the following:
-Cut scenes (keyboard is disabled, the level plays for a fixed time before transitioning to the next level).
-Transitioning to the next level by means of touching a designated object.
-Player character that can move left/right, jump, and is subject to gravity -- with play mechanics that are comfortable, albeit not nearly as good as Super Mario.
-Player death by way of infinite pit. (Easily extended to other means of dying!)
-Full animation support so the player is facing the direction he's walking (or was walking last). 8 animations in total: Standing (leftwards), standing (rightwards), walking (left), walking (right), jumping (facing leftwards), jumping (facing rightwards), jumping (moving left), jumping (moving right)
Things are still just a *touch* twitchy, but it's pretty smooth.
Here's the rough timeline:
3:38PM: Started reading the platformer tutorial.
4:39PM: Gave up on the tutorial code and started gutting it.
5:18PM: Basic platform mechanics (moving left/right and jumping) implemented relatively robustly, but subject to some physics quirks.
5:27PM: Worked around physics quirks.
5:50PM: Dying and respawning implemented, with some nasty bugs related to the latter.
6:01PM: Found and fixed my stupidity that caused nastiness related to dying.
6:58PM: Player can move to the next level by touching a designated (by way of class definition) object. All the major physics quirks worked around.
7:08PM: Commented the code. :D
8:19PM: Cut-scenes implemented.
8:26PM: Disabled keyboard during cutscenes.
Despite the hassles, both TGB and the platformer mini tutorial proved very valuable tools in putting this little game together. Good stuff, and thanks to GG and whomever is responsible for the platformer mini tutorial!
Now, back to that data warehouse project I was SUPPOSED to be working on...
Speaking of data warehousing, here's how that code volume breaks down (not that lines-of-code are a good measure of anything, but it's interesting to see what requires a lot of verbiage to express and what can be expressed concisely):
-Constants/exec statements: 4 lines.
-Boilerplate from game.cs: 12 lines.
-Basic movement/jumping: 62 lines. (includes a few lines from the platformer mini-tutorial)
-Workarounds for physics quirks (correct and incorrect): 38 lines.
-Cut scenes: 4 lines. (plus moving one line from the boilerplate stuff to a different place)
-Animation: 20 lines.
-Level changing: 13 lines.
-Death: 46 lines.
-JF
I looked over the code and frankly, it was a bit of a mess with some very complicated tricks going on that I didn't quite understand. I attempted to clean it up and get it working to no avail. Then she revealed that she had based it on the platformer mini tutorial and had had the same problems with the stock result of the tutorial. Aha!
So I went through the tutorial. In many respects, the tutorial is quite excellent -- as a guide to how to structure the code and play well with Level Builder, it's very good. Unfortunately the actual code is... Not quite good enough. It is buggy (jumping just didn't seem to work at ALL), prone to encountering quirks of TGB's physics system (sticking to the ceiling, or sticking to the floor when jump is pressed), the play mechanics are awkward, and so forth.
So, I asked my friend "what play mechanics do you WANT", and I proceeded to systematically gut the code. I reimplemented it in a somewhat simpler manner and then proceeded to work around the quirks of TGB's physics and the correct-but-undesirable consequences of using the physics system for movement. For example, if I jump, and I'm moving right, and I hit a platform while going up, I stop moving right and don't resume once I'm above the platform unless I release and re-press the right-arrow. Kind of frustrating when you're actually playing.
When the dust had settled, I had 199 lines of code and the following:
-Cut scenes (keyboard is disabled, the level plays for a fixed time before transitioning to the next level).
-Transitioning to the next level by means of touching a designated object.
-Player character that can move left/right, jump, and is subject to gravity -- with play mechanics that are comfortable, albeit not nearly as good as Super Mario.
-Player death by way of infinite pit. (Easily extended to other means of dying!)
-Full animation support so the player is facing the direction he's walking (or was walking last). 8 animations in total: Standing (leftwards), standing (rightwards), walking (left), walking (right), jumping (facing leftwards), jumping (facing rightwards), jumping (moving left), jumping (moving right)
Things are still just a *touch* twitchy, but it's pretty smooth.
Here's the rough timeline:
3:38PM: Started reading the platformer tutorial.
4:39PM: Gave up on the tutorial code and started gutting it.
5:18PM: Basic platform mechanics (moving left/right and jumping) implemented relatively robustly, but subject to some physics quirks.
5:27PM: Worked around physics quirks.
5:50PM: Dying and respawning implemented, with some nasty bugs related to the latter.
6:01PM: Found and fixed my stupidity that caused nastiness related to dying.
6:58PM: Player can move to the next level by touching a designated (by way of class definition) object. All the major physics quirks worked around.
7:08PM: Commented the code. :D
8:19PM: Cut-scenes implemented.
8:26PM: Disabled keyboard during cutscenes.
Despite the hassles, both TGB and the platformer mini tutorial proved very valuable tools in putting this little game together. Good stuff, and thanks to GG and whomever is responsible for the platformer mini tutorial!
Now, back to that data warehouse project I was SUPPOSED to be working on...
Speaking of data warehousing, here's how that code volume breaks down (not that lines-of-code are a good measure of anything, but it's interesting to see what requires a lot of verbiage to express and what can be expressed concisely):
-Constants/exec statements: 4 lines.
-Boilerplate from game.cs: 12 lines.
-Basic movement/jumping: 62 lines. (includes a few lines from the platformer mini-tutorial)
-Workarounds for physics quirks (correct and incorrect): 38 lines.
-Cut scenes: 4 lines. (plus moving one line from the boilerplate stuff to a different place)
-Animation: 20 lines.
-Level changing: 13 lines.
-Death: 46 lines.
-JF
Recent Blog Posts
| List: | 09/20/08 - 3 days of AGDC, untold weeks to recover... 08/28/08 - DEATH TO YOUR BALLS! 04/13/08 - Hordes of Orcs for Windows, Harmonic Convergence, and Revenge! 02/20/08 - I CAN HAZ GAME BALANCE? 02/11/08 - 240 days, and counting! 12/15/07 - My milkshake brings all the orcs to the yard... 09/20/07 - "Gentlemen, I'm goin' home in my new car." 09/17/07 - OH GOD!!!! THE ORCS ARE INVADING!!!!!! |
|---|
Submit your own resources!| Mads Laumann (Dec 17, 2006 at 10:33 GMT) |
I did the platform tutorial too yesterday :) What about some screenshots?
| Luc Jordan (Dec 17, 2006 at 14:31 GMT) |
Not to be a stickler, but with TGE it's almost a sacrilege to say we're 'starting from scratch'. Examples of concision in TGE, much like really brief Ruby on Rails walkthroughs or short winforms programs in C# that do a lot of cool things by leveraging windows' media libraries, are better showcases of the frameworks/libraries they're built on than the prowess of the programmer -- especially in the less expressive languages like C#; the language will only let you be so expressive in that few lines of code.
Anyways, semi-snarky morning commentary aside ... with that few LOC, why not go ahead and post it?
| Jon Frisby (Dec 17, 2006 at 17:56 GMT) Resource Rating: 5 |
You must be a member and be logged in to either append comments or rate this resource.



3.0 out of 5


