Worms-like destructible terrain in Flash – Part 3

After another truck of Aspirin, Jordi Sanglas Molist is back with the 3rd step of his Worms tutorial.

I’ve finished part 3. I almost got a headache. Forgive me if there are some mistakes, I wrote this post and the comments quickly.

Now the character is affected by the explosions. To do that, I added an horizontal speed and a friction. However, I don’t want the character to slide when I’m using the arrow keys, so:

* The arrow keys won’t use horizontal speed
* If the horizontal speed is different than 0 (an explosion is moving the character), I can’t use the arrow keys

To calculate the impulse, we will need to use trigonometry:

I’ve also solved another bug: if the character was falling (without using the space bar), it could jump in the air. Here I removed the jumping variable and I check if the character is on the ground.

Pay attention!!! Sometimes I check if the character is ON the ground (character.y+10) and sometimes I check if the character is TOUCHING the ground (character.y+9).

KNOWN BUGS:

* The horizontal speed won’t decrease faster or more slowly if the character is on a slope.
* The for loop isn’t exact when the horizontal speed is a decimal number (I think).

What should I do in the next part? I must do it before I start school, or I won’t have time.

While you think about the next part to request, here it is the script: Read more

Create Box2D levels in a quick with Bison Kick

Some time ago I published a Basic Box2D editor using Flash movieclips.

Now it’s time to show you something way more interesting called Bison Kick by Jacob Schatz who runs the blog jacobschatz.com (bookmark it! It contains a lot of useful information).

It’s an online Box2D editor with live preview.

Besides it’s still under development, with more options to be added and a few bugs to be removed, it’s very fun and simple to use.

I tried to design a level to be used in a game like Totem Destroyer and I managed to export it both in AS3:

//order: x , y , height, width, rotation, isDynamic, shape, friction,density,restitution,ID 
 var map:Array = [
[175,324,50,50,0,true,'SQUARE' , 1,0.5,0.5,'normal']
,[325,325,50,50,0,true,'SQUARE' , 1,0.5,0.5,'normal']
,[250,375,50,500,0,false,'SQUARE' , 1,0.5,0.5,'ground']
,[250,275,50,300,0,true,'SQUARE' , 1,0.5,0.5,'normal']
,[250,200,100,150,0,true,'SQUARE' , 1,0.5,0.5,'normal']
,[125,225,50,50,0,true,'SQUARE' , 1,2,0.5,'heavy']
,[250,125,50,50,0,true,'SQUARE' , 1,2,0.5,'heavy']
,[375,225,50,50,0,true,'SQUARE' , 1,2,0.5,'heavy']
,[250,50,100,50,0,true,'SQUARE' , 1,0.25,0.5,'totem']
];

and in XML: Read more

Create your own tween manager class in AS3

I publish this tutorial with the permission of Krasimir Tsonev, from Bulgaria, who runs krasimirtsonev.com (take a look at the light bulbs: don’t you think it can be done using a basic Box2D rope?). It’s an amazing tutorial with clean and well commented code that will guide you through the process of the creation of a custom tween manager class with AS3.

There are some features in Flash that we can’t work without. Tween classes are among the most used ones. They give you ability to animate objects without using the timeline, to change the animation fast and easy. The idea of these classes is very simple. That’s why I think that it is a good idea to have your own tween manager that you can modify to fit into your needs.

The basic structure of our tween manager:

1
2
3
4
5
6
7
8
9
10
11
package {
	import flash.display.MovieClip;
	public class TweenManager extends MovieClip {
		private var _objectToModify:Object;
		private var _properties:Object;
		public function TweenManager(objectToModify:Object, properties:Object) {
			_objectToModify = objectToModify;
			_properties = properties;
		}
	}
}

We are going to pass the object that we want to modify and the properties that we want to change. The idea is to create a function that calls every frame. All the magic will be done there. As you can see in the code below I created a public function – start, which adds listener for ENTER_FRAME event. So now we have a repeated method, i.e. loop. Read more

Worms-like destructible terrain in Flash – Part 2

After having some troubles with the email, I am finally able to post Jordi Sanglas Molist‘s second step of Worms-like destructible terrain in Flash.

Now the character can jump and move. I’ve also solved a bug: in the last script I checked a collision using the feet, so if the terrain was between both feet the character would fall.

Now, instead of using a hitTest between a BitmapData and a point I use a hitTest between a BitmapData and a Rectangle.

We have to check more collisions, so I used four rectangles:

* The rectangle below the character is used to check if the character must fall

* The rectangle above the character is used to check if the character hit the ground (while he was jumping)

* The rectangles at the sides are used to check if the character can move.

These rectangles aren’t as long as the character, they’re 17 pixels height instead of 20. That’s because, if the character wants to move left and the obstacle isn’t high enough (high enough to reach the rectangle), the character will be able to move. A similar strategy is used in “Create a flash draw game like line rider or others – part 5“, where a point (the knee point) is used to check if the character can move.

I renamed the function “fall”: now it’s “move_character”. I only commented the new lines. Now I’m working on part 3, but I still don’t know how to calculate the explosion impulse. I looked for some information, but now I’m thinking about maths (an explosion is a growing circle). Read more

Create a Flash racing game – Flex version

Hamilton Lombardi is a brazilian Flex programmer who decided to rewrite the code you can find in the original post for Flex 4.

Moreover he added a splash screen, as you can see:

The source code is clearly formatted and commented as you can see from Level class: Read more

Claytus Hood Tower Defense case study

I always loved games that revive an old concept with new features, and Claytus Hood Tower Defense is one of them.

Based on the old “tower defense” theme, it introduces new strategy options with large, scrollable maps and the capability to block some paths to make enemies take a larger route to attack you base.

Roux Raphaël, the author, shares with us his experience:

« Why did I decide to work on Claytus?

Before that, I used to be a developer for a web agency, coding online shops or institutional communication websites… not that fun!

After I lost my job at the end of 2009, I decided to increase my knowledges in AS3, to code funny stuff like games for example!

I always learnt programming by myself (the geekish way), with books, resources found on the web and personal experience…

I thus decided to read Keith Peters’ book “AS3 animation – Making Things Move” to fill my gaps in maths, and I saw lots of quite useful things to code games I had forgotten.

After reading this book, I managed to learn AI and Pathfinding, I thus studied A* algorithm.

Here are the examples I inspired myself of to learn A* :
http://www.remixtechnology.com/view/AStar-haXe.

Well, I reviewed trigonometry, I know A*, what can I do with it? A Tower Defense game! Let’s code! Read more

PHP face detection class

Face detection is a computer technology that determines the locations and sizes of human faces in arbitrary (digital) images.

It detects facial features and ignores anything else, such as buildings, trees and bodies.

(source: Wikipedia)

There is so much to say about face detection and all its algorithms… I am planning a step by step tutorial about every branch of object detection in digital images, but first I want to publish Maurice Svay‘s PHP class.

Maurice, in his blog svay.com, explains he was looking for a face detection script for PHP, but wasn’t able to find one working without OpenCV (Open Source Computer Vision), an opensource lib that was originally developed by Intel.

OpenCV seems to perform well but you need to be able to install it on your server.

So he coded his own pure PHP solution, that does not require any library to be installed on the server.

And, obviously, that can be easily ported into any language. His class itself has been translated from a javascript code that actually is no longer available online

So this is the class: Read more

Worms-like destructible terrain in Flash

Do you remember Worms game and its destructible terrain?

Jordi Sanglas Molist explains us how to create a basic destructible terrain with AS3

« Today, browsing the “most popular” posts, I found “Create a flash artillery game – step 1“, where you talked about making a game similar to Worms.

Then, I thought: “How will I make a destructible terrain?”

After looking for some information, I realized I should use a Bitmap. So I started with a really basic prototype:

- The character falls if he doesn’t touch the ground
- You can press at any point of the terrain to make a hole (because I don’t still have weapons)

The code is fully commented (and there are only 59 miserable lines), so you won’t have any problem to understand it.

I’ll be three days on holiday, so on Sunday I’ll start writing the next part, which I think it may talk about moving the character.

I think I’ll do it in that way: if you press the right arrow and in the right the obstacle is less than X
pixels height, you can move. I’ll try if that works. »

I am looking forward for character movement, meanwhile this is the script: Read more

Integrate Mochi games in your custom arcade website

Do you want to create your custom arcade website without using popular arcade scripts or WordPress plugins? Maybe with a Mochi integration?

That’s what Gabriel Bianconi did, and he wants to share his script with us.

It’s a simple, interesting script dedicated to all developers looking for a quick way to integrate Mochi games into their custom arcade sites.

« Hello. My name is Gabriel Bianconi. I’m a 16 years old Brazilian student and I’m interested in game and web development.
I’ve recently launched my first arcade website, PlugB.com. I decided to create my own script for two reasons: to improve my PHP skills and to have a more customizable website.

One of the features I integrated to my admin was the MochiAds ‘Post Game to my Site’ button. Since I add games manually (I don’t want to import all Mochi games), this saves me a lot of time.

When I tried to search about this feature, I realized that there is no tutorial about this online (at least, I couldn’t find one). I searched a little more and found a few scripts about this. Read more

Flash games and religion

I am used to see Flash educational games, but I don’t remember any Flash game based on religion.

And I don’t mean something like “you are God and must obliterate a village”, but a game entirely based on the Bible.

Now Gabriel Walter talks about Verse Vessel

« The working demo of Verse Vessel is ready now!

The idea now is to promote it and I’m open to suggestions as its a “casual-to-hardcore-rpg-word-matching-bible-game”, which is not the easiest “category” in the world to get across!

The technology used is mainly flash (css for text) because of its range of output for Pc, Mac, portable, and (most) browsers. It’s also the simplest to set up and export (no sdks).

But why did I select the bible? Before I explain here’s how I came up with the concept. Read more

Next Page →