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

  • Home
  • SEARCH
  • 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 8640745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:21:14+00:00 2026-06-12T11:21:14+00:00

okay, so i have my image move straight down along the y axis whenever

  • 0

okay, so i have my image move straight down along the y axis whenever i click the mouse, my only problem is i don’t know how to get it to stop when it hits the bottom of the screen, can someone please help?

    import java.awt.Point;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;

public class Control extends BasicGameState {
    public static final int ID = 1;

    public Methods m = new Methods();
    public Point[] point = new Point[(800 * 600)];

    int pressedX;
    int pressedY;
    int num = 0;
    String Build = "1.1";

    public void init(GameContainer container, StateBasedGame game) throws SlickException{
    }

    public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException {
        for (Point p : point) {
            if (p != null) {
                m.drawParticle(p.x, p.y += 1);
            }
        }
        g.drawString("Particle Test", 680, 0);
        g.drawString("Build: " + Build, 680, 15);
        g.drawString("Pixels: " + num, 10, 25);
    }

    public void update(GameContainer container, StateBasedGame game, int delta) {
    }

    public void mousePressed(int button, int x, int y) {
        pressedX = x;
        pressedY = y;
        num = num + 1;
        point[num] = new Point(pressedX, pressedY);
        }

    public int getID() {
        return ID;
    }

}
  • 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-12T11:21:15+00:00Added an answer on June 12, 2026 at 11:21 am

    I’d imagine somewhere you will want to check the x/y pos of the particle before you renderer it and remove it from the array when it’s out of bounds…

    public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException {
        for (int index = 0; index < point.length; index++) {
            Point p = point[index];
            if (p != null) {
                p.y++;
                if (p.y > height) { // You'll need to define height...
                    point[index] = null; // Or do something else with it??
                } else {
                    m.drawParticle(p.x, p.y);
                }
            }
        }
        g.drawString("Particle Test", 680, 0);
        g.drawString("Build: " + Build, 680, 15);
        g.drawString("Pixels: " + num, 10, 25);
    }
    

    You could also do a preemptive check, which would allow you to know what points are at the bottom of the screen…

            if (p != null) {
                if (p.y >= height) { // You'll need to define height...
                    // Do something here
                } else {
                    p.y++;
                    m.drawParticle(p.x, p.y);
                }
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

okay i have found the way to run a video in a image.... the
Okay, so I have a JSON array of image URLs. I want to load
Okay excuse the cryptic subject. I have a system which dynamically fetches image data
Okay, I have a Jpanel which is shown as white in the below image
Okay so I want to have an image that I select through CSS to
Okay, I have a method that takes the variables: an image, int x, int
Okay, so I have a code, that take an image of the current view,
Okay, So I have a PHP file that uploads a image to my server.
Okay I have a drop down menu, before I put the drop down menu
Okay, so I have this character, and I want it to smoothly move. I

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.