lundi 22 juin 2015

Action Script 3 Moving Between Randomized Rooms And Knowing Where You've Already Been

Ok, I'm new to Action Script and Flash so there could be a basic answer, but doubtful. I'm trying to create a Rogue Like type game in the flash program. This is my first real game I have tried to create. I have created a singular room with randomized blocks places around in it and a player that can shoot arrows. I'm going for something similar to The Binding Of Issac. The problem is I have searched the internet and no one seems to have a proper tutorial on how to go between levels/rooms and be able to go back to a previous room with all the enemies dead. If you need any more info then tell me. I just started with actionscript so my code is most likely in the worst possible way so sorry I just kinda learn by doing.

This is my room class which just pretty much puts down the blocks, wall, player randomly. The Constants class just has vars that are referencing the name they say like playerRef. Also I do my collision testing on my Player class so if you want to see that tell me.

package {
    import flash.display.MovieClip;

    public class Room extends MovieClip{
        var box:Box;
        var boxes:Array;
        var onTop:Boolean;
        private var player:Player;
        private var walls:Walls;
        private var blocker1:Blocker;
        private var blocker2:Blocker;
        private var blocker3:Blocker;
        private var blocker4:Blocker;
        private var arrowImage:ArrowSymbol;

        public function Room(){
            addEventListener(Event.ENTER_FRAME, update);
        function init(){
            player = new Player();
            //add walls 

            blocker1 = new Blocker();
            blocker1.x = 350;
            blocker1.y = 1;

            blocker2 = new Blocker();
            blocker2.x = 350;
            blocker2.y = 619;

            Constants.blockerRef1 = blocker1;
            Constants.blockerRef2 = blocker2;
            //add player

            player.x = 300;
            player.y = 200;

            arrowImage = new ArrowSymbol();
            arrowImage.x = 630;
            arrowImage.y = 30;


            box = new Box();
            boxes = new Array();
            onTop = false;

        function update(e:Event){
                //this will be where i want to change rooms

        public function createWalls(){
            walls = new Walls();


        function addRandomBlocks(){
            for(var e=0; e <Math.random() * 10; e++){
                box = new Box();
                box.x = Math.random() * (615 - 100) + 100;
                box.y = Math.random() * (500 - 120) + 120;

                //colision for block to block
                for(var col = 0; col < boxes.length; col++){
                        onTop = true;
                if(onTop == false){

Aucun commentaire:

Enregistrer un commentaire