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
- if pixel is colour key
Colour key working:
The image before the colour is changed for the two visuals.
Two different colours replacing the key.
An example using a crappy sprite sheet I made that is just different colours:
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 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 ) 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]
- [color="#333333"]Fix A* for Iso Staggered maps[/color]
- [color="#333333"]Create a seperate pathfinder depending on map being used (normal sqaure tile map or iso map)[/color]
- [color="#333333"]Entity[/color]
- [color="#333333"]ComponentGameVisual[/color]
- [color="#333333"]Basic Networked Entity[/color]
- [color="#333333"]Some kind of network manager[/color]
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. .
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]
(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]