Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8652975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:25:53+00:00 2026-06-12T14:25:53+00:00

Hello for a school exercise i need to create a game and i decided

  • 0

Hello for a school exercise i need to create a game and i decided to create Pacman. Everything goes well but one thing i can’t accomplish is to draw a pacman dude and his ghosts.. i made and oval but what now? i want the pacman mouth also to open and close as it moves. can someone help drawing this?

below what i have till now:

package h04PacMan;

import java.awt.*;

public class DrawPacMan {

public void drawPacMan(Graphics g, int x, int y, Color color) {

    g.setColor(color); // set color
    g.fillOval(x, y, 50, 50); // paint
    g.setColor(Color.black);
    g.drawOval(x, y, 50, 50); // outline
    // mouth?

}

public void drawGhost(Graphics g, int x, int y, Color color) {

    g.setColor(color); // color
    // here goes shape

}

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T14:25:54+00:00Added an answer on June 12, 2026 at 2:25 pm

    So there are a couple of things going on here that you will need to address.

    1. Drawing Characters

    I’ll only address drawing Pacman here.

    Thinking about the Pacman game, Pacman’s character has two states — mouth closed, and mouth opened (in each cardinal direction!). This will be important for when we animate Pacman in a moment, so first, lets establish our pacman shape by using the fillArc method from the Graphics library.

    Example of Mouth-Open Pacman:

      g.setColor(Color.yellow);
      g.fillArc(0,0,150,150,30,300);
    

    This will create pacman in the top-left corner of your window, with pacman’s mouth facing to the right of the screen. The last two paramters of the fillArc method control this opening — the 5th parameter is the starting angle, and the sixth parameter is the angle of the full arc. You may infer from this that the start angle 0 is the horizontal line going from the center of the arc to the right of the screen. Also remember from mathematics that a full circle is 360 degrees.

    Using this information, try drawing mouth-opened Pacman facing up, down and left. After you do that, fill the entire arc to draw Pacman with his mouth closed. Also consider other methods in the Graphics library you can use to draw your ghosts!

    2. Animating Pacman

    For this task you will probably want to implement some sort of Thread structure to animate Pacman, which gets quite a bit more complicated than what you’ve demonstrated here. Since we don’t know your program specifications, and you also haven’t demonstrated any code relating to the animation yet, I’m hesitant to lay this out any further. However, I will direct you to some links on the matter:

    • For a general overview, check out Java Tutorials – Concurrency.
    • If you’re using Swing for this project, you may want to use SwingWorker for your threads.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello is have a question for a school assignment i need to : Read
Hello ! I need to create a report like the attachment shows with Jasper
Hello I'm about to create a school management system where it should assure the
Hello can you help me get this String $string =High School#Church Divinity School of
Hello I am in the process of doing a school project, where we have
Hello! I've been programming for a long time but just started developing for android,
For an school project, I need to parse a text/source file containing a simplified
I am trying to make a website for the students in my school but
Sorry for the newb question but I am an experienced old-school programmer but I
Hello I'm doing a school project and I'm stuck on a problem any help

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.