![]() |
| ||
| PacMan Boolean Problem Part Duex. Hello All, This is suppose to be my finished code for my "PacMan Game". All this "game" is suppose to do is to allow a Pacman to eat dots that can be placed on the screen at any location by clicking the mouse. It has a main class and a dot class file. For some reason the PacMan is not eating the dots, any ideas? Any help will be greatly appreciated Here are the codes for each. Main Class: import java.applet.*; Dot Class: import java.awt.*; |
| ||
| Re: PacMan Boolean Problem Part Duex. Ah I just realised that you are not actually calling the eatDot() method anywhere in your code. I think it should probably be called immediately before the call to repaint()... |
| ||
| Re: PacMan Boolean Problem Part Duex. Yes, EatDot() needs to be called before repaint() in your KeyAdapter to evaluate if a dot is eaten. Also, your collision function in EatDot() needs to check the absolute value of the coordinate differences if ((Math.abs(xcoords - dot[i].x) <= 5) && ((Math.abs(ycoords - dot[i].y) <=5)) && !dot[i].isEaten()) {and lastly you need to reevaluate your offsets from xcoords and ycoords in your placement and drawing of the pacman arc. Offsetting -50 from x and y are causing your pacman to be drawn in the wrong location relative to xcoords and ycoords values you are checking against the dot coordinates.You are close. You just need to check your relative coordinate and bounding box usage to fine tune it. You might want to also use an ArrayList for the Dots instead of a fixed 1000 element array and remove a dot when it is eaten, rather than leaving it in an array and continuing to check it after it's long gone. |
| ||
| Re: PacMan Boolean Problem Part Duex. Thanks for the help guys! I finally figured it out :) |
| All times are GMT -4. The time now is 6:31 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC