Skip to main content
deleted 1839 characters in body; edited tags
Source Link
Vaillancourt
  • 16.4k
  • 17
  • 56
  • 61

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.

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 i have the fla and a folder name cem - into cem i have two as fils one name: Jeu.as an the other name Monstre.as

i code like OOP for my school.

In my cem/Monstre.as code i have nothing for the moment, but i would like to put the mouving code in it.

Here the picture of my swf (like the entier game)

the blue cercle is my player and the blue square are all my monster. They pop each 1 sec. they pick a value random in the assignement array (like for the monster a they pick inn the top array...) and they pop. Now i only need to move it to the player rotate it when they move or at the start (to face the player) andstop it when they reach the player.

here the code of the game (Game - in english):

My hierarchy is like: main folder - into the main folder I have the .fla and a folder name cem - into cem I have two .as files one name: Jeu.as an the other name Monstre.as.

I use OOP for my school.

In my cem/Monstre.as code I have nothing for the moment, but I would like to put the moving code in it.

Here the picture of my .swf (like the entire game)

The blue circle is my player and the blue squares are all my monsters. They pop each 1 sec. They pick a random value in the assignment array (like for the monster a they pick inn the top array...) and they pop. Now I only need to move it to the player, rotate it when they move or at the start (to face the player) and stop it when they reach the player.

Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Tweeted twitter.com/StackGameDev/status/1193589269866176512
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user