Results 1 to 3 of 3
  1. #1
    Newbie_Javaer is offline Member
    Join Date
    Oct 2009
    Posts
    1
    Rep Power
    0

    Post need help with pacman game!!

    1.how to draw a corridor for pacman in corridor class??:confused:
    (the code is given below)

    corridor class:

    import java.awt.*;

    public class Corridor {
    private int startX, startY, length;
    private boolean isHorizontal;

    public Corridor(int x, int y, int length, boolean isHorizontal) {

    }


    }
    //-------------------------------------------------------------------
    //-------------------------------------------------------------------
    // METHOD FOR CHECKING IF PARAMETER POSITION, x, y,
    // IS ON THE CORRIDOR
    //-------------------------------------------------------------------
    public boolean isOnCorridor(int x, int y) {





    return false;
    }
    //-------------------------------------------------------------------
    //-------------------------------------------------------------------
    // METHOD FOR DRAWING A SINGLE CORRIDOR OBJECT
    //-------------------------------------------------------------------
    public void drawCorridor(Graphics g) {






    }
    }


    constants:

    import java.awt.*;

    public class A3Constants {
    private static final int CORRIDORS_TOP = 40;
    private static final int CORRIDORS_LEFT = 40;
    private static final int CORRIDORS_MAX_LENGTH = 510;

    public static final int OUTER_EDGE = 10;
    public static final int INNER_EDGE = 10;
    public static final int BOTTOM_EDGE = 60;
    public static final int WINDOW_WIDTH = CORRIDORS_MAX_LENGTH + OUTER_EDGE * 2 + INNER_EDGE * 2;
    public static final int WINDOW_HEIGHT = CORRIDORS_MAX_LENGTH + OUTER_EDGE * 2 + INNER_EDGE * 2 + BOTTOM_EDGE;



    public static final int[] HORIZONTAL_CORRIDORS_DATA = {
    200,200,150,
    200,300,150,
    50,500,450
    };


    public static final int[] VERTICAL_CORRIDORS_DATA = {
    300,150,150,
    350,250,250,
    250,450,50
    };

    //-------------------------------------------------------------------
    // There are 3 values to define one corridor, therefore the number
    // of corridors is equal to the length divide by 3.
    //-------------------------------------------------------------------
    public static final int NUMBER_OF_HORIZONTAL_CORRIDORS = HORIZONTAL_CORRIDORS_DATA.length / 3;
    public static final int NUMBER_OF_VERTICAL_CORRIDORS = VERTICAL_CORRIDORS_DATA.length / 3;
    public static final int TOTAL_NUMBER_OF_CORRIDORS = NUMBER_OF_HORIZONTAL_CORRIDORS + NUMBER_OF_VERTICAL_CORRIDORS;
    Last edited by Newbie_Javaer; 10-21-2009 at 10:42 AM.

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Please use code tags when posting code.
    You didn't say specifically what the problem with the code is. What exactly do you need help with?

  3. #3
    Lizzip is offline Member
    Join Date
    Oct 2009
    Posts
    12
    Rep Power
    0

    Default

    Firstly, you need a width of the corridor.

    Then, for the isOnCorridor function, you're needing collision detection. Something along the lines of if pacmanX > corridorWallMinX and pacmanX < corridorWallMaxX and pacmanY > corridorWallMinY and pacmanY < corridorWallMaxY, return true. True being that pacman is in the corridor.

    Other than that im not really sure whats going on or what exactly your problem here is
    Last edited by Lizzip; 10-23-2009 at 08:01 AM.

Similar Threads

  1. Replies: 2
    Last Post: 08-05-2010, 05:49 AM
  2. Replies: 3
    Last Post: 07-18-2009, 02:26 PM
  3. 2D strategy game or 2D war game
    By led1433 in forum Java 2D
    Replies: 5
    Last Post: 02-10-2009, 07:00 AM
  4. Tic Tac Game
    By loggen in forum New To Java
    Replies: 1
    Last Post: 12-12-2008, 08:36 AM
  5. Java Pacman question
    By whdbstjr90 in forum New To Java
    Replies: 0
    Last Post: 12-12-2007, 12:28 AM

Tags for this Thread

Posting Permissions

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