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 448165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:38:33+00:00 2026-05-12T21:38:33+00:00

Here’s the problem: I’ve been working on a little game where monsters bounce off

  • 0

Here’s the problem:

I’ve been working on a little game where monsters bounce off the walls (edges) of the main form, and it’s going swimmingly, but it only paints one of each type of monster when it should be iterating through a list of each of them and calling their OnPaint and Move methods:

private void Pacmen_Paint(object sender, PaintEventArgs e)
{
    Graphics g = e.Graphics;
    Rectangle rect = e.ClipRectangle;

    g.Clear(backgroundColor);

    foreach (Hydra h in hydraList) {
        h.OnPaint(e);
        h.Move(e);
    } // end foreach

    foreach (Ghost gh in ghostList) {
        gh.OnPaint(e);
        gh.Move(e);
    } // end foreach
}

Here’s the ghost’s methods:

public void OnPaint(PaintEventArgs e)
{
    Graphics g = e.Graphics;
    g.SmoothingMode = SmoothingMode.HighQuality;

    GraphicsPath path = new GraphicsPath();
    SolidBrush fillBrush = new SolidBrush(color);
    SolidBrush eyeBrush = new SolidBrush(Color.Black);

    path.AddArc(pos, (float)180, (float)180);
    path.AddLine((float)pos.Right, (float)(pos.Y + pos.Height / 2),
        (float)pos.Right, (float)pos.Bottom);
    path.AddLine((float)pos.Right, (float)pos.Bottom,
        (float)(pos.X + pos.Width / 2), (float)(pos.Bottom - radius / 2));
    path.AddLine((float)(pos.X + pos.Width / 2), (float)(pos.Bottom - radius / 2),
        (float)pos.Left, (float)pos.Bottom);
    path.AddLine((float)pos.Left, (float)pos.Bottom,
        (float)pos.Left, (float)(pos.Y + pos.Height / 2));

    g.FillPath(fillBrush, path);
    g.FillEllipse(eyeBrush, new Rectangle(pos.X + pos.Width / 4, pos.Y + pos.Height / 4, radius / 4, radius / 5));
    g.FillEllipse(eyeBrush, new Rectangle(pos.X + 3 * pos.Width / 4, pos.Y + pos.Height / 4, radius / 4, radius / 5));
} // end OnPaint

public void Move(PaintEventArgs e)
{
    pos.Offset(xSpeed, ySpeed);
}

Any ideas why only one would show up? Thanks!

  • 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-05-12T21:38:33+00:00Added an answer on May 12, 2026 at 9:38 pm

    Are you sure you’re giving the characters individual starting positions and speed? Maybe they are all painting, but on exactly the same spot?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my problem: I'm making a product upload module (main form) in C#. I
Here's a problem I ran into recently. I have attributes strings of the form
here is something I have been working on for quite a while and can't
Here is my problem...I have a page that loads a list of clients and
Here is some code I made :) @echo off set source=R:\Contracts\ set destination=R:\Contracts\Sites\ ROBOCOPY
Here is my problem : I have a post controller with the action create.
Here my problem: @Assert\Regex( * pattern=/^[A-Za-z0-9][A-Za-z0-9\]*$/, * groups={creation, creation_logged} * ) I'm using the
Here is the stacktrace: 04-10 18:09:36.393: E/AndroidRuntime(26592): FATAL EXCEPTION: main 04-10 18:09:36.393: E/AndroidRuntime(26592): java.lang.RuntimeException:
Here is a screenshot of the problem (in IE): http://img401.imageshack.us/img401/7580/screenield.jpg The above effect -
Here is another spoj problem that asks how to find the number of distinct

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.