![]() |
|
[Java] Two Circles Coliding in sperate class ? - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [Java] Two Circles Coliding in sperate class ? (/showthread.php?tid=5582903) |
Two Circles Coliding in sperate class ? - Most3rs2 - Mar 23, 2017 Hey, so we need to make a pinball machine kinda thing for an assignement, and i need the to do something when 2 pinballs collide, now both circles have a diiferant class to modify there speed etc. how could I call Object1 in Object2. what should i use to do this * - ☕⚛Austin⚛☕ - Mar 23, 2017 You should have an ArrayList(Object based array with no fixed size) of all your game objects. So this is a polymorphism problem. You should probably have an interface GameObject which has tick(); and render(); and then a class called BaseGameEntity immplements GameObject. In Game Object initialize a public static final ArrayList<Game Object> gameobjects and in the constructor simply add this Object to your list. GameObject.java PHP Code PHP Code Main.java PHP Code This code isn't ideal for a real game I left out threading and a physics loop but it should resemble something like that. Typed this out in edit comment so the syntax might be off. * - Most3rs2 - Mar 23, 2017 (Mar 23, 2017 10:48 PM)☕⚛Austin⚛☕ Wrote: You should have an ArrayList(Object based array with no fixed size) of all your game objects. So this is a polymorphism problem. You should probably have an interface GameObject which has tick(); and render(); and then a class called BaseGameEntity immplements GameObject. In Game Object initialize a public static final ArrayList<Game Object> gameobjects and in the constructor simply add this Object to your list. Its not exactly a game, I have 5 classes, demo which had the objects, game time any anything to do with the actual game, pinballobject1 which has everything to do with the first pinball, pinballobject2 same thing as 1 but for the 2nd pinball, machine which has the size of canvas and most of the values and canvas, is there a way me can can talk on skype ? * - ☕⚛Austin⚛☕ - Mar 23, 2017 Sorry I don't do one on one. But if your going to be making pinball it should probably ressemble a game. * - Most3rs2 - Mar 23, 2017 ok sure but it's a verry simple game, i dont know a lot about java, there are no controls its automatic kind of thing |