Crate Crash 2 and More

Hey,

It’s been a pretty long time since I last updated. I’ve been up to a few things lately. One of the biggest things I want to address is the development of Crate Crash 2. A few of you know of the first Crate Crash game, but for those of you who don’t, you can play it here: Crate Crash at TopPhysicsGames.com. The first Crate Crash game is all about clicking the game screen to apply impulses or little explosions that launch the crates. The goal of the game was to get the crates off of the screen, and this goal is still pertinent in the second game, BUT there are more crazy levels, obstacles, and challenges to get through.

The biggest issue that I noticed that people were having was that the game was way too damn hard. Now that I go back and play it again, I think it’s too hard. What I’m going to do with CC2 is create different difficulties. By default users will be playing on casual mode which will allow you to just play the game with no limits of restrictions (that means no medals on the levels, and no click limit). I’ve found having a sandbox-type mode allows the user to have a more enjoyable experience, I know that for a fact because sometimes in developing the game I get distracted just messing with the physics.

Another change from the original is that there will be less levels. It isn’t completely final how many levels there will be, but right now I have a 45 level cap. It could increase, but I don’t think it will.

The biggest feature of Crate Crash 2 will be the level editor. Users these days like to create their own content, and with the level editor that I’ve made, creating your own content should be VERY easy. I’ve had a few ideas of how I wanted to share these levels and I have few ideas going on in my head.

In other news, I am developing my own arcade script, Custom Arcade Script (Pretty cool name, right?). After being in the arcade scene for nearly 2 years now, and having mild success, and looking at how the arcade business is being handled, I’m not 100% satisfied with the way that arcade scripts work today. I’ve tried a few arcade scripts, and none of them are particularly great. They all their ups and downs, but none of them are a one-stop solution. Custom Arcade Script looks to provide just that. CAS will encompass some of the newest and most reliable arcade-related code available. With its streamlined interface, and easy to use admin panel, I have no doubt that Custom Arcade Script will be a huge contender in the arcade script market when it’s released!

-Tom

How to make a platform engine in QuickBox2D – Part 2

Read Part One of the article, it covers some of the basics, and explains a few things.

With the release of QuickBox2D 1.0 I figure I should update my game engine articles. I won’t actually update the first one, but instead I will provide updated versions here, with links to download the files (source).

One of the best things about the new QuickBox2D is the addition of QuickContacts.

var contacts:QuickContacts = sim.addContactListener();
contacts.addEventListener(QuickContacts.ADD, onAdd);
contacts.addEventListener(QuickContacts.PERSIST, onPersist);
contacts.addEventListener(QuickContacts.REMOVE, onRemove);

function onAdd(evt:Event):void{
	if(contacts.currentPoint.shape1 == main.shape || contacts.currentPoint.shape2 == main.shape){
		if(contacts.currentPoint.normal.y >= -1 && contacts.currentPoint.normal.y < 0){
			grounded = true;
		}
	}
}
function onPersist(evt:Event):void{
	if(contacts.currentPoint.shape1 == main.shape || contacts.currentPoint.shape2 == main.shape){
		if(contacts.currentPoint.normal.y >= -1 && contacts.currentPoint.normal.y < 0){
			grounded = true;
		}
	}
}
function onRemove(evt:Event):void{
	grounded = false;
}

QuickContacts is a class that uses the b2ContactListener class that comes stock with Box2D. If you remember, we actually modified that class so we could detect if we were touching things (this way our character could jump). With this addition, we won’t actually need to modify that, AND we won’t have to make that global class. We can just do all the code on the timeline.

On the first part of the series, someone commented saying that if you add an object that does NOT have a zero density, that game would get pretty messed up. Well, he was right. That was because in the b2ContactListener, when we checked to see if we were grounded, the class was actually checking every single object against each other. Meaning that any object with zero density was being checked, and since it was sitting on the boxes right, it would set our grounded variable to true.

One more addition to the platform engine is the ability to make platforms that you can jump through the bottom, this isn’t really new feature, but it’s pretty nice. To be honest, the code that actually makes it so you can jump through the bottom of platforms was originally taken from a snippet on Actionsnippet.com, the creator of QB2D. So, thanks Zevan.

I also made numerous fixes to the code from the last version. One of these fixes include changing direct modification of gravity, to setting the main character object to sleep. I would change the gravity to 0 when the main character was standing on a platform, specifically on a slope, so that the character wouldn’t slide down. However, it turns out to be a better plan to set the object to sleep. Why? Well, if you push one of those non-zero density spheres off a platform, it won’t actually fall with the old system, whereas the new system fixes that.

Test the QB2D Engine

Download the source

What should I add to the new version? Suggestions?

Tom

5 Ways to Improve Your Flash Game

You just made the best flash game ever, huh? Is that so? Before releasing your game into the wild, make sure you try some of the following:

Add a Highscore Table

Highscores are a great way to get people to play your game more, and enjoy it. A highscore table in this day and age is becoming more of a standard for flash games than ever before. The player practically lives to be ‘the best’, so why not help them the best by letting them show it.

Add Achievements

This practically goes hand in hand with having a highscore a table. Users lately have been expecting a rewards for actions they perform in games. Major consoles have them, and if they have them, there’s no doubt that Flash game players will be expecting them as well.

Have Good Audio

Some people totally skip this part. This is a vital part of creating a great game. Games that totally skimp out on taking the time to get audio that fits the game are only hurting themselves. I’m not saying throw a sound effect on every little thing in the game, I’m just saying don’t be too intrusive on how it’s played out. Menu’s should have their own music, different locations in the game should have different music. Every viral and popular game has great audio that adds to feeling of the game. Imagine you’re doing the final level of Halo to vivaldi, not very epic is it? Vivaldi would definetly ruin the mood.

Use less text!

One mistake that most developers make is that they use too much text. People going online looking to play some free flash games after a hard day aren’t looking to read, they want to relax and have some fun. So, try to avoid lengthy instruction screens. Players are looking for simple intuitive controls. If you absolutely need to have directions in the game, so be it. But, add a skip button so they don’t have to sit through it. Then, show a graphics, or something real quick to tell the controls. Just so they know.

Spend a day or two tweaking

You don’t know how many developers skip this step and are just so eager to get they’re game out there that they forget to bug check, and as a result lose fans. Let’s say a developer gave the boss on level 12 too much health, resulting in half the people playing getting frustrated. Five minutes of adjustment could have made the game that much more enjoyable. Other things could be added to keep the players hooked are save games, cutscenes, special effects, and etc.

Making a great viral flash game can be a daunting task, but I hope this guide/outline will help make that task a little easier.

Please, don’t hesitate to comment. Your opinions are always welcome.

-Tom

Convert Unsigned Integers to Hexadecimal Strings

So, you wanna convert a uint to hex in AS3, huh? Well, this is how you do it:

function uintToHex(val:uint):String {
	var pref:String = "000000";
	var str:String = String(pref + val.toString(16));
	return "#" + str.substr(-6).toUpperCase();
}

What I think this is really useful for is converting randomly generated colors to hexadecimals so that you can access them later. I mean, it’s not that the uint equivalents are bad or anything, but the hex codes are generally easier to work with.

Also, awhile back I was browsing the web seeing how other people managed to do this, and I found this post: Tylerbeck.com
Feel free to check it out. It’s really great for understanding hexadecimals a bit more. It’s a longer function, but does the exact same thing as this one.

Good Luck,
Thomas

How to make a platform engine in QuickBox2D

Check out part 2 RIGHT HERE

What’s up? Ready to learn a little something about QuickBox2D? Wait, you don’t know what QuickBox2D is? Well, QuickBox2D is a simpler way of using Box2D — A physics library originally written in C++ and ported to many other platforms including AS3 — and is much cleaner and easier to use than the straight Box2D library. Anyways, QuickBox2D was made by Zevan Rosser, who is a teacher at the School of Visual Arts in NYC. You can see a lot of great examples of how to use QuickBox2D at his blog, ActionSnippet.

Let’s get started here. First thing you need to do is get the latest version of Box2D and QuickBox2D at these links:
Box2DFlashAS3
QuickBox2D
And Save them in a new folder called ‘PhysicsPlatformer’.

Now open Flash CS3/4 and create a new Flash AS3 Document File. Go back to the File menu button and add another file, this time we are going to add an Actionscript Document (.as file). Save the .fla as game.fla, and save the .as file as global.as.

The global.as file is going to contain one variable (kind of a waste, I know, but it can be useful when you expand your engine a little bit more, like for implementing wall-jumping, it could be useful). Since global.as is the smallest, we’ll start with that. This is the code that should be in your global.as class file:

package {

	public class global {

		public static var grounded:Boolean = false;

		public function global():void {

		}
	}
}

The important thing to notice here is ‘static’ on line 5. When you use the word static in the definition of a variable, it means that you can access the variable by stating the class name then the variable name without instantiating the class. This is really great because when we need to access our boolean, grounded, all we type is “global.grounded”.

The next part is probably the hardest part to do, actually making the engine. When I was in works of creating the engine, I had some real trouble getting the main character (a ball in our case) to stay still on a slope, and i came up with an ingenious way of fixing this problem, and you’ll see in the tutorial here how I did it.

Lets start by setting up our QuickBox2D simulation:

import com.actionsnippet.qbox.*;

var sim:QuickBox2D = new QuickBox2D(this);
sim.setDefault({lineAlpha:0, fillColor:0x333333});
sim.createStageWalls();

sim.start();

If you paste this in the timeline of game.fla and test it, you should see a dark grey box surrounding your stage, If not, then look through your code checking for typos or something because we have a long way to go.

Next we can add our character, a simple ball will do:

import com.actionsnippet.qbox.*;

var sim:QuickBox2D = new QuickBox2D(this);
sim.setDefault({lineAlpha:0, fillColor:0x333333});
sim.createStageWalls();

var main:QuickObject = sim.addCircle({x:3, y:3, restitution:0, lineAlpha:1, fillColor:0x888888, allowSleep:false, fixedRotation:true});

sim.start();

There is obviously only one addition to this, it’s on line 7. First we make a new variable that’s typcasted as a QuickObject, then we set it equal to the results of the addCircle function. You’ll notice in the function that there is one argument, and it’s an object with a lot of stuff in it. I’ll point out the most important parts of those parameters. allowSleeping: false. If our object could ‘sleep’ then we would not be able to move it unless we wake it up, I suppose it’s fine to leave this as true (by default) and then whenever you want to move the character wake it up, but it’s not making the hugest impact on the game right now, so don’t worry about it. And, fixedRotation: true. Let’s say we are controlling our circle and we get to a slope, and we are trucking up the slope, but then we have to stop for a second because a friend is calling or something, when we let go of our keys, the ball will just start rolling down the slope, and we can’t have that.

So, great, we have a ball. How do we move it? We move the ball by adjusting it’s linear velocity. But first we have to set up a few functions to handle our keyboard input and such:

import com.actionsnippet.qbox.*;
import Box2D.Common.Math.*

var sim:QuickBox2D = new QuickBox2D(this);
sim.setDefault({lineAlpha:0, fillColor:0x333333});
sim.createStageWalls();

var main:QuickObject = sim.addCircle({x:3, y:3, restitution:0, lineAlpha:1, fillColor:0x888888, allowSleep:false, fixedRotation:true});

sim.start();

stage.addEventListener(Event.ENTER_FRAME, loop);
stage.addEventListener(KeyboardEvent.KEY_UP, checkKeysUp);
stage.addEventListener(KeyboardEvent.KEY_DOWN, checkKeysDown);

var keyArray:Array = new Array();
var speed:int = 5;
for (var i=0; i<222; i++) {
	keyArray.push(false);
}

function loop(e:Event):void {
	if(keyisdown(39)){
		main.body.SetLinearVelocity(new b2Vec2(speed, main.body.GetLinearVelocity().y));
	}
	if(keyisdown(37)){
		main.body.SetLinearVelocity(new b2Vec2(-speed, main.body.GetLinearVelocity().y));
	}
}

function checkKeysDown(event:KeyboardEvent):void {
	keyArray[event.keyCode]=true;
}
function checkKeysUp(event:KeyboardEvent):void {
	keyArray[event.keyCode]=false;
}
function keyisdown(X:Number):Boolean {
	return keyArray[X];
}

Continue reading “How to make a platform engine in QuickBox2D”

Flash Tutorial #2 – The Basics of Actionscript 3.0

Hey there. I just finished up another tutorial about the basics of Actionscript 3.0 (AS3). The video is about 36 minutes long and covers a wide range of topics, including: variables, conditionals, operators, functions, events, and other general basic ideas in Actionscript 3.0 (and many other languages). By the way, I talk about all those pretty much in that order, slipping in little bits of data about other things as I progress through the video.

I also finally got around to submitting SpaceFlyer online, so the project page is now updated with a playable link to the game, or you can click here. I’ll be straight about this game, it isn’t really pretty, and it doesn’t exactly have a great story line, BUT there are some sweet mechanics!

Hope you enjoy them both
-Tom

Video Tutorial #1 – The Basics of Flash CS4

Flash LogoThe Basics of Flash

In this awesome tutorial, I cover the basics of Flash¬† CS4, I mean, the BASICS. This is probably as simple as it gets for you,¬† so, don’t count on other tutorials being this simple.

 

SO, this is the future of my website. I will probably be doing tutorials for… the rest of my life. I feel like I made a real connection here.

Nah. But I will be making more tutorials in the future that will cover Actionscript 3.0 ideas in Adobe Flash as well as other programming languages, such as C# (for XNA), and C++.