Archive

Posts Tagged ‘Flash Games’

Re-coding complete and then some

May 4th, 2012 2 comments

I’ve completed re-coding my game from scratch and the code is much cleaner and much more reusable this time. I managed to add some background music and sound effects during attacks. I’ve also got a stage selection page working (though admittedly it’s not much at this point). I think it’s much more obvious now which units can still be moved, and the flow of each turn is much smoother (though you’ve lost the ability to attack before moving). The music and sound effects are just filler at the moment, I’m going to try and compose my own bg music at some point. As promised, here’s the video:

Please ignore the 2 spots in the video where the music skips forward. I had a couple bugs pop up that required me to review my code midway through the videos and didn’t have the time to figure out what was causing the errors.

I need some feedback on the control scheme. Currently, you choose to not attack anything by clicking on the unit again or by clicking on an empty attack square. I forgot to show it in the video, but if you click outside of the highlighted move/attack area, you cancel the turn (this can’t be done after an attack is completed). Should I change this? I found myself accidently choosing not to attack a couple times during testing. Would a menu that gives you the option to attack, end or cancel be more useful after the movement selection is complete? Your feedback is appreciated!

First Gameplay Video

March 4th, 2012 1 comment

So it’s another busy weekend, with little time for coding. But I did have time to create a gameplay video from the old code which is currently uploaded to Flash Game License.



Some of the features seen in this video have already been removed from the newest version. The two buttons that appear when you click on a unit have been removed in favor of automatically going to movement. The game no longer scrolls when you go to the edges of the map either, it’s now a click and drag interface.

Also, none of the images in the video are the final versions, they’re just pictures I pulled from Google to have something to work with. Let me know what you think in the comments.

No Work Done in a While

February 29th, 2012 1 comment

So…. not much work has been done on my game lately. I’ve been really busy with house repairs being done last week into this weekend and my car needing to be fixed late this weekend up until today. On a positive note, I’ve been so exhausted when I get home that I’ve been getting 9-10 hours of sleep every day this week. So this weekend I should be good to go.

Also, it seems that computer issues are catching in my house. A week after I recovered my game code with the decompiler, my desktop died. I’m planning on using the desktop to create my game art, so this is yet another set back. I’m going to need to reinstall Windows XP on it, so I’ll do that once I get my installation disk back from my friend. Fortunately, I installed Windows XP on a separate partition from all my data in case of such an issue. So I’ll also start working on my game art this weekend.

I’m not going to wait this long for my next update. I promise something will be done for my game this weekend and if I can figure out my video capture software, I’ll post a video on Sunday.

Decompilers Good, Hibernating Bad

February 11th, 2012 No comments

So I haven’t done any work at all on my game since last weekend. Mostly because losing a week’s worth of work on it was depressing me. I believe I’ve found a way to fix it, but it’s still a pain in the butt.

Hibernation Fail
Here’s what happened. I loaded up my computer on Tuesday night to start doing some coding. FlashDevelop was open when the computer put itself into hibernation due to a low battery. I pulled it up to see this:

FlashDevelop post hibernation

There might not appear to be anything wrong with that at first. The only problem is that when I shut down my computer on Saturday night, I had about 14 classes and there’s only 6 in that picture. I figured, “Well, that just must be because that’s what I had open.” So I browse to the folder where I had been saving all my files. Which I had been saving regularly. And what did I see? 7 files with the last modified date listed as 1/29/2012. Even though I had been working on my code as recently as 2/4/2012.

Looking For The cause
Now I can’t say for sure that it was the hibernation file that caused the issue. I don’t see how loading the contents of RAM should affect a folder full of files saved on the hard drive. I suppose it’s possible that “Saving” was only occurring in FlashDevelop’s memory, but that seems unlikely.

The odd part about it all, was that the compiled swf file – the one that’s created every time I try to debug the game – was still showing a last modified date of 2/4/2012. I loaded it up and, lo and behold, it was the same file I had pulled screenshots from last Saturday.

I still don’t know for sure what happened. But I’ve turned off all hibernation on the laptop just in case. I really don’t mind shutting it down every night when I’m done working. It forces me to save more often anyways.

Finding a Fix
I did try downloading a trial for a deleted files recovery tool. But it acted as if the files had never existed as well. I knew about the importance of securing your code before releasing it into the public. This is because it’s supposed to be really easy to decompile unencrypted flash files. I figured I would look for a decompiler and see what my finished swf file could give me.

I can tell you to NOT try sothink’s swf decompiler. It will let you see your code, but the local variable names will be changed and you can only copy out the code if you buy the full version.

I knew there had to be a free decompiler out there, so I googled “free actionscript 3 decompiler” and was led to F.L.A.S.W.F.. He had links to several decompilers and the one I decided to try was ASDec. Looking at the output I was surprised to find that every variable name is identical to the original version.

My Code Is Reborn!

The decompiler isn’t perfect though. It still has to leave out all the comments because those aren’t compiled at all. It also has many extra lines added in declaring variables and then initializing them on separate lines. Fortunately, it should recompile fine for now and I can update it as I go. I was really concerned for a couple days, but I’m ready to return to coding my game once again.

I’ve learned to appreciate decompilers, so long as they aren’t used to steal my game and pass it off as someone else’s. Anyone else every have computer nightmares resulting in lost code?

Move Engine Recompleted

February 4th, 2012 1 comment

Once again I can move my units as I desire. Next is the reprogramming of the AI. For now, enjoy this screenshot of the movement area, recreated.

3 Steps Forward, 2 Steps Back

Well, time to tuck into bed for the night. While it’s disappointing that I haven’t gotten back to where I was 2 weeks ago, I think I’ll be much happier with the code once it’s done. Just about every variable is private now and the classes are properly encapsulated.

Programming A Click and Drag Function

February 3rd, 2012 No comments

Last night I decided to program in a function to allow easier map scrolling when using mouse controls. Previously I had made it similar to the Wii’s turning functionality in first-person shooters. When you got near the edge of the screen, the game would start to scroll in that direction.

The problems arose when you were just trying to access buttons that were off screen because the game would try to scroll in the direction of the buttons. It was just too easy to accidentally scroll. And if you wanted to scroll to the other side of the screen from where you were, you needed to move your mouse all the way to the other side.

Enter Click and Drag
So last night, I decided I was going to make my game scroll when I clicked and dragged. This was a more intuitive interface, similar to the iPhone’s scrolling functionality.

My first attempt at setting this up had mixed results. The scrolling was jittery and it wasn’t 1:1 for some reason. Check out my code below to see if you can spot the error. For reference, the mouseDown function is called when the user presses the left mouse button while on the map, the mouseUp function is called when the user releases the left mouse button while on the map and the mouseMove function is called when the user moves the mouse around the playField, but only after the mouse button is pressed.

private function mouseDown(e:MouseEvent):void {
	this.startMouseX = this.mouseX;
	this.startMouseY = this.mouseY;
	this.startX = this.x;
	this.startY = this.y;
		
	this.addEventListener(MouseEvent.MOUSE_UP, mouseUp);
	this.addEventListener(MouseEvent.MOUSE_MOVE, mouseMove);
	Main.stageSprite.addEventListener(Event.DEACTIVATE, mouseUp);		
}

private function mouseUp(e:Event):void {
	this.removeEventListener(MouseEvent.MOUSE_UP, mouseUp);
	this.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMove);
	Main.stageSprite.removeEventListener(Event.DEACTIVATE, mouseUp);	
}

private function mouseMove(e:Event):void {
	this.x = (this.startX - this.startMouseX + this.mouseX);
	this.y = (this.startY - this.startMouseY + this.mouseY);
}

Ignore the fact that the game will keep scrolling if you happen to release the mouse button while your mouse is outside the flash screen. I haven’t yet figured out how to fix that, so anyone that has a solution should let me know. If you can spot the other error in my code, then you’re a better programmer than I was last night.

The Solution
The problem, it turned out, was caused by my use of this.mouseX and this.mouseY. You see, as you move a sprite around, it’s mouseX and mouseY coordinates change to reflect the relative position of the mouse from the sprite’s (0,0) point, usually the upper-left hand corner.

What was happening was the game would update the mouse coordinates at the same time it tried to update the map’s coordinates. Resulting in what some would call hilarity, but what I called annoyance. To fix the problem, all I had to do was update the references to this.mouseX and this.mouseY to Main.stageSprite.mouseX and Main.stageSprite.mouseY.

Main is my initializing class and stageSprite is a static reference to a sprite that never moves. So as the map scrolled around, the stageSprite stays where it is and provides an accurate reference point to calculate how far the mouse has moved. Here are the results:

Starting Position

The ending point after one click and drag

So overall, I’m pretty happy with the results. I’m trying to reintegrate my old classes for moving units around and attacking other units now. The only problem is that I changed many of the variable names for my units and actually implemented private variables instead of public variables, so I have a lot of updates left to make before I can even run the game without compiler errors. Maybe I just need to program those classes from scratch too. As I write this I’m buzzing from my 2nd coffee this week (I only drink coffee 2-3 times per week to avoid developing a tolerance) and I’m probably feeling way too ambitious. Maybe that’s for the best.

Medieval Tactics: Zombie Wars Concept

February 2nd, 2012 2 comments

I realized recently that I haven’t actually explained the concept for my game yet, so here goes.

Game Mechanics
Medieval Tactics is going to be a turn-based strategy (TBS) game, similar to Advance Wars. Each turn you can move and attack with each of your units.

Every unit will have statistics based on its unit type and every unit of that type will be identical. This is in contrast to most fantasy TBS games in which each unit is unique. I thought this would allow for better tactical decisions, because once you learn how to use a unit type you know how to use all units of that type. This also simplifies the balancing because I know exactly what each unit will be able to do.

Each map will probably have a specific set of units available to it. I’ve considered adding the ability to purchase units at the beginning of each map to add more strategy to it, but if I don’t have time then it won’t be added. At the end of each level, player’s will receive a grade or score based on the number and health of units remaining. This will be used to generate a cumulative score that will either unlock future levels or provide a bonus in the final level.

Units
So far I’ve decided on 14-15 units to include in the game. This should be large enough to provide a learning curve and diversity of map types, but small enough to allow easy balancing.

Good Units
Spearman
-High defense
-Average attack and armor
-Average movement

Swordsman
-High attack
-Average defense and armor
-Average movement

Archer
-Average, medium-ranged attack
-Low defense and armor
-Average movement with ability to move and fire

Hammerer
-Very high attack
-Low defense and armor
-Average or high movement depending on balancing

Lancer
-High attack
-Low defense
-Average armor
-Very high movement

Knight
-Very high attack
-High defense and armor
-High movement

Catapult
-Very high attack with large range
-Average armor
-No defense
-Low movement and can’t move and fire same turn

Cleric
-Low attack, defense and armor
-Ability to heal allied units
-Average movement

Enemy Units
Note: Most zombie units will have an ability that fully heals them whenever they destroy a unit. Zombies would be able to turn units into zombies to replenish their numbers.

Zombie
-Average attack
-Average defense and armor
-Average movement

Zombie Archer
-Average, medium-ranged attack
-Low defense and armor
-Average movement with ability to move and fire

Explosive Zombie
-Very high attack no matter what unit’s health is
-Low defense and armor
-Average movement

Hulking Zombie
-Very high attack
-Average defense
-High armor
-Low movement

Vultures
-Average attack
-Average defense and armor
-Very high movement with ability to cross all terrain

Necromancer
-Very high attack (Or maybe ability to ignore armor)
-High defense
-Average armor
-High movement
-Ability to turn any unit it defeats into a new zombie unit

Level plans
I’m aiming to create around 20 levels for the game, depending on how long it takes to complete each level. Overall I hope the game takes a couple hours to complete and hopefully the ability to get a bonus on the last mission will encourage people to replay levels to get a high score.

Control scheme
I was originally planning on making the game completely playable with either keyboard or mouse, but I’m thinking that optimizing it for mouse will make for a better playing experience. While I prefer using keyboard controls for games, I don’t think I can easily optimize a strategy game for keyboard controls.

I also think that mouse controls are just more intuitive, i.e. click this unit, click there to move it, click the enemy to attack. Keyboard controls would be more like, let’s see, press ‘n’ to go to the next unit, press ‘m’ to move, scroll over to the target square with arrow keys, press ‘m’ to move to that square, press ‘a’ to attack, scroll over to target unit with arrow keys, press ‘a’ again to attack that unit.

Final Thoughts
There are a couple additional mechanics I’d like to include, such as wizards with spells, water-based units and an alternate campaign. I don’t think any of these are going to make it into the first version of the game. I’ll reserve them for sequels.

Any thing you’d like to see in the game that I’m not including? Let me know in the comments.

The Results of 3 Hours of Programming

January 29th, 2012 1 comment

So after doing 3 hours of programming from scratch I only have the bare bones of my game completed. I did manage to make my level select screen and the rest of the game is in much better shape than it was before. Unfortunately the new game is still a good 3-4 hours short of being a full prototype.

This is what I had after 45 minutes of programming

I think the lesson to learn from this is don’t attempt to complete a prototype from scratch in one sitting if you’re not a great programmer. Also, don’t start at 11 PM if you know staying up past 2 AM isn’t a realistic expectation. I’m guessing the people that do this from scratch thing probably have more tools than just basic actionscript 3 at their disposal. Once I have my game working again I may have to look into it to see what’s out there.

Game Jam Time

January 28th, 2012 No comments

A Game Jam is a programming session undertaken with the intention of creating a complete and working game prototype. Since I had so many issues when I went to integrate my level selection screen, I’ve decided that I’m going to start from scratch and see what I can do. If all goes well, I’ll post a picture of the new version of the game tomorrow.

I know I can stay up until at least 2 AM, so that’s at least 3 hours of work. Having already made the prototype of the game once that should be enough to get everything working as it does now. Since I already know what mistakes I made the first time, it might actually work better after I’m done with this. Wish me luck!

Unexplained Bugs

January 26th, 2012 No comments

My game has been on Flash Game License for a week now and in that time all 3 of my friend’s with fan accounts have logged in and tried it. The first one discovered the error caused by code encryption. The second one told me that they couldn’t figure out how to end turn, but after looking into that I couldn’t find an issue. The third one reported the same issue as the second one. So I dug a little deeper.

Apparently, moving units is causing the “End Turn” button to disappear. The third tester also found that when clicking on an enemy unit, the game completely locked up. I have yet to reproduce either of these things even when playing the game online on a different computer. So I guess it’s back to the drawing board on the buttons.

Additional Game Progress
In the meantime, I’ve been working on adding a level selection screen up front. It’s making me realize how bad a decision it was to treat the “Main” class as though it were the class for my battle screen. I don’t have a “destroy” function to quickly make everything disappear when I want to go back to the stage selection screen.

That’s a lesson for anyone starting on their first game. Make every screen the user might see it’s own class and make the “Main” class (the one that runs every time the game is opened) as minimal as possible. It should contain a static variable referencing the window itself and should create an instance of whatever class will contain your opening screen and then attach it to the window. That way when you switch up which screen your game opens with you only need to change which class is called. Don’t do what I did. You’ll have to rewrite most of it later.