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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:35:27+00:00 2026-06-04T03:35:27+00:00

//Pylons int xCoord[]; int yCoord[]; int numSquare; boolean firstPaint; public void init() { //Images

  • 0
//Pylons
int xCoord[];
int yCoord[];
int numSquare;
boolean firstPaint;

public void init() {
    //Images Call
    pylon = getImage(getDocumentBase(), "image/pylon.png");
    numClicks = 0;

    //pylons
    xCoord = new int[100];
    yCoord = new int[100];
    numSquare = 0;
}

public void paint(Graphics g) {
    if (numClicks == 0) {
        drawUI(g);
        //probeDraw(g,2);
    }

    if (numSquare == 1) {
        for (int k = 0; k < numSquare; k++) {
            g.drawImage(pylon, xCoord[k], yCoord[k], this);
        }
        Minerals -= 100;
        popMax += 9;
    }
}

public boolean mouseDown(Event e, int x, int y) {
    if (numClicks == 10) {//Title screen        
        numClicks++;
        repaint();
    }

    if (numSquare == 0) {
        xCoord[numSquare] = x;
        yCoord[numSquare] = y;
        numSquare++;
        repaint();
    }
    return true;
}

When i do this instead of just minusing 100 it will put it at like -300 and it wil add the popMax to like 36 instead of 10. Some times it will do it correct and sometimes it won’t its really annoying

  • 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-04T03:35:28+00:00Added an answer on June 4, 2026 at 3:35 am

    you’re updating class-level variables in paint(…), a method which is called every time the ui component needs repainting. I’m not surprised it’s annoying.

    You need to split the logic that handles click actions out of the paint method – and use the paint method to render just the CURRENT STATE of your component.

    Edit: Further to your comments, and without knowing the structure of your application, I imagine you would need something like this:

    private void handlePylonPlacement()
    {
        if(decrementMinerals(-100))
            addPopMax(9);
    } 
    
    private boolean decrementMinerals(int amount)
    { 
        if(MaxMinerals - amount >= 0) // prevent situation where you go into negative minerals
        {
             MaxMinerals -= amount;
             return true;
        }
        else
             return false;
    }
    
    private void addPopMax(int amount)
    {
        if(popMax + amount <= MAX_POPULATION) // restrict addition to pop-max to a sane upper bound
             popMax += amount;
    }
    
    public boolean mouseDown(Event e, int x, int y) {
        if (numClicks == 10) {//Title screen        
            numClicks++;
            repaint();
        }
    
        if (numSquare == 0) {
            xCoord[numSquare] = x;
            yCoord[numSquare] = y;
            numSquare++;
            handlePylonPlacement(); // call your new handler
            repaint();
        }
        return true;
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm running pylons and I did this: paster server development.ini It's running on :5000
Does anyone know how Pylons and TG2 projects handle database migrations? I'm looking for
Are there documented pylons or turbogears2 widgets for generating SVG markup as components and
I have a Pylons web application served by Apache (mod_wsgi, prefork). Because of Apache,
In a framework like Django or Pylons you can set up function to handle
I am developing a Web application in Pylons on the Mac. My development server
I'm working on a fairly simple Pylons 0.9.7 application. How do I tell, in
I've created a new Pylons application and added a controller (main.py) with a template
Im moving from django to pylons, is there an admin app?
reading pylons documentations I did understand that websetup:setup_app is only called when the application

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.