Results 1 to 3 of 3
Thread: need help with pacman game!!
- 10-21-2009, 09:03 AM #1
Member
- Join Date
- Oct 2009
- Posts
- 1
- Rep Power
- 0
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 09:42 AM.
- 10-21-2009, 09:20 AM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
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?
- 10-22-2009, 02:44 PM #3
Member
- Join Date
- Oct 2009
- Posts
- 12
- Rep Power
- 0
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 isLast edited by Lizzip; 10-23-2009 at 07:01 AM.
Similar Threads
-
Implementing "Game Over" in Minesweeper game based on Gridworld framework.
By JFlash in forum New To JavaReplies: 2Last Post: 08-05-2010, 04:49 AM -
[SOLVED] Ready to Program Java IDE Problem #3 PacMan For Loop to Slide Across the Scr
By Starr29 in forum New To JavaReplies: 3Last Post: 07-18-2009, 01:26 PM -
2D strategy game or 2D war game
By led1433 in forum Java 2DReplies: 5Last Post: 02-10-2009, 06:00 AM -
Tic Tac Game
By loggen in forum New To JavaReplies: 1Last Post: 12-12-2008, 07:36 AM -
Java Pacman question
By whdbstjr90 in forum New To JavaReplies: 0Last Post: 12-11-2007, 11:28 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks