The Spawn Engine

an educational open source Flash game engine

Release of The Spawn Engine version 0.2

Version 0.2 (for CS5) includes the following changes:

* Completely removed all display objects from the stage, all timeline keyframes, and all timeline code.

* “game states” are now handled by the variable “applicationMode”, which is set to one of two constants, AM_IDLE or AM_GAME

* ButtonFactory is now UIFactory

* all “user interface” elements are now created programmatically, using static methods exposed by UIFactory

* the various application modes manipulate the user interface elements by changing their visibility state, as well as changing text strings

* experienced some strangeness with changing the text of TextFields; they seemed to lose their previous formatting. This was worked around by reapplying the previous formatting (see SpawnEngine.updateText()).

* Implemented some tests of procedural buttons via ButtonFactory (static method)

  1. Download the Spawn Engine v 0.2 and get started.
  2. If you have any trouble please comment.

2012/04/24 Posted by | Engine Releases | , , | Leave a comment

Release of The Spawn Engine version 0.1.2

Version 0.1.2 (for CS5) includes the following changes:

* All “constant numbers” moved to private static constants. The used (and preferred) style for this is all caps, for example: private static THIS_IS_A_CONSTANT:uint = 5;

* The private function showText() is now updateText() to better reflect what it does.

* Fixed a spelling error in the name of the private function checkBulletEnemyCollisions().

* All variable names are now in english. The few ones in swedish have been removed.

* All comments in swedish have been removed. English comments in some future version.

  1. Download the Spawn Engine v 0.1.2 and get started.
  2. If you have any trouble please comment.

 

2012/02/29 Posted by | Engine Releases | , | Leave a comment

NEW Release of the Spawn Engine version 0.1

I’ve cleaned up some curly brackets that were in the wrong places which created problems for students when they were editing the code. I also cleaned up some comments. In future versions there will only be comments in english.

Download the Spawn Engine v 0.1 for CS3. If you have any trouble please comment. For a CS5-version get the 0.1.1 of the Spawn Engine.

I apologize for all the comments in swedish in the code. Remember that this is a project where we work with this engine as a text-book for a swedish programming course. That is also why this version is fully playable yet has a lot of room for improvement.

2011/12/06 Posted by | Engine Releases | , , | Leave a comment

Release of the Spawn Engine version 0.1.1

This is just a small update of version 0.1 to make the engine work for CS5 where fonts needs be embedded. I also did some clean up among comments and there where a few curly brackets in the 0.1 version that where in the wrong places that now have been fixed.

  1. Download the Spawn Engine v 0.1.1 and get started.
  2. If you have any trouble please comment.

I apologize for all the comments in swedish in the code. Remember that this is a project where we work with this engine as a text-book for a swedish programming course. That is also why this version is fully playable yet has a lot of room for improvement. Maybe you can find some things that you don’t like with the engine? Good! Start coding and feel free to post descriptions of what you don’t like with the engine that you have fixed.

2011/11/29 Posted by | Engine Releases | , | Leave a comment

Updating newEnemy for version 0.2 using variables instead of numbers

If you have downloaded the release of the Spawn Enginen version 0.1 and played around with it you will have noticed a lot of things that need to be improved. Please feel free to comment what changes you would suggest! The idea is that each new release of the Engine should have a few improvements slowly making it better and better but always leaving a little room for students to improve the Engine. I don’t have any ambition to ever make the engine completely perfect. There must always be room for improvement inspiring students to do their best to do those improvements themselves.

This time I thought I’d blog about one area of improvement and I’d like to demonstrate it by showing how we will update newEnemy for version 0.2 using variables instead of numbers. This is what the function looks like in version 0.1 (removing comments).

public function newEnemy(te:TimerEvent) {
var e:Enemy = new Enemy;
var slumpX = 10 + Math.random()*530;
e.x = slumpX;
e.y = 10;
addChild(e);
enemies.push(e);
setNextEnemy();
}

The function works fine but there are a few things that the programmers eye should catch. Not errors just not good looking code.

Using variables instead of numbers

The first one I’d like to point out is using variables instead of numbers. Lets illustrate this with an example:

I want to use the engine for a game with a wider stage than the original engine has. I’m not sure how wide though. At the beginning of the design phase I’m changing the width of the stage back and forth to try and see what width is most suitable considering how wide enemies, pickups and the player is. Each time I change the width of the stage I need to go and change that number 530 to represent the correct value for the new width of the stage. If I have any other places in my code where I use a number for the stages width I’ll have to change them too. Annoying and time consuming! Lots of changes in lots of places. It’s also easy to miss one place and get errors. Not good. We should use variables or constants instead so we only need change in one place: at the top of our code where the variables and constants are declared.

I would add enemyMargin as an int variable with value 10 at the top of our code where we add the other enemy variables. I would also add the constant STAGE_WIDTH with the value corresponding to the stages width. If you have a GUI that removes some part of the stage you can adjust STAGE_WIDTH and STAGE_HEIGHT to have the correct values for your game.

Updating newEnemy for version 0.2 would look something like this:

public function newEnemy(te:TimerEvent) {
var e:Enemy=new Enemy;
var randomX = enemyMargin + Math.random() * (STAGE_WIDTH – enemyMargin);
e.x = randomX;
e.y = e.height;
addChild(e);
enemies.push(e);
setNextEnemy();
}

As you notive I also changed the swedish variable name slumpX to an english name randomX and also changed the numeric value of e.y to e.height. This value could be set to zero if you want the enemies to spawn off stage.

This was a little updating newEnemy for version 0.2 using variables instead of numbers. I hope you can find the many more places in 0.1 where we make this mistake. Can you find them and post a comment?

2011/03/13 Posted by | Engine Releases | , , | Leave a comment

Release of the Spawn Engine version 0.1

This is it! Finally had time to fix a Sourceforge account, add the engine as a project, upload the file so I can release the Spawn Engine version 0.1.

Download the Spawn Engine v 0.1 and get started. If you have any trouble please comment.

I apologize for all the comments in swedish in the code. Remember that this is a project where we work with this engine as a text-book for a swedish programming course. That is also why this version is fully playable yet has a lot of room for improvement. That is what my students are working with at the moment; building add-ons and tutorials that will appear in the blog in the future.

Tune in later on for version 0.2 with lots of small updates. If you wish to help out with this project or use it as a teacher please contact me by commenting.

2011/02/03 Posted by | Engine Releases | | 3 Comments