This week's book giveaway is in the Java in General forum.
We're giving away four copies of Helidon Revealed: A Practical Guide to Oracle’s Microservices Framework and have Michael Redlich on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

How to design a game?

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a basic java knowledge(Syntax, basic OOP), but I don't know how I can make a structure of my classes. I want to write a game with some sprites(rabbits) and background pictures. You kill the rabbits and they die. A simple game...
I thought I create for every sprite a thread that calculates the x,y position. Every Thread has an object of the sprite with some data about the health and so on.
My Problem is : Where can I get an example of a game like this?
I don't know how I should work with the mouseEvents. I add the mouseListener to the Panel, but create the threads in an other class. So how can I implement: If the user click on the rabbit at X,Y; the sprite thread must die(or init again). But I can't access the thread because it is created in an other class! Arggg... there are a lot of problems like this of structuring this game.
Please help with an example, or better with a discription...
Thanks a lot!
 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What if the 'rabbit' class held a variable of type Thread referring to the thread it is running in ?
 
Smilidon Sapiens
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I will try it! Thanks!
 
Bring me the box labeled "thinking cap" ... and then read this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic