here the code of the game (Jeu - in french):
package cem {
import flash.display.MovieClip;
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.events.Event;
public class Jeu extends MovieClip {
private var _monJoueur: Joueur = new Joueur,
_horloge: Timer,
_delai: uint = 1000,
_conteneurMonstre: MovieClip = new MovieClip;
public function Jeu() {
// constructor code
addChild(_monJoueur);
addChild(_conteneurMonstre);
_monJoueur.x = 500;
_monJoueur.y = 450;
_horloge = new Timer(_delai);
_horloge.addEventListener(TimerEvent.TIMER, _creeMonstre);
_horloge.start();
}
private function _creeMonstre(e: TimerEvent){
var a:Monstre = new Monstre;
var b:Monstre = new Monstre;
var c:Monstre = new Monstre;
var d:Monstre = new Monstre;
var emplacementMonstreHaut: Array = ["178", "302", "426", "550", "674", "798", "922", "1046"];
var emplacementMonstreDroit: Array = ["118", "248", "372", "496", "620"];
var emplacementMonstreBas: Array = ["178", "302", "426", "550", "674", "798", "922", "1046"];
var emplacementMonstreGauche: Array = ["118", "248", "372", "496", "620"];
_conteneurMonstre.addChild(a);
_conteneurMonstre.addChild(b);
_conteneurMonstre.addChild(c);
_conteneurMonstre.addChild(d);
a.x = emplacementMonstreHaut[Math.floor(Math.random() * emplacementMonstreHaut.length)];
a.y = 0;
b.x = 1222;
b.y = emplacementMonstreDroit[Math.floor(Math.random() * emplacementMonstreDroit.length)];
c.x = emplacementMonstreBas[Math.floor(Math.random() * emplacementMonstreBas.length)];
c.y = 760;
d.x = -46;
d.y = emplacementMonstreGauche[Math.floor(Math.random() * emplacementMonstreGauche.length)];
}}}
here the code of the game (Game - in english):
My hierarchy is like : main folder - into the main folder iI have the fla.fla and a folder name cem - into cem iI have two as fils.as files one name: Jeu.as an the other name Monstre.as.
i code likeI use OOP for my school.
In my cem/Monstre.as code iI have nothing for the moment, but iI would like to put the mouvingmoving code in it.
Here the picture of my swf.swf (like the entierentire game)
theThe blue cerclecircle is my player and the blue squaresquares are all my monstermonsters. They pop each 1 sec. theyThey pick a value random value in the assignementassignment array (like for the monster a they pick inn the top array...) and they pop. Now iI only need to move it to the player, rotate it when they move or at the start (to face the player) andstopand stop it when they reach the player.