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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:54:25+00:00 2026-05-11T03:54:25+00:00

I am developing a simple platform game in Java using BlueJ. Over the next

  • 0

I am developing a simple platform game in Java using BlueJ.

Over the next few weeks I will be posting a few questions asking for help with this project as am not very proficient at programming. So I hope I don’t become annoying and I would be very grateful if you can kindly help me.

In my game I have a gameOver method which ends the game and prints a statement to the console. What I would like is to call upon this method when my player sprite ‘falls off’ the screen.

Right now I have a rectangle shape placed at the bottom of the screen to represent some kind of hazard (like water) and when the player collides with it, it calls the gameOver method and the game ends. However, I would still prefer if the game ended if the player fell below a certain height of the screen.

This is my gameOver method (from the ‘Game’ class)-

/** End the game. */ public void gameOver() {     world.terminate();     isOver = true; } 

This is my player sprite (currently drawn using a polygon)-

super(Utils.createPolygon(170, 102,     155, 118, 137, 118, 151, 134, 146,     140, 167, 140, 170, 135, 174, 140,     193, 140, 188, 134, 202, 118, 186,     118, 170, 102));  setColor(new Color(254, 167, 184)); 

This is the code (from the ‘Enemy’ class, similar code is used in a Hazard class also) that ends the game when player collides with an enemy-

if (e.contact.involves(player) && (player.getLives() < 1)) {     System.out.println('YOU ARE DEAD!');     game.gameOver(); } 

I would like a similar, or at least simple solution that will call on my gameOver method when my player sprite falls or goes beyond a certain coordinate of the screen.

I would appreciate it if you could kindly provide a sample/example code, with comments to help me understand it, in order to give an idea of what I should do to achieve this.

Thank you very much and I look forward to your answers.

  • 1 1 Answer
  • 1 View
  • 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. 2026-05-11T03:54:26+00:00Added an answer on May 11, 2026 at 3:54 am

    To get you started:

    1. Think about how you might get the player’s current position.
    2. Think about what makes the player fall (there should be some method/class that implements gravity and falling?)
    3. Check the player’s position as they fall against the boundries of your world. If they’re outside the boundries, it’s time to call your GameOver method.

    To check the boundries:

    1. Your world should have a minimum height that the player has to keep above to stay alive. Remember this value.
    2. If you get your player’s vertical position and compare to this minimum height, you should get a boolean result (safe vs. dead).
    3. Note that screen position starts at the top left and increases as you go right and down, so you’re player position probably reflects this. Thus, you’re most likely looking for the test (player.getPosition().Y > world.getMaxAllowedHeight());

    For reference: Please post what you’ve tried already and where you’re having problems. Asking for a spoonfed solution isn’t going to help anyone – you’re going to have to think about this a bit yourself. If you have no idea where to start, tell us that instead; we can try to steer you in the right direction.

    Update: Sounds like you’ve done a bit of thinking already, which is great! Sorry if I was harsh to jump down your throat, but your original post suggested otherwise. Next time, though, do try to ask a more help-me-help-myself question than a solve-it-for-me one. A simple ‘Can someone give me an idea of how to start tackling this problem?’ will do.

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

Sidebar

Ask A Question

Stats

  • Questions 162k
  • Answers 162k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You could add the numbers to the legend. library(ggplot2) critters… May 12, 2026 at 12:03 pm
  • Editorial Team
    Editorial Team added an answer You need to flush the session. That will make sure… May 12, 2026 at 12:03 pm
  • Editorial Team
    Editorial Team added an answer That overload of the template for function pointers surely is… May 12, 2026 at 12:03 pm

Related Questions

I am developing a simple platform game using Java using BlueJ as the IDE.
I have been researching around trying to find the best way to begin developing
Concerning pages that build a web application: Lately, I have found myself creating web
I am developing a simple game in PyGame ... A rocket ship flying around

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.