Help with a hunt the wumpus game

I accidently posted this question on the wrong section so i'm posting it again here.
i'm trying to write the hunt the wumpus game with simple conditions: (check-marked the ones i already accomplished)
[x]the pits will be placed randomly
[x] the wumpus is placed in the maze randomly (not sure if i did that one correctly)
[x] the player starts on the lower left of the maze row 3 col 0
-the player will only have 1 chance to shoot the Wumpus
[x]if the player is close to the Wumpus then there would be a prompt saying there is stench around
[x]if the player is close to a pit then she/he will be prompted that there is a breeze.
-if the player falls in a pit or gets eaten by the wumpus the game will be over and the map of the maze will be shown. I used 0 for empty cells and p for pits and w for wumpus in the array.
There is some problem with the program i've written so far but i don't know how to fix it. also, i don't know how to check if the wumpus will be in the direction the player wants to shoot. i'd appreciate any suggestions
import java.util.*;
public class playWumpus
    //initMaze METHOD
    //put the pits and wumpus into the world
    public static void initMaze(char [][] maze)
        Random r = new Random();
        for (int row = 0; row <4; row ++)
            maze[row][col] = '0';    <<<<<<there is a problem here: col cannot be resolved
        int pitRow, pitCol;
        for (int pitNum = 0; pitNum <4; pitNum++)
            pitRow = r.nextInt(4); //randomly choose row
            pitCol = r.nextInt(6); //randomly choose column
            if (pitRow == 3 && pitCol == 0)//start location
                pitCol=5;
        maze [pitRow][pitCol] = 'p'; //places the pits in the maze randomly
        maze [r.nextInt(4)][r.nextInt(6)] = 'w'; //places the wumpus randomly in the maze
    }// end of Maze method
    //CHECKMOVE method
    //possible outcomes: run into the wall , fall into the pit, eaten by wumpus,
    //feel breeze, smell stench, nothing.
    public static int checkMove(char [] [] maze, int newRow, int newCol)
        //checks if they run into a wall
        if (newRow<0 || newRow>3 || newCol<0 || newCol>5)
            System.out.println("You hit a wall");
            return 0;
            // it will return to the main method and places 0 in the state variable
        else if (maze[newRow][newCol] == 'p') 
        //this checks the maze if there is a P in that location
            System.out.println("You fall into a pit");
            return 2;
            // it will return to the main method and places 2 in the state variable
        else if (maze[newRow][newCol] == 'w')//checks for the wumpus
            System.out.println("You've eaten by the Wumpus!!");
        //checks for the breeze (right,left,down,up)   //<<is the following if-statement correct?>>>
        if (
            (newCol>0 && maze[newRow][newCol-1] == 'p') ||
            (newCol<5 && maze[newRow][newCol+1] =='p') ||
            (newRow>0 && maze[newCol][newRow-1] == 'p') ||
            (newRow<3 && maze[newCol][newRow+1] =='p')
            System.out.println("You feel a breeze");
        return 1;
    }//end of the maze method
    public static void main(String [ ] args)
        char [ ] [ ] maze = new char [4][6]; //the actual map of the game
        int playerRow=3, playerCol=0;  // player location aka lat/long
        Scanner in= new Scanner(System.in);   //<<there is something wrong with my scanner:The method nextInt(int) in the type Scanner is not applicable for the arguments (InputStream)>>>
        int move, state;
        // state of the game
        // state   0= illegal move, 1= legal move, 3= end game
        initMaze (maze); // calling the initMaze method
        do
            System.out.println("What would you like to do? 1=up, 2=down, 3=right 4=left, 5=shoot");
            move = in.nextInt(System.in);   //<<eclipse is telling me that the type is incorrect>>
            if (move ==1) // move up in the world
                state = checkMove(maze, playerRow-1,playerCol); //these are coordinates
                if ( state >0 ) // legal move
                    playerRow = playerRow-1;
            if (move ==2) // move down in the world
                state = checkMove(maze, playerRow+1,playerCol);
                if ( state >0 ) // legal move
                    playerRow = playerRow+1;
            if (move ==3) // move right in the world
                state = checkMove(maze, playerRow,playerCol+1);
                if ( state >0 ) // legal move
                    playerCol = playerCol+1;
            if (move ==4) // move left in the world
                state = checkMove(maze, playerRow,playerCol-1);
                if ( state >0 ) // legal move
                    playerRow = playerCol-1;
            if (move == 5) // shoot the wumpus in the world
                System.out.println("Which direction would you like to shoot? 1=up, 2=down, 3=right, 4=left");
                int shootDir = in.nextInt(System.in);
                // check if the wumpus gets killed
                if (  shootDir == 1 )  //<<not sure on how to check if the dir they are shooting has the wumpus in there>>
                    System.out.println("You shot the Wumpus!");
        }while (state!=2);
    }//end of main
}//end of class

here is the whole code just in case you guys want to see it...yes i know it looks primitive to you experts but hey i can follow and understand what i've written and that's what matters ^.~))V
import java.util.*;
public class playWumpus
     //initMaze METHOD
     //put the pits and wumpus into the world
     public static void initMaze(char [][] maze)
          Random r = new Random();
          for (int row = 0; row <4; row ++)
            for (int col = 0; col<6; col ++)
                maze[row][col] = '0';             
          int pitRow, pitCol;
          for (int pitNum = 0; pitNum <4; pitNum++)
               pitRow = r.nextInt(4); //randomly choose row
               pitCol = r.nextInt(6); //randomly choose column
               if (pitRow == 3 && pitCol == 0)//start location
                    pitCol=5;
               maze [pitRow][pitCol] = 'p'; //places the pits in the maze randomly
          int wumpusRow = r.nextInt(4);
          int wumpusCol = r.nextInt(6);
          maze [wumpusRow][wumpusCol] = 'w'; //places the wumpus randomly in the maze
     }// end of Maze method
     //CHECKMOVE method
     //possible outcomes: run into the wall , fall into the pit, eaten by wumpus,
     //feel breeze, smell stench, nothing.
     public static int checkMove(char [] [] maze, int newRow, int newCol)
          //checks if they run into a wall
          if (newRow<0 || newRow>3 || newCol<0 || newCol>5)
               System.out.println("You hit a wall");
               return 0;
               // it will return to the main method and places 0 in the state variable
          //this checks the maze if there is a pit in that location
          else if (maze[newRow][newCol] == 'p') 
               System.out.println("You fall into a pit. You lose!");
               return 2;
          //checks for the wumpus
          else if (maze[newRow][newCol] == 'w')
               System.out.println("You've been eaten by the Wumpus. You lose!!");
               return 2;
          //checks for the breeze (right,left,down,up)
          if (
               (newCol>0 && maze[newRow][newCol-1] == 'p') ||
               (newCol<5 && maze[newRow][newCol+1] =='p') ||
               (newRow>0 && maze[newCol][newRow-1] == 'p') ||
               (newRow<3 && maze[newCol][newRow+1] =='p')
               System.out.println("You feel a breeze");
          //checks for the wumpus' stench
          else if (
                    (newCol>0 && maze[newRow][newCol-1] == 'w') ||
                    (newCol<5 && maze[newRow][newCol+1] =='w') ||
                    (newRow>0 && maze[newCol][newRow-1] == 'w') ||
                    (newRow<3 && maze[newCol][newRow+1] =='w')
                    System.out.println("Something smells!!");
                    return 1;
          else
               System.out.println("Nothing happens.");
               return 1;
          return 1;
     }//end of the maze method
     public static void main(String [ ] args)
          char [][] maze = new char [4][6]; //the actual map of the game
          int playerRow=3, playerCol=0;  // player location
          Scanner in= new Scanner(System.in);
          int move;
          int state = 1;
          // state of the game
          // state   0= illegal move, 1= legal move, 3= end game
          initMaze (maze); // calling the initMaze method
          do
               System.out.println("What would you like to do? 1=up, 2=down, 3=right 4=left, 5=shoot");
               move = in.nextInt();
               if (move ==1) // move up in the world
                    state = checkMove(maze, playerRow-1,playerCol); //these are coordinates
                    if ( state > 0 ) // legal move
                         playerRow = playerRow-1;
               if (move ==2) // move down in the world
                    state = checkMove(maze, playerRow+1,playerCol);
                    if ( state >0 ) // legal move
                         playerRow = playerRow+1;
               if (move ==3) // move right in the world
                    state = checkMove(maze, playerRow,playerCol+1);
                    if ( state > 0 ) // legal move
                         playerCol = playerCol+1;
               if (move ==4) // move left in the world
                    state = checkMove(maze, playerRow,playerCol-1);
                    if ( state >0 ) // legal move
                         playerCol = playerCol-1;
               if (move == 5) // shoot the wumpus in the world
                    System.out.println("Which direction would you like to shoot? 1=up 2=down 3=right 4=left");
                    int shootDir = in.nextInt();
                    if (shootDir==1 && playerRow>0)
                         if (maze[playerRow-1][playerCol] == 'w')
                              System.out.println("You shot the Wumpus!");break;
                         else
                              System.out.println("You missed! You lose!");break;
                    else if(shootDir==2 && playerRow<3)
                         if (maze[playerRow+1][playerCol] == 'w')
                              System.out.println("You shot the Wumpus!");break;
                         else
                              System.out.println("You missed! You lose!");break;
                    else if (shootDir==3 && playerCol<5)
                         if (maze[playerRow][playerCol+1] == 'w')
                              System.out.println("You shot the Wumpus!");break;
                         else
                              System.out.println("You missed! You lose!");break;
                    else if (shootDir==4 && playerCol>0)
                         if (maze[playerRow][playerCol-1] == 'w')
                              System.out.println("You shot the Wumpus!");break;
                         else
                              System.out.println("You missed! You lose!");break;
          }while (state!=2);
          //shows the user the map of the maze if he/she gets eaten or falls in a pit
               for(int row=0;row<4;row++,System.out.println())
                    for(int col=0;col<6;col++)
                         String loc = ""+maze[row][col];
                         loc += ((row == playerRow) && (col == playerCol)) ? "*" : "";
                         System.out.print(loc+"\t");
     }//end of main
}//end of class

Similar Messages

  • I need help: hunt the wumpus game

    i'm trying to write the hunt the wumpus game with simple conditions: (check-marked the ones i already accomplished)
    [x]the pits will be placed randomly
    [x] the wumpus is placed in the maze randomly (not sure if i did that one correctly)
    [x] the player starts on the lower left of the maze row 3 col 0
    -the player will only have 1 chance to shoot the Wumpus
    [x]if the player is close to the Wumpus then there would be a prompt saying there is stench around
    [x]if the player is close to a pit then she/he will be prompted that there is a breeze.
    -if the player falls in a pit or gets eaten by the wumpus the game will be over and the map of the maze will be shown. I used 0 for empty cells and p for pits and w for wumpus in the array.
    There is some problem with the program i've written so far but i don't know how to fix it. also, i don't know how to check if the wumpus will be in the direction the player wants to shoot. i'd appreciate any suggestions
    import java.util.*;
    public class playWumpus
        //initMaze METHOD
        //put the pits and wumpus into the world
        public static void initMaze(char [][] maze)
            Random r = new Random();
            for (int row = 0; row <4; row ++)
                maze[row][col] = '0';    <<<<<<there is a problem here: col cannot be resolved
            int pitRow, pitCol;
            for (int pitNum = 0; pitNum <4; pitNum++)
                pitRow = r.nextInt(4); //randomly choose row
                pitCol = r.nextInt(6); //randomly choose column
                if (pitRow == 3 && pitCol == 0)//start location
                    pitCol=5;
            maze [pitRow][pitCol] = 'p'; //places the pits in the maze randomly
            maze [r.nextInt(4)][r.nextInt(6)] = 'w'; //places the wumpus randomly in the maze
        }// end of Maze method
        //CHECKMOVE method
        //possible outcomes: run into the wall , fall into the pit, eaten by wumpus,
        //feel breeze, smell stench, nothing.
        public static int checkMove(char [] [] maze, int newRow, int newCol)
            //checks if they run into a wall
            if (newRow<0 || newRow>3 || newCol<0 || newCol>5)
                System.out.println("You hit a wall");
                return 0;
                // it will return to the main method and places 0 in the state variable
            else if (maze[newRow][newCol] == 'p') 
            //this checks the maze if there is a P in that location
                System.out.println("You fall into a pit");
                return 2;
                // it will return to the main method and places 2 in the state variable
            else if (maze[newRow][newCol] == 'w')//checks for the wumpus
                System.out.println("You've eaten by the Wumpus!!");
            //checks for the breeze (right,left,down,up)   //<<is the following if-statement correct?>>>
            if (
                (newCol>0 && maze[newRow][newCol-1] == 'p') ||
                (newCol<5 && maze[newRow][newCol+1] =='p') ||
                (newRow>0 && maze[newCol][newRow-1] == 'p') ||
                (newRow<3 && maze[newCol][newRow+1] =='p')
                System.out.println("You feel a breeze");
            return 1;
        }//end of the maze method
        public static void main(String [ ] args)
            char [ ] [ ] maze = new char [4][6]; //the actual map of the game
            int playerRow=3, playerCol=0;  // player location aka lat/long
            Scanner in= new Scanner(System.in);   //<<there is something wrong with my scanner:The method nextInt(int) in the type Scanner is not applicable for the arguments (InputStream)>>>
            int move, state;
            // state of the game
            // state   0= illegal move, 1= legal move, 3= end game
            initMaze (maze); // calling the initMaze method
            do
                System.out.println("What would you like to do? 1=up, 2=down, 3=right 4=left, 5=shoot");
                move = in.nextInt(System.in);   //<<eclipse is telling me that the type is incorrect>>
                if (move ==1) // move up in the world
                    state = checkMove(maze, playerRow-1,playerCol); //these are coordinates
                    if ( state >0 ) // legal move
                        playerRow = playerRow-1;
                if (move ==2) // move down in the world
                    state = checkMove(maze, playerRow+1,playerCol);
                    if ( state >0 ) // legal move
                        playerRow = playerRow+1;
                if (move ==3) // move right in the world
                    state = checkMove(maze, playerRow,playerCol+1);
                    if ( state >0 ) // legal move
                        playerCol = playerCol+1;
                if (move ==4) // move left in the world
                    state = checkMove(maze, playerRow,playerCol-1);
                    if ( state >0 ) // legal move
                        playerRow = playerCol-1;
                if (move == 5) // shoot the wumpus in the world
                    System.out.println("Which direction would you like to shoot? 1=up, 2=down, 3=right, 4=left");
                    int shootDir = in.nextInt(System.in);
                    // check if the wumpus gets killed
                    if (  shootDir == 1 )  //<<not sure on how to check if the dir they are shooting has the wumpus in there>>
                        System.out.println("You shot the Wumpus!");
            }while (state!=2);
        }//end of main
    }//end of class

    First you need to fix some basic errors:
    1)
    move = in.nextInt(System.in);   Should be:
    move = in.nextInt();   2) You have to initialize some of your vairables like pitRow, pitCol, and col...maybe more...
    3) As for your 'col' variable you need to implement not only the rows but columns as well. Maybe you could do something like this:
    for (int row = 0; row <4; row ++)
                 for(int col = 0; col < 4; col ++)
                maze[row][col] = '0';   // <<<<<<there is a problem here: col cannot be resolved
            }Hope this helps.

  • Hunt the Wumpus

    Hey, I'm pretty new to Java (since September actually) and have been give this assignment in school to create the game, Hunt the Wumpus. Honestly I have no idea of where to start with this. Can anyone lead me in the right direction. Thanks. Below are the instructions that were given to do this.
    Backstory
    The first programming assignment for the course CPS 109 Computer Science I is to implement a real dinosaur and the original grandfather of our modern computer games, Hunt the Wumpus. Despite being rather lame by today's gaming standards, this game is hopefully an educational topic to serve as your first programming project.
    Wumpus is a game played on a maze which for our purposes is a rectangular grid of rooms. From each room it is possible to move to any of the adjacent rooms in north, west, south and east, unless you are at the edge of the grid to that direction. The maze is dark, so in each room you can see only that room, but you can't see through the doors what the adjacent rooms might contain.
    You are a brave explorer armed with a bow and a quiver of arrow to search the maze for the pile of gold that is rumored to be hidden in one of the rooms. You enter the maze at the entrance room at the coordinates (1,1), and win the game if you successfully find the gold and manage to return to the same entrance alive. If you enter the room where the pile of gold is located, you automatically pick it up.
    Beware, though, since the maze is also a home for the mythical monster known as the Wumpus! Wumpus is rather stupid and bestial and pretty much just moves randomly around the maze. If you and Wumpus happen to meet at the same room, game is over for you, since you are no match for the Wumpus in close quarters combat. Your only chance of survival is to either avoid the Wumpus or to kill him with a well-aimed shot from your trusty bow.
    To shoot, pick any of the four directions and hope for the best. When you shoot, your arrow will fly through three rooms to that direction and then hit the stone floor, shattering to useless shards. If the Wumpus happens to be in any of those three rooms on the path of the arrow, he is hit and he dies.
    Classes and methods to write
    In this project, you need to write two classes called WumpusGrid and WumpusGame. The first class simulates the Wumpus world, while the second class implements the interface. The class WumpusGrid should have whatever private fields and methods you need, and the following public methods:
    void startNewGame(int width, int height, int arrows)
    Starts a new game and initializes the grid to the given width and height so that the player is in the room (1,1) and carries arrows arrows. Wumpus and the pile of gold are placed in random rooms in the grid, but not in the room (1,1).
    boolean isGameOn()
    Returns true if the player has not yet died or successfully completed his task, otherwise returns false.
    int getArrowCount()
    Returns the number of arrows that the player is currently carrying in his quiver.
    boolean isCarryingGold()
    Returns true or false depending on whether player is currently carrying the gold.
    int getX()
    Returns the x-coordinate of the room that the player is currently in.
    int getY()
    Returns the y-coordinate of the room that the player is currently in.
    String moveWumpus()
    If Wumpus is alive, moves the Wumpus from the room that he is currently in to a randomly chosen adjacent room in one of the four directions. This method returns a message string:
    If Wumpus moves to the same room as the player, the game ends and the message is �The Wumpus eats you!�
    If the Manhattan distance (find out yourself what this is) between Wumpus and player is one, the message is �You can smell the putrid breath of the Wumpus!�
    If the Manhattan distance between Wumpus and player is two, the message is �You can hear the Wumpus slouching nearby!�
    If the Manhattan distance between Wumpus and player is three, the message is �You can sense the Wumpus lurking nearby!�
    String movePlayer(int dx, int dy)
    Moves the player from his current room (x,y) to the adjoining room (x+dx, y+dy), unless that move would take him outside the grid, or it is not the case that one of the parameters is zero while the other is -1 or +1. The method returns a message string:
    If the player moves to the same room as the living Wumpus, the game ends and the message is �The Wumpus catches you and dismembers you!�
    If the player moves to the same room as the dead Wumpus, the message is �The carcass of the Wumpus lies on the ground.�
    If the player moves to a room that has the pile of gold in it, he picks it up and the message is �You have found the treasure that you are looking for!�
    If the player is carrying the gold and moves to the room (1,1) so that Wumpus is not there, the game ends and the message is �You survived to bring the gold back home and live rich and happy for the rest of your life!�
    Otherwise, the message is �This room is dark and empty.�
    String shootArrow(int dx, int dy)
    Shoots one arrow to the direction specified by dx and dy, as in the previous method. The method returns a message string:
    If the player has no arrows left, the message is �You want to shoot, but your quiver is empty!�
    If the player shoots and hits nothing, the message is �The arrow flies into the darkness.�
    If the player shoots and hits the Wumpus, the Wumpus dies and the message is �You hear the Wumpus scream horribly and then collapse to the ground!�
    The class WumpusGame allows the human user to play this game over a textual console interface. This game should proceed in turns so that each turn, the game outputs the current coordinates of the player and the number of arrows in his quiver, and asks him what he wants to do. The possible answers are either �n�, �e�, �s�, �w� to move to the given direction, �sn�, �se�, �ss�, �sw� to shoot an arrow to the given direction, or �q� to quit the game. The message that the action produces is shown to the player, and then it is Wumpus's turn to move. This is repeated until the player either dies, quits or wins the game. Whatever way the game ends, the program should ask the player if he wants to play a new game, and exit if he answers no.
    The class WumpusGame must have the main method for the game to run as a standalone application, and whatever other methods you wish to put there to implement the game functionality of the previous paragraph.
    If you want to, you can also write a class Position that stores a pair of (x,y) coordinates, with methods to calculate the position to a given direction, and use objects of this class to represent and store the positions of player, Wumpus and gold.

    Thanks very much for telling me how to post a question. As you know I'm new here, so I don't know the procedure of things around here. I know how to create an interface, but I was wondering if I'm going about this wrong. This is just what I have to make the "player" on the game interface.
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.geom.Ellipse2D;
    import javax.swing.JPanel;
    import javax.swing.JComponent;
    public class WumpusGrid extends JComponent
        //Creates the explorer the player is going to use.
        public void paintComponent(Graphics g)
            //Recover Graphics2D
            Graphics2D g2 = (Graphics2D) g;           
            //Draws the brave explorer.
            Ellipse2D.Double man = new Ellipse2D.Double(1,1,5,5);
            g2.setColor(Color.RED);
            g2.fill(man);
    }This is what I have for the game interface.
    import javax.swing.JFrame;
    public class WumpusGame
        public static void main(String[] args)
            JFrame frame = new JFrame();
            frame.setSize(200,200);
            frame.setLocation(100,100);       
            frame.setTitle("Hunt the Wumpus");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            WumpusGrid component = new WumpusGrid();
            frame.add(component);
            frame.setVisible(true);
    }

  • I had to put my computer by together without migration or time machine I NEED help with order of the files?

    I had to put my computer by together without migration or time machine I NEED help with order of the files?

    Hi, where are these other files exactly?

  • Hi. I have an iPhone 4s. The music doesn't play when I connect it to my car stereo. It used to play previously but stopped playing all of a sudden. My phone is getting charged when I cut it to the USB port. Please help with this. The iOS is 6.1.3.

    Hi. I have an iPhone 4s. The music doesn't play when I connect it to my car stereo. It used to play previously but stopped playing all of a sudden. My phone is getting charged when I cut it to the USB port. Please help with this. The iOS is 6.1.3.

    Hello Priyanks,
    I found an article with steps you can take to troubleshoot issues with an iPhone not connecting to your car stereo:
    iOS: Troubleshooting car stereo connections
    http://support.apple.com/kb/TS3581
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • Please i need help with switch from the us store to malaysian store how i can switch

    Please i need help with switch from the us store to malaysian store how i can switch

    Click here and follow the instructions to change the iTunes Store country.
    (82303)

  • I need help with shooting in my flash game for University

    Hi there
    Ive tried to make my tank in my game shoot, all the code that is there works but when i push space to shoot which is my shooting key it does not shoot I really need help with this and I would appriciate anyone that could help
    listed below should be the correct code
    //checking if the space bar is pressed and shooting is allowed
    if(evt.keyCode == 32 && shootAllow){
        //making it so the user can't shoot for a bit
        shootAllow = false;
        //declaring a variable to be a new Bullet
        var newBullet:Bullet = new Bullet();
        //changing the bullet's coordinates
        newBullet.y = tank_mc.y + tank_mc.width/2 - newBullet.width/2;
        newBullet.x = tank_mc.x;
        //then we add the bullet to stage
        addChild(newBullet);
    listed below is my entire code
    import flash.display.MovieClip;
        //declare varibles to create mines
    //how much time before allowed to shoot again
    var cTime:int = 0;
    //the time it has to reach in order to be allowed to shoot (in frames)
    var cLimit:int = 12;
    //whether or not the user is allowed to shoot
    var shootAllow:Boolean = true;
    var minesInGame:uint;
    var mineMaker:Timer;
    var cursor:MovieClip;
    var index:int=0;
    var tankMine_mc:MovieClip;
    var antiTankmine_mc:MovieClip;
    var maxHP:int = 100;
    var currentHP:int = maxHP;
    var percentHP:Number = currentHP / maxHP;
    function initialiseMine():void
        minesInGame = 15;
        //create a timer fires every second
        mineMaker = new Timer(6000, minesInGame);
        //tell timer to listen for Timer event
        mineMaker.addEventListener(TimerEvent.TIMER, createMine);
        //start the timer
        mineMaker.start();
    function createMine(event:TimerEvent):void
    //var tankMine_mc:MovieClip;
    //create a new instance of tankMine
    tankMine_mc = new Mine();
    //set the x and y axis
    tankMine_mc.y = 513;
    tankMine_mc.x = 1080;
    // adds mines to stage
    addChild(tankMine_mc);
    tankMine_mc.addEventListener(Event.ENTER_FRAME, moveHorizontal);
    function moveHorizontal(evt:Event):void{
        evt.target.x -= Math.random()*5;
        if (evt.target.x >= stage.stageWidth)
            evt.target.removeEventListener(Event.ENTER_FRAME, moveHorizontal);
            removeChild(DisplayObject(evt.target));
    initialiseMine();
        //declare varibles to create mines
    var atmInGame:uint;
    var atmMaker:Timer;
    function initialiseAtm():void
        atmInGame = 15;
        //create a timer fires every second
        atmMaker = new Timer(8000, minesInGame);
        //tell timer to listen for Timer event
        atmMaker.addEventListener(TimerEvent.TIMER, createAtm);
        //start the timer
        atmMaker.start();
    function createAtm(event:TimerEvent):void
    //var antiTankmine_mc
    //create a new instance of tankMine
    antiTankmine_mc = new Atm();
    //set the x and y axis
    antiTankmine_mc.y = 473;
    antiTankmine_mc.x = 1080;
    // adds mines to stage
    addChild(antiTankmine_mc);
    antiTankmine_mc.addEventListener(Event.ENTER_FRAME, moveHorizontal);
    function moveHorizontal_2(evt:Event):void{
        evt.target.x -= Math.random()*10;
        if (evt.target.x >= stage.stageWidth)
            evt.target.removeEventListener(Event.ENTER_FRAME, moveHorizontal);
            removeChild(DisplayObject(evt.target));
    initialiseAtm();
    function moveForward():void{
        bg_mc.x -=10;
    function moveBackward():void{
        bg_mc.x +=10;
    var tank_mc:Tank;
    // create a new Tank and put it into the variable
    // tank_mc
    tank_mc= new Tank;
    // set the location ( x and y) of tank_mc
    tank_mc.x=0;
    tank_mc.y=375;
    // show the tank_mc on the stage.
    addChild(tank_mc);
    stage.addEventListener(KeyboardEvent.KEY_DOWN, onMovementKeys);
    //creates the movement
    function onMovementKeys(evt:KeyboardEvent):void
        //makes the tank move by 10 pixels right
        if (evt.keyCode==Keyboard.D)
        tank_mc.x+=5;
    //makes the tank move by 10 pixels left
    if (evt.keyCode==Keyboard.A)
    tank_mc.x-=5
    //checking if the space bar is pressed and shooting is allowed
    if(evt.keyCode == 32 && shootAllow){
        //making it so the user can't shoot for a bit
        shootAllow = false;
        //declaring a variable to be a new Bullet
        var newBullet:Bullet = new Bullet();
        //changing the bullet's coordinates
        newBullet.y = tank_mc.y + tank_mc.width/2 - newBullet.width/2;
        newBullet.x = tank_mc.x;
        //then we add the bullet to stage
        addChild(newBullet);
    if (tank_mc.hitTestObject(antiTankmine_mc))
            //tank_mc.gotoAndPlay("hit");
            currentHP -= 10;
            // remove anti tank mine
            removeChild(antiTankmine_mc);
    if (tank_mc.hitTestObject(tankMine_mc))
            //tank_mc.gotoAndPlay("hit");
            currentHP -= 10;
            // remove anti tank mine
            removeChild(tankMine_mc);
        //var maxHP:int = 100;
    //var currentHP:int = maxHP;
    //var percentHP:Number = currentHP / maxHP;
        //Incrementing the cTime
    //checking if cTime has reached the limit yet
    if(cTime < cLimit){
        cTime ++;
    } else {
        //if it has, then allow the user to shoot
        shootAllow = true;
        //and reset cTime
        cTime = 0;
    function updateHealthBar():void
        percentHP = currentHP / maxHP;
        healthBar.barColor.scaleX = percentHP;
        if(currentHP <= 0)
            currentHP = 0;
            trace("Game Over");
        updateHealthBar();

    USe the trace function to analyze what happens and what fails to happen in the code you showed.  trace the conditional values to see if they are set up to allow a shot when you press the key

  • Help with action script number guessing game

    can someone help me in flash cs6 to make a simple guessing game, i just need help with the coding. making a guessing game from 1-100
    The constructor is coded to assign a random number for
    the user to guess
    • In the section of code indicated by the comments
    (within the handler function doGuess()), write condition
    statements that guide the user to guessing the number
    using text written to the output
    • Trace out the users' guess, plus a message
    • Messages for the user depending how close they are from the
    guess, condition each of the following:
    • Guesses correctly, +/-1 from the guess, +/-10 from the guess,
    +/-20 from the guess, +/-40 from the guess, all other guesses

    close, it's actually an in class practice lab. After doing this we have to do another one that needs to be submitted. I just need help with the coding for this because i dont know how to start at all. let alone the actual lab.

  • Help making a Spot The Difference game

    Hi!
    Im pretty new at Actionscript 3.0 and I have to make a Spot The Difference game for school.. Now I followed a tutorial, but it's in AS 2.0 and I really cant get it to work in AS 3.0. Also, the tutorial isn't complete, so is there anyone that can help me any further with the code ?
    Here's the tutorial I followed:
    http://www.flashperfection.com/tutorial ... rence-Ga...
    Thanks!

    The link in the first post doesnt seem to work, so I hope it works now:
    http://www.flashperfection.com/tutorials/Create-a-Spot-the-Difference-Game-63139.html
    The code in the game Mc is:
    var differences:Number = 3;
    var found:Number = 0;
    function addDifferences(thisSide, otherSide) {
    for (var i = 1; i<=differences; i++) {
    var difference = thisSide["dif"+i];
    difference.useHandCursor = false;
    difference.found = false;
    difference.otherSide = otherSide["dif"+i];
    difference.tabEnabled = false;
    difference.onPress = function() {
    if (!this.found) {
    this.play();
    this.otherSide.play();
    this.found = true;
    this.otherSide.found = true;
    found++;
    if (found == differences) {
    found = 0;
    levels.play();
    and then on left side:
    _parent._parent._parent.addDifferences(this, _parent.rightSide)
    and on the right side:
    _parent._parent._parent.addDifferences(this, _parent.leftSide)

  • Help with form sending the data to email

    I have looked all over the Internet for help with this.  I have tried numerous video tutorials and for some reason I can't get it to work.  I have created a form in flash cs4 AS2.  It is a contact information form where the user fills out their information and sends it.  I have created a the form in a movie clip (I have also tried it not in a movie clip) with the form components inside that movie clip.  I have given each component on the form an instance name.
    The form has:
    Full name (with instance name=name)
    Company (with IN =company)
    Title (with IN = title)
    Phone (with IN = phone)
    Email (with IN = email)
    Topic combobox (with IN=topic)
    Message box (with IN=msg)
    Submit button (with IN=submit)
    I need help with the actionscript writing.  I am VERY new to flash and have never done any scripting really.  Does anyone have a sample file I can look at to see how it works or can someone IM me and I can send my file for them to help me?
    My IM is logan3975
    Any help is greatly appreciated.  I consider myself a pretty technical person so I do learn quick...I just need some guidance until I wrap my head around how this all works.  Thanks.

    Here's a link to a posting elsewhere some had had that may provide some useful info (?)
    http://board.flashkit.com/board/showthread.php?t=684031

  • Need help with developing a small pool game

    Hi,
    I want to develop a small pool game ....Im using the netbeans ide and ....what I have so far is 2 classes ......Pool and GUI
    Basically the main method is in the Pool class.......withing main I created a new GUI object .....which in turn creates a frame.
    I now want to custom code a rectangle and make it a container for the pool table and also colour it......the thing is can I do animations in a frame and by using independant classes rather than using an applet?
    I know this may be innefficient but I want to create a standalone pool game that uses custom objects and classes for the various tasks. I was just wandering if it was possible to do drawings the way i am saying without using an applet? Its just all the tutorials I see .....well all the code seems messy and lumped together in the one place ....and I basically want things such as a independant ball class and perhaps a painter custom interface that colours rectangles.
    Any advice would be appreciated
    David

    Thanks for the advice .....The thing is I understand pretty well what is needed .....and I have programmed small applications that take bookings for a hotel and and a library ....Im am familiar with references, arraylists and the alike and im also reading about the java collections interface ......I have also coded a simplistic program in the past that basically a ball was bouncing of the sides of a container and made a sound when it hit the edge(this used threads i believe). However it has been a while ......and although I am happy with some of the concepts of java........we did not do any java graphics programming at college. In all fairness though I learned the importance of using classes properly and in a way thats why im finding it so difficult to code even basic graphic movement that Im happy with as the tutorials Ive seen have everything lumped in one place(as mentioned) and trying to make them more modular can be difficult. As far as I know from coding some basic applets they are generated on the client side to enable everyone with different platforms to view stuff over the web. I dont want applets as I dont at this time want to distribute any of my meager programs over the web :-)). It is good to know that I can use threads and such independent of the applet class........I know my question may be naive but 100% of the tutorials I saw invoked the applet class in some way and emplied in a way that it was essential.......I thought there would be a way to do it without using applets but was not 100% sure which is why I asked.
    I will just need to try and find one guide now that actually shows me how to do what im asking:-)
    Cheers
    David
    I also have 3 java books.......each of which concentrate on graphics by use of applets ....im going to look them out again as they might contain something useful .....to be honest though they were a bit of a waste of money lol(well 2 of them were)

  • Help with Chicken of the VNC and Airport

    I had my airport working with Chicken of the VNC perfectly and lost the settigns. Now I cannot get it to work again. What do I do a bridge or port forwarding? And how?
    There is so much contradictory information that I have just spent the whole night not doing anything of use. Any precise help would be greatly appreciated.
    Thanks in advance!

    The basic steps to configure for VNC are as follows:
    o Configure the machine you want to control (VNC Server) to allow VNC access. If the VNC Server is behind a router, then this would entail at least three things: 1) Configure the OS X Firewall to allow VNC access, 2) Configure the router to map port 5900 to the VNC Server, and 3) Know the WAN IP address of your router. (Note: One way to get the WAN IP is to go to the web site http://whatismyip.com and make a note of the ip address.)
    o Connect to your VNC Server from a VNC Client from the Internet.
    And I tried to do port forwarding but it doesn't seem to work.
    Let's double-check your port mapping settings.
    1. Reserve a DHCP-provided IP address for the VNC Server.
    Internet > DHCP tab
    o On the DHCP tab, click the "+" (Add) button to enter DHCP Reservations.
    o Description: <enter the desired description of the host device>
    o Reserve address by: MAC Address
    o Click Continue.
    o MAC Address: <enter the MAC (what Apple calls Ethernet ID if you are using wired or AirPort ID if wireless) hardware address of the VNC Server>
    o IPv4 Address: <enter the desired IP address>
    o Click Done.
    2. Setup Port Mapping on the AEBSn.
    Advanced > Port Mapping tab
    o Click the "+" (Add) button
    o Service: <you can ignore this setting>
    o Public UDP Port(s): 5900
    o Public TCP Port(s): 5900
    o Private IP Address: <enter the IP address of the VNC Server from the above step>
    o Private UDP Port(s): 5900
    o Private TCP Port(s): 5900
    o Click "Continue"
    (ref: "Well Known" TCP and UDP ports used by Apple software products)

  • Help getting help with iTunes (or, the elusive product registration number)

    My almost brand-new iPOD classic is now useless because iTunes no longer works on my Vista 64. It was fine for a while. Now, when my computer starts up, I get an error message that reads:
    iTunes was not installed correctly. Please reinstall iTunes Error 7 (Windows error 14003).
    I tried all the obvious stuff, and then decided, what the heck, I'm a paying customer, I'll get some online help for Apple. But much to my frustration and rage, I can't get any help without my product registration number. I can't read the microscopic number on the back of my iPod, and because i can't open iTunes, I can't find my registration number that way. Do you know, you can't even call Apple without the product registration number? So I can't get any help. I'm so frustrated. I got my iPod on Airmiles, so I don't even have a bill.
    Is there any other way to find my registration number?

    hi dan,
    i am using iWeb for a non .Mac account! the reason behind is that external hosters offer better online space and loading times than .Mac. Yet on the other hand, the iDisk, Web-Mail, Addressbook and iCal features that are offered with .Mac make the 99€ a year quite worthy!
    i myself do not use .mac because my website is simply to large and the prices are not accepteable that .Mac offers for more space!
    the next thing is that your .Mac account username will be in you URL and you cannot stay anonymous! your address will be something like this:
    http://web.mac.com/USERNAME
    so now you will share your username with the whole wide world! the other thing is that iWeb was designed to work hand in hand with .Mac. This means that some cool feature fall off when you publish externally, meaning to a different host, eg.: 1and1, godaddy, strato. These features include Slideshows, Password-Protection, Blod-Search and other small things!
    yet when you still choose to go for .Mac - no one will get your address unless you tell them what the address is! it is extremely hard to find, if not impossible, your .mac address under Google or Yahoo! So your username is somewhat protected!
    Here are some good hosters:
    http://godaddy.com
    http://1and1.com
    http://strato.de (german)
    you practically have to also see for your country what hosters offer. 1and1 is extremely cheap and is over the world! Yet when you choose to have a external host - then you have to pay extra and if you close your .Mac account you cannot buy music in the itunes store!
    here is a very good FTP program to upload your files to a different host:
    http://cyberduck.ch
    http://karreth.com/iweb/Host%20To%20Other%20Than%20.Mac.html
    i hope that helped!
    max

  • Help with printing out the # of quarters, nickels, dimes, and etc... using

    Hi, im new to java and im using a program called blue j.
    anyway heres my question.
    , I recommend you dont do the program for me, but rather help gear me in the right direction of things.
    In this program they want me to have it print out the # of dollars,quarters,nickels,dimes, and pennies.
    They have provided me with a base program to start off with which is this.
    import chn.util.*;
    public class ComputeChange
       *  The main program for the Change class
       * @param  args  The command line arguments - not used
      public static void main(String[] args)
        double purchase, cashPaid, temp;
        int change, remainder, dollars, quarters, dimes, nickels, pennies;
        ConsoleIO keyboard = new ConsoleIO();
        System.out.print("Enter amount of purchase --> ");
        purchase = keyboard.readDouble();
        System.out.print("Enter amount of cash paid --> ");
        cashPaid = keyboard.readDouble();
        temp = cashPaid - purchase;
        dollars = (int) temp;
        temp = temp - (int)temp + 0.0000001;
        change = (int)(temp * 100);
        System.out.println();
        System.out.println("$" + dollars + "." + change);
    }Ive been given the amounts 23.06 for amount of purchase
    and 30.00 for the amount paid. that should give me the difference of $6.94
    It should print out the amount of change as the following
    6 dollars
    3 quarters
    1 dime
    1 nickel
    1 penny.
    IVe tried a few methods for printing out the # of each coin type, but i simply dont get how they are using temp or what type of funciton i need to follow. Any hints or pointings in the right direction would help. Since i need to learn this.
    Thanks a lot and i hope i can get some tips. !
    ~Jbinks

    And here's my contribution to the scratch batch... :o)
    class Coins {
        private java.util.Map<Coin, Integer> count = new java.util.HashMap<Coin, Integer>();
        enum Coin {
            DOLLAR(100), QUARTER(25), DIME(10), NICKEL(5), PENNY(1);
            private final int value;   
            Coin(int value) { this.value = value; }
            public int value() { return value; }
        public Coins(int centsValue) {
            for (Coin c : Coin.values()) {
                count.put(c, centsValue / c.value());
                centsValue %= c.value();
        public void display() {
            for (Coin c : Coin.values()) {
                System.out.println(c + ": " + count.get(c));
    public class CoinsDemo {
        private static java.util.Scanner keyboard = new java.util.Scanner(System.in);
        public static void main(String[] args) {
            int price = getPennies("Enter amount of purchase --> ");
            int paid = getPennies("Enter amount of cash paid --> ");
            new Coins(price - paid).display();
        private static int getPennies(String prompt) {
            System.out.print(prompt);
            double d = keyboard.nextDouble();
            System.out.println();
            return (int)(d * 100);
    }

  • I need help with problems after the April 2015 update

    In December 2015 I purchased an LG G3. It started out great. Then often people couldn't hear me..sometimes with the speaker on, sometimes with it off, sometimes on bluetooth with my car,.or my voice faded in and out, or sounded muffled or garbled.  After over a month of these frequent audio problems and several calls to Verizon during which they boosted my signal and guided me through a factory reset which took all of my photos out of their albums, the final suggestion a few days ago (April 21, 2015) was to download the new software update. I did and I'm not happy with some of the changes e.g. I wish I could have the old  home touch buttons back,The jury is still out on sounds quality, but now I have two new annoying problems.
    The first is that my car and phone used to bluetooth (connect) as soon as I put my engine on. Now, every time I get in my car I have to go into settings and give the phone permission to have other devices find my phone. Then after one or two tries the bluetooth eventually connects them. I am a Realtor and I need my phone and car to connect automatically every time I get in. I can give the phone permission to connect for up to an hour, but then it goes off. How do I get the opton to stay on?
    The second is that I often turn my data off, and I used to do it from the notification panel that I can pull down. I just pulled it down and tapped "data" and the light would go off if the data was off and on if it was on.  Now when I tap "data" I can turn it on or off, but the data button stays lit so when the data is off the light is still on. No more quickly glancing to see the data status...I have to tap it and read the notice to find out. Yes, 3G or 4G light up in tiny letters at the top, but data is the only button that stays lit when it is turned off.
    Am I missing the steps that would fix these issues?

    SiBIMe,
    I am sorry to hear of the issues with your device before and after the update. We want to restore the love back to your device. Please keep us posted on the audio issues to see if the update did assist with that issues.
    In regards to the two new problems, we want to make sure we get this worked out. Do you have issues with the device only auto connecting to your car or all bluetooths?  Do you receive and error message when the device doesn't auto connect and you attempt to connect manually but it fails? As for the data icon, when you tab on the data icon from the notification tab does the 4G actually disappear even thought the data icon is still lit?
    Please test your device in Safe mode and let us know if you still experience the same issues. Here is how to place the device in safe mode. http://vz.to/1owbN8K
    LindseyT_VZW
    Follow us on Twitter @VZWSupport

Maybe you are looking for

  • Invalid synonyms in PUBLIC after upgrade from 9i to 10g

    We just did a conversion from Oracle 9i to 10g on our databases, and now I'm getting a warning in the enterprise manager database control that I have 1753 invalid objects in the PUBLIC schema. I drilled down and it looks like its all SYNONYMS. Not su

  • Data source filter in studio

    is data source filter still supported in studio in version 3.1? I don't see it working in my case when I put the filter in endeca server connection. please advise

  • OSX 10.4.8 app launch difficulties!

    I updated to 10.4.8 through software update and although it indicated that there was an 'error' with the update, my cpu showed the OSX as 10.4.8 Many apps work fine but when I went to launch some others, they won't launch and below is a sampling of t

  • Help on flash video pls

    i have insert a flash video into my webpage using dreamweaver. but when i pressed F12 , the page load with showing my video at all! but there is a message displayed at the video space there saying " click here to acitivate and use this control". when

  • VoIP between Norstar and Nortel option 11

    Hi, i have some problems in the calls between a Norstar and a Nortel option 11, both are connected to a 2811 via E1 with the IOS is c2800nm-spservicesk9-mz.124-15.T3.bin both routers are using h323. We also have a Callmanager 5.1.2.3000-2 that intera