Monday, May 11, 2009

Open Source AS3.0 Game Engine

You are definitely attracted with my post title, right? Well, as you probably already know Flanture delivers when promise is made.

Free Tetris ActionsScript 3.0 Game Engine is created by Richard Lord and his Big Room project. You can download the code from Google Code. Besides actual game engine you will get excellent KeyPoll class which is appropriate AS3.0 supplement for AS2.0 Key.isDown() functionality and user keyboard interaction.

 

Now everyone can make Tetris-like game Personal Edition. I hope I can learn a thing or two from reading the code, since AS3.0 isn’t my favorite snack [yet] ;)
Posted by flanture at 15:27:34 | Permalink | Comments (1) »

Thursday, February 19, 2009

Windmill rotation example

note: this post is sequel to previous ‘about rotation’ post.

To use rotation in real world examples I have to combine it with other functions. Simple example would be windmill Flash animation. I have two movie clips, pillar which is static and windmill hands. Second one must be precisely centered in the middle of the central circle, so rotation can be perfect.

Hands movie clip instance is named mc_hands. First, we will set some variables:

var fcounter:Number = 0;
var wind_speed:Number = 0;

Next, we will create onEnterFrame function to perform hands rotation as function of wind_speed.

wind_speed = change_wind_speed(wind_speed);      if ((wind_speed < 40)&&(wind_speed > -40)) {          mc_hands._rotation += wind_speed;   }else {             wind_speed = 0;             mc_hands._rotation += wind_speed;   }
We use if else conditional loop to limit wind_speed to some reasonable amount, between -40 and 40. Beyond this limits wind will be too strong for windmill to operate without risk. Next, we have to deal with change_wind_speed function.
function change_wind_speed(a:Number):Number {     fcounter += 1;

    // wind direction change    if ((fcounter % 100) == 0) {                // every 100 frames wind changes its direction and speed            bd = Math.random()*50-25;           da = Math.random()*5-2.5;           a = a + bd + da;            return a;   }else{              // small, per frame change   da = Math.random()*5-2.5;   a = a + da;                return a;   }}
We have created situation where every frame wind changes its speed in very small amount, variable da. Change is between -2.5 and 2.5. That’s not all. To make things more random and interesting, we have another bigger change on every 100th frame. That’s why we use fcounter variable to count frames and bd variable (big difference) to change wind speed amount between -25 and 25.

Windmill is ready to generate some clean energy.

 download windmill

Posted by flanture at 14:13:32 | Permalink | No Comments »

Monday, December 15, 2008

Background Packs and Tutorials

This is another post on Flash backgrounds after cool carbon backgrounds and quick examples. Tutorial on how to create custom Flash tiled backgrounds are published in two parts. Read them here:

After you learn how to create them, I’m sure very soon you’ll become proud owner of some great backgrounds pack and if you do, drop a comment about it. Tiled Flash backgrounds are useful in many occasions, as apps backgrounds, design elements or part of game interface graphics. Take a look at this wood backgrounds pack with 20 awesome ready to use tiles.

Posted by flanture at 19:36:50 | Permalink | No Comments »

Wednesday, June 11, 2008

Character elastic movement

Flash game characters doesn’t have to move only in standard way, press left arrow key to move left, right arrow key to move right, space to jump etc. In this new flash game, main character (hero) will move differently. Hero will be dragable and on click, he will perform elastic move. Start position and destination position will be symmetrical in relation to Stage center. Enemy can be destroyed only if mouse is not pressed, otherwise, hero health will decrease.

Now, code. First we import related classes:

import mx.transitions.Tween;
import mx.transitions.easing.*;

We need to define simple onPress, onReleaseOutside and onRelease methods for movie clip of our hero, mcHero. Method onRelease has two functions, findSimPoint() and doTween(). It is obvious that findSimPoint() calculates symmetrical point of hero x and y in relation to Stage center. DoTween(), well, performs the tween! Code comes with comments.
Download hero.fla

Posted by flanture at 14:48:03 | Permalink | No Comments »

Thursday, January 3, 2008

Flash Lite 3 enabled mobile phones


Flash Lite 3 Developers Edition is available for some time now for download. This is standalone player for testing SWF files published as Flash Lite 3. Some features are not available like wallpapers, screensavers, web browser. First phones with pre-installed player will be available in first quarter of 2008.

Now, FL3 DE has been downloaded and succesfully installed on these devices: N95, N95-NA, N93, N91, N80, E65, Nokia 6110 Navigator, E62, Nokia 6120c, Nokia 3250, E90, N75 (some issues), N82, E61. This list have been collected from Adobe Forums. If you installed on other device, tell us about it.

Did I mentioned that download is free, no need for IMEI number submitting?

Posted by flanture at 00:56:49 | Permalink | Comments (1) »

Tuesday, November 27, 2007

How to shuffle deck of cards

When making some Flash game there is sometimes need for Arrays manipulation. For example if you make game with cards, you want to find a way how to shuffle set of 52 cards. Let’s say your array is:

a = Array(“1h”, “2h”, …, “14h”, …, “14d”);

now, you can use next function to shuffle your cards array:

1.function shuffle( b:Array ) : Array{
2.     var temp:Array = new Array();
3.     var templen:Number;
4.     var take:Number;
5.     while (b.length > 0) {
6.         take = Math.floor(Math.random()*b.length);
7.         templen = temp.push(b[take]);
8.         b.splice(take,1);
9.     }
10.   return temp;
11.}

What this code means? I hope it is clear I only have to explain lines in while loop, because everything else is easy to understand. So, while loop will work until there are elements in start array, and do remember that we take one element from that array in every pass. With line 6 we choose randomly one element of start array. Then in 7, we push that element in first empty place in result array and than in line 8, we exclude same element from start array. In every while loop pass, start array is shorter for 1 element and result array is longer for 1 element. Since we choose element randomly in the end function returns shuffled array. Simply as that.

You can test this function with this code:

trace(a);
trace(a.length);

function onMouseUp() {
    var c:Array = new Array();
    c = shuffle(a);
    trace(c);
}

Download this function and few more here.
Enjoy!

Posted by flanture at 02:21:34 | Permalink | No Comments »

Wednesday, November 21, 2007

Charles Darwin’s Beagle

Recently I spent several hours traveling by bus, without any source of fun except my Nokia mobile phone. I realized that I have to do something about it for such future trips. I enjoy reading, but carrying books around is not always an option.

Solution is mobile book or mBook, which is small Flash lite file I can transfer to my mobile phone. There are limitations, I know, but I’m not looking for perfection just something that can do the trick.

Check out my example - Charles Darwin’s The Voyage of the Beagle preface. download here.

File is only 9 kb and has 14 pages. File dimensions are 176 x 208. First screen is “jump page” where you can enter page number where you wanna start reading. Press right button, then OK and enter number of page and then number 5 for jump. Navigation is done by pressing buttons up and down.

Now this mBook is just small experiment, but it allows any text book to be converted in a form that is suitable for reading on mobile devices that supports Flash Player. So, what should I read next?

Posted by flanture at 03:20:27 | Permalink | No Comments »

Saturday, June 23, 2007

Small update

Small update to Sparta Defender, now v0.13. First, I added points won movie clip that let’s you know if you killed Persian shield or you missed it. Second, I introduced time limit. Now you have 3 minutes to kill 300 points or 60 Persians or Sparta fill fall.

Download Sparta Defender v0.13

Posted by flanture at 18:39:32 | Permalink | No Comments »

Wednesday, June 20, 2007

Sparta Defender v0.11

My simple “space shooter” v0.8 surprized me few days ago by becoming “Sparta defender” v0.11 ! I have changed main character and enemies, added background and solved timeline issue.

You have to move mouse left and right and destroy all those Persians as soon as possible. At start they come to you slowly, but their speed is changing fast. You goal is to get 300 points.

Game has 56 lines of code. I have been using code I wrote earlier for main character and you can read that post here .

Download game swf and source code Sparta .

If you have any question about code, please feel free to ask.
Enjoy !

Posted by flanture at 22:50:34 | Permalink | No Comments »

Thursday, June 14, 2007

Emanuele Feronato rocks !

 

Emanuele Feronato and his website really rocks. For every Flash Game Developer wannabe this is never ending source of useful informations about making games in Flash. More suitable for beginers, but well explained, code everywhere , samples and stuff.

 

I wish I could have more free time to explore it more. Nice work Emanuele !

Posted by flanture at 15:48:54 | Permalink | No Comments »