This program shows a pacman like figure moving right across the screen using GArcs. I run my program and it doesnt even show the first PacMan garc that I have added. Any Help?
Heres my code:
/* * Name: Connor Moore * File: PacMan.java * Date: 3/24/13 * Purpose: The program displays a PacMan like figure moving * rightward across the canvas starting on the very left side. */ package mat2670; import acm.graphics.*; import acm.program.*; import java.awt.Color; public class PacMan extends GraphicsProgram { public static void main(String[] args) { (new PacMan()).start(); } public void run() { //Gets the window's width double windowWidth = getWidth(); //Initializes all the components to the GArc double r = 50; double x = 0; double y = getHeight() / 2; double width = 2 * r; double height = 2 * r; double start = 60; double sweep = 240; //displacement of x double dx = 120; //Creates and adds the first PacMan shape. GArc PacMan = new GArc(x, y, 2 * r, 2 * r, start, sweep); PacMan.setFilled(true); PacMan.setFillColor(Color.YELLOW); add(PacMan); int count = 0; while ((x + r) < windowWidth) { //takes 3 times for PacMans mouth to shut. //Starts open, shuts at 3, switch to opening again, etc if (count < 3 || count > 6) { start -= 20; sweep += 40; x += dx; } else if (count > 3 || count > 9) { start += 20; sweep -= 40; x += dx; } PacMan.move(x, y); pause(PAUSE_TIME); } } private static final int PAUSE_TIME = 5; }