Programming enemies

Programming enemies

開發者 CoolioJulio
舉報問題
舉報遊戲
Loading ad...

Programming enemies

評分:
2.2
推出: May 18, 2009
最後更新: May 18, 2009
開發者: CoolioJulio

Programming enemies 的標籤

遊戲簡介

Learn how to make a simple enemy that roams around the screen.

玩法說明

Arrow keys to move the main spaceship!

開發者更新

May 18, 2009 8:27am

Here is the code to paste in the enemy0:
onClipEvent(load)
{
function reset()
{
var timer = 12;
this.y = Math.random() * 300
this.x = 550
mySpeed = Math.ceil(Math.random() * 6) + 1;
}
reset();
}
onClipEvent(enterFrame)
{
//in every frame the enemy move left in the speed defined in the reset function.
this.x -= mySpeed;
if (this.
x < -10)
{
//if the enemy is not on the screen, we reset it.
reset();
}
//if our timer is bigger than 12 we get a new
if (timer >= 12)
{
//direction to the Ship.
var dir = Math.ceil(Math.random() * 2)
//We get a random number, 1 or 2. 1 is up, 2 is down.
//Then we set timer to 0, so we only get a new dir when timer is bigger than 12
timer = 0;
}
if (dir == 1)
{
//if dir = 1, we move the ship up.
this.
y -= 3;
} else if(dir == 2)
{
//if dir = 2, we move the ship down.
this.
y = 3;
}
//increase timer by 1, so the timer gets equal to 12 and we get a new direction.
timer
+
}

This is the code to paste in the main timeline:
var nrEnemies = 3;
for (i = 1; i < nrEnemies; i++)
{
_root.Enemy.duplicateMovieClip(“Enemy” + i, _root.getNextHighestDepth());
}

留言

0/1000
SamTheGod avatar

SamTheGod

Dec. 19, 2014

1
1

OMGMGGMGGMMGGMGMGMGMGMGM SOOOOOOOOO PROOOOOO

motionman avatar

motionman

Sep. 02, 2009

0
1

very handy

bugalugs avatar

bugalugs

Jun. 21, 2009

0
1

It dusnt work!

CoolioJulio avatar

CoolioJulio

May. 18, 2009

0
1

This is definitely no where the same as kongregate's shootorials.

linc98 avatar

linc98

May. 18, 2009

0
1

(not really love its a joke)