A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Dice Game: Can you move the player

  1. #1
    Junior Member
    Join Date
    Nov 2014
    Posts
    2

    Dice Game: Can you move the player

    Using Actionscript 3, How does a player move based on dice result?
    I'm developing a game that is based on the popular snake and ladder game as my undergraduate project. It has 36 tiles. Thus far, I'm able to roll the dice but needs the player to move with dice result. I appreciate help. Here is code:

    Code:
    package{
    
    
    
        import flash.display.*;
    
        import flash.events.*;
    
        import flash.text.*;
    
    
    
        public class peaconty extends MovieClip{
    
    
    
            //variables
    
            public var rollBtn;
    
            public var dieMov;
    
            public var boardMov;
    
            public var textResult;
    
    
    
            public function peaconty() :void{
    
                rollBtn.addEventListener(MouseEvent.CLICK, rollRandomNumber);
    
                dieMov.gotoAndStop(Math.ceil(Math.random() * 6));
    
                boardMov.gotoAndStop(Math.ceil(Math.random() * 6));
    
            }
    
    
    
            function rollRandomNumber(Event:MouseEvent) :void{
    
                //trace(randNumb);
    
                var randNumb:uint = Math.ceil(Math.random() * 6);
    
                textResult.text = "You rolled "+randNumb;
    
    
    
                dieMov.gotoAndStop(randNumb);
    
                boardMov.gotoAndStop((currentFrame) +(randNumb));
    
        }
    
    }
    
    }

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    You need to have the grid set up for referencing the locations to move toward/from ( the base basically).
    Have a look at this and rip the bones out of it, you might need to do some simply as2 > as3 conversion though, I'm sure it will help, I personally don't have the time and it is after all YOUR undergraduate project

    http://www.flashkit.com/movies/Games...0889/index.php

  3. #3
    Junior Member
    Join Date
    Nov 2014
    Posts
    2
    Thanks for this. So many fruits on the bread. It will prove helpful. Now I must learn AS2 and AS3. LOL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center