Flash Engine, GO!

Published May 21, 2011
Advertisement
[color="#333333"][font="Georgia,"]So for the last few days I have been working on my flash engine (currently unnamed) and by extension Elma and Sorc.

The way I handled this was, I first figured out the games I would be making using this engine, one was a strategy game, the other an adventure game, both utilising different views but still using tiles. So the first thing I wanted, was a nice way to display a sprite BUT in such a way that I can set colour keys that change depending on team colour (for Sorc) and so I went ahead and implented something super quick and easy:

  • Loop through all bitmap data
    • if pixel is colour key
      • set pixel to colour
Oh but Nathan why not use shaders!? Well, it doesn't need to be real-time, I can change all the sprites for each team once and they will just use those. Simples. If I have long load times I can just change a sprite on demand(once) instead of all at once.

Colour key working:

colourkeytest.png

The image before the colour is changed for the two visuals.

ColourKey-300x241.png

Two different colours replacing the key.

Okay, I had a nice and easy way to load and display a sprite with a different colour key, now I wanted an easy way to create and change \ play animations! So I created a SpriteSheet class to easily handle all of this, the way it works is that it keeps track of animation names (string) to AnimationData which just outlines how an animation works within a SpriteSheet, very simple but works well.

An example using a crappy sprite sheet I made that is just different colours:

animtest-300x150.png

Test animation, yes it has separators.


[color="#333333"][font="Georgia,"]
[/font][/color]http://t3agames.com/Test2.swf

Now, you can see there is a simple problem, if the sprite-sheet has any separation between frames my sprite sheet class won't work icon_sad.gif I was going to fix this, but then I realised, separators are wasted pixels anyway, who needs 'em! I will probably add the functionality in later though (Had a little chat to my Artist friend about it).



So I had nice animating game visuals which I would eventually put into an Entity, but I felt I needed to work out my state manager, which is a fairly trivial task for me, as I have made them easily before in other languages although there was a tiny hitch, the default vector has only splice which is used both to add an element anywhere in the vector, or remove an element anywhere in a vector, and not just a remove or push front. Kind of annoying but easily rectified.



Now that I had a state manager, I started going crazy with States and I created two groups in my nice flash develop src folder that were elma and sorc for each project, each one for the states of each. Then I made a choose state which I can use to start up either game so I can change the engine and make sure it works for both fairly easily. At this point I also realised I'll need buttons, but for now a state just uses sprites for buttons, I'll create my own class for those later on when polish is needed.



Now that I had states working fine, I decided it was finally time to start tackling the big project of tile maps, I needed two different ones as Sorc was going to be in the style that StarCraft 1 was in while Elma was going to be Zelda style. I decided to work on the staggered isometric first, and then encapsulate anything that was reusable into a single tilemap class, with an isometric and a normal tile map class extending from it.



This was fairly easy, getting the rendering correct and whatnot, the hard part was figuring how to correctly pick a tile using mouse coordinates in a staggered isometric world, since I wasn't using matrices I couldn't un-project them (Although I might switch to matrices later on) two days later I only had a it barely working (It would skip a row or column sometimes!) so I enlisted the help of a friend Michael Sampson to help me out and he came up with a sweet way, although it probably isn't the best solution but it works fine for now and is essentially engine independent. I will only optimise if I find it is slow. This took the majority of the time, along with A*.



Just for funsies I also added a GameWorld class which will eventually give easy access to path-finding and the map data, and gave it a create random world function, which is called on start-up and recalled if you release 'k'. At the moment it just uses the simple random function that as3 provides, but it is still cool to spam k and see what it makes. I might mess with this if I feel like it, to make bigger worlds and make proper environments because random terrain gen is something I don't know anything (or enough icon_razz.gif ) also it's really cool.



I then 'worked' on A*, I basically copy pasted my C++ implementation that I made for Brains and just made it work in AS3 (Is actually pretty difficult...or time consuming to do). The only problem with it is that the heuristic that I used in that was for a square map, and I am using an isometric map for Sorc, so I need to work on the heuristic so that it properly calculates the distances AND my search for nearby nodes needs to be redone as it currently searches a tile too far in some cases making the A* jump a tile.

To choose a new path, just click somewhere, then click somewhere else. I put a maximum step that could be taken, otherwise trying to make a path directly four across would result in Flash crashing, I made it 100 iterations. Press 'k' to create a new world.

http://t3agames.com/Test3.swf[/font][/color]
[color="#333333"][font="Georgia,"]
[/font][/color]
[color="#333333"][font="Georgia,"]So things to do:[/font][/color]
  1. [color="#333333"]Fix A* for Iso Staggered maps[/color]
  2. [color="#333333"]Create a seperate pathfinder depending on map being used (normal sqaure tile map or iso map)[/color]
  3. [color="#333333"]Entity[/color]
  4. [color="#333333"]ComponentGameVisual[/color]
  5. [color="#333333"]Basic Networked Entity[/color]
  6. [color="#333333"]Some kind of network manager[/color]
[color="#333333"][font="Georgia,"]
Anywho, I have also done some progress on my TS engine, FPS and TWU. I'll post about them later, I'll also post more detailed explanations of my games as well. icon_razz.gif .

Until then, good luck!

EDIT: Apparently I need to do some research on deploying flash games, as what I posted doesn't really match what I had. Ah well.

[/font][/color]
Previous Entry Brains
Next Entry Flash Peer-to-Peer!
0 likes 1 comments

Comments

nhold
Well, for every hour I don't work on them while at home I owe my brother $100 and my friend a case of beer. Also I find it okay having this many projects, if I get bored of one I switch to another.

(I have so far gone like this: Flash Engine->TWU->Sorc->Elma->TWU->FPS->TS GameEngine->Elma)

Which reminds me, I still have to post about TWU and my Surf-based FPS)

And thanks a lot! [img]http://public.gamedev.net/public/style_emoticons/default/laugh.gif[/img]
May 28, 2011 05:19 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement

Latest Entries

Dimins V2018.2

1869 views

Dimins V2018.1

2383 views

Octree Voxel Planet

3884 views

Toasty Update #9

2314 views

Toasty Update #8

2106 views

Toasty Update #7

2181 views

Toasty Inspiration

2102 views

Toasty Update #6

1899 views

Toasty Update #5

2003 views
Advertisement