Saturday, February 11, 2012

How to make space shooter game with ActionScript 3 and FlashDevelop - part 2

Part 1
Now lets continue with our game. In the init function remove the hello world code and add this row:
startGame();

and right afrer the init function we will add startGame:
private function startGame():void {
 this.addEventListener(Event.ENTER_FRAME, gameLoop);
}
And now the game loop:
private function gameLoop(event:Event = null):void {
           
}

It is time to add the player. Lets make new folder called assets and add some images to it. For player spaceship I’ll use this cool image:

and for enemies this one:

You can use my images but please credit me.
Lets start with adding the player. More about embedding images you can learn from this post - FlashDevelop, ActionScript3 and images.
Add this in the class body:
[Embed(source="../assets/s1.png")]
private var playerShipImage:Class;
       
private var player:MovieClip;

And now alter the startGame function this way:
private function startGame():void {
   player = new MovieClip();
   var bitmap:Bitmap = new playerShipImage();
   bitmap.x = -bitmap.width / 2;
   bitmap.y = -bitmap.height / 2;
   player.addChild(bitmap);   
   player.x = 250;
   player.y = 430;
   addChild(player);
   this.addEventListener(Event.ENTER_FRAME, gameLoop);
  }
Compile and run! Here is the result:

And here is the full source code till now:
Main.as
package 
{
 import flash.display.*;
 import flash.events.*;
 
 
 
 public class Main extends Sprite 
 {
  
  [Embed(source="../assets/s1.png")]
  private var playerShipImage:Class;
  
  private var player:MovieClip;
  
  public function Main():void 
  {
   if (stage) init();
   else addEventListener(Event.ADDED_TO_STAGE, init);
  }
  
  private function init(e:Event = null):void 
  {
   removeEventListener(Event.ADDED_TO_STAGE, init);
   // entry point
   startGame();
  }
  
  private function startGame():void {
   player = new MovieClip();
   var bitmap:Bitmap = new playerShipImage();
   bitmap.x = -bitmap.width / 2;
   bitmap.y = -bitmap.height / 2;
   player.addChild(bitmap);   
   player.x = 250;
   player.y = 430;
   addChild(player);
   this.addEventListener(Event.ENTER_FRAME, gameLoop);
  }
  
  private function gameLoop(event:Event = null):void {
   
  }
  
 }
 
}
Part 1

FlashDevelop and ActionScript 3 - how to embed image - fast tip

When you use the official flash ide, using images is as easy as clicking several buttons. Actually using images with FlashDevelop is even easier but if you haven't done it you will need this info.
First copy the desired image into folder of the project, for example I'll name my folder assets.
Add a variable to your class:
private var myImg:Class;
And place your cursor on the row above it. Right mouse button on the image and select Generate Embed Code:


You will get something like this:

[Embed(source="../assets/s1.png")]
private var myImg:Class;

Add this where you want to use the image:

var bitmap:Bitmap = new myImg();
addChild(bitmap);

Easy, isn't it?

Wednesday, February 8, 2012

Typing Defense - free game for your website

Typing defense is fast paced typing game where you must defend your base from attacking enemy tanks.

You can play Typing Defense here.

Typing Defense Game Screenshot

Embed Code:


You can download the game swf - Typing Defense SWF. Right button and choose save as.

Thumb:


Tuesday, January 10, 2012

Get Cosmos Puzzle flash game free for your website

Cosmos Puzzle is relaxing match two game with space theme.
Get this game free for your website:
Cosmos Puzzle Game

Embed Code:


Download SWF: Cosmos Puzzle

Thumb:

Get Kawaii Bubble Shooter free for your website

Kawaii Bubble Shooter

Embed Code:


Download SWF: Kawaii Bubble Shooter

Thumb:

Saturday, January 7, 2012

Cute Cubes Collection - free game for your website

Get Cute Cubes Collection game free for your website:
Cute Cubes Collection game

Cute Cubes Collection game

Embed Code:


Download game swf: Cute Cubes Collection

Thumb:

Friday, December 23, 2011

A Story

I've made a game from my latest experiments with flixel. Flixel is really cool game library that I like more and more.
 After reading the post on mochi blog about making a retro plartformer with flixel I got inspired and now this is the result.
 The art isn't much but hey, don't expect cool art from a developer.
You can try the game on kongamato - A Story.
There are seven different levels made with Dame - by the way Dame is really cool editor once you learn to use it. You can get Dame free from its official site http://dambots.com/dame-editor/ and yea, the site is awful and my head hurts after a minute there. Till now I used Tile Studio by Mike Wiering. Actually the tiles in A Story a made with it but now I use Dame to make maps because its easier to integrate with flixel.
So the game has 7 levels - 4 with this grass land as you can see on the screenshot and 3 with lava tiles and theme. I get bored too fast when I make art or maps. I prefer to work on another game so this is a reason that I have hundreds of unfinished games.

Get A Story free for your website: