Friday, November 13, 2009

Action Script

I got the coding from here.
I am going to use coding for the Hero, keys to move, shoot the enemy and the map format. It's kind of hard to understand. But I'm learning :)


for example, codes for the map
is

myMap = [
[1, 1, 1, 1, 1, 1, 1, 1],
[1, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 1, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 1, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 1],
[1, 1, 1, 1, 1, 1, 1, 1]
];

Shoot:

For creating the bullets and giving bullets all the data they need for successful deadly flights, we will use new function called "shoot":

function shoot (ob) {
ob.lastshot=getTimer();
game.bulletcounter++;
if (game.bulletcounter>100) {
game.bulletcounter=0; }
var name = "bullet"+game.bulletcounter;
game[name]= new game.Bullet; game[name].id=game.bulletcounter; game.bullets.push(game[name]);
if (ob.dirx or ob.diry) {
game[name].dirx= ob.dirx;
game[name].diry= ob.diry;
}
game[name].xtile= ob.xtile;
game[name].ytile= ob.ytile;
game.clip.attachMovie("bullet", name, 10100+game.bulletcounter); game[name].clip=game.clip[name];
game[name].x = (ob.x+game[name].dirx*ob.width);
game[name].y = (ob.y+game[name].diry*ob.height);
game.clip[name]._x = game[name].x;
game.clip[name]._y = game[name].y;
}

1 comment:

  1. Ninja Vampire, Very cool concept and reviews
    The work is very versatile, with so many concentrations intermingling
    Ninja Gear

    ReplyDelete