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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:40:28+00:00 2026-06-11T06:40:28+00:00

I have to create a game for my software development class and i’m trying

  • 0

I have to create a game for my software development class and i’m trying to figure out how can I link my classes together to update for instance the health of the player when I go to a different screen.
I created a class player that contains all the methods and variables needed for a player for instance, health, ship, name, but say i get in a fight in the game, how can i keep updating the health because everytime I have to go to a new screen where I have to keep creating a new instance of player.

What is another way around this so its more OO oriented?

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-06-11T06:40:30+00:00Added an answer on June 11, 2026 at 6:40 am

    Use events for things like this. Imagine there is a central place where all events are sent for distribution. Components of your game can then register listeners for certain events. Examples of events:

    When someone updates the player health, the player instance sends an event “Health changed” with the new value.

    The “display health” component could listen for this kind of event and update itself accordingly.

    The beauty of this approach is that the health component need not know anything about the player. It just responds to a “Health(int)” event.

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

Sidebar

Related Questions

I have a multiplayer game lobby up where users can create private chatrooms and
I'm trying to figure out a way to create random numbers that feel random
For a class project, we have to create a hangman game in Java (we're
I am trying to create a game and have run into what is probably
I am trying to create a Game so that I can change its data
I'm trying to create a game. I have a list. I want to take
I'm making a pong game for my software development class, and I should probably
I have the following scenarios: Scenario: Create a game with valid information Given I
i have a problem (obviusly :P) i'm create a mini game, and when i
I have a big 3d game that lets players build and create interesting and

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.