This site requires JavaScript, please enable it in your browser!
Greenfoot back
Entity1037
Entity1037 wrote ...

2014/4/28

Help setting up classes and hit detection in an actual java game.

Entity1037 Entity1037

2014/4/28

#
I'm not sure how to set up the classes in real java, how they work, or hit detection (although I have a pretty good idea on hit detection). Could someone please show me how to set up the classes and how they're drawn/redrawn, and basically the summary of how a java game functions? I just need a short explination that explains what's happening. I can't seem to find anything online that explains it...
bourne bourne

2014/4/28

#
I'm not sure what you mean by real Java. If you have programmed in Greenfoot, you have programmed Java. A class can be whatever you want it to be, give it fields for an image, a location (within some "world"), perhaps some bounds (could just be the bounds of the image). Then whatever form or window responsible for drawing the game environment can grab these classes' images to draw them given their location fields etc. Edit: Greenfoot is just a library and a little bit of overhead taking care of the window, drawing of game environment, execution of game objects, mouse interaction, etc. It is not a different language than that of Java
JetLennit JetLennit

2014/4/28

#
This was the tutorial I used and it was great Java Games Tutorial (I think you were asking for something like this) After I posted I saw you wanted something short..... but if you want something more in-depth just go here
Entity1037 Entity1037

2014/4/28

#
By actual java I meant not greenfoot, but Just java. And I'm just wondering how the game keeps tracks of classes and interacts with them to create the game. I just want a basic explination, not a full tutorial. Although thank you JetLennit; the tutorial is very interesting! And bourn, I did not know that Greenfoot was that simple...
bourne bourne

2014/4/28

#
Keep a list of game objects, and tell each one to "act" every game cycle interval that you define. Or have them have their own threads is a possibility
Entity1037 Entity1037

2014/4/28

#
Act? You mean call each one's "Act" method? So basically all I have to do is create a similar setup to greenfoot?
bourne bourne

2014/4/28

#
Since Greenfoot has this already setup in mind, you probably will be recreating something similar
You need to login to post a reply.