• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

101 Neutral

About EvanPolekoff

  • Rank
  1. [Java] Setting the variables in 2 objects equal

    From reading that tutorial, it seems like the clone(); method is used to create a cloned object that has all of the same variables as the first. I don't want to create a new object every cycle, though. Here's a more specific breakdown of what I am trying to do: *I create Robot1 and Robot2 that are both objects of the Robot class. *I manually set certain variables from Robot2 equal to certain ones from Robot1, such as: Robot2.Speed = Robot1.Speed, etc *I edit the all of the variables that belong to Robot2, including the ones I manually set from Robot1 and more. *Now I want to set all of the variables from Robot1 to what they were changed to when I edited Robot2. I don't want to have to manually do them all because there are a lot more that were changed. I do it in this roundabout way because I don't want Robot1 to be able to edit any of Robot2's variables without me specifically saying so (like how I make Robot1.Speed = Robot2.Speed). If Robot1 and Robot2 had the same path, then Robot1 would be able to set variables in Robot2 that I didn't want it to.
  2. [Java] Setting the variables in 2 objects equal

    I would like for each object to have their own independent copies of the variables, lists, etc. The two objects' variables will only be set equal to each other under certain circumstances. Otherwise, they will be changing their own variables independently of the other object. The Robot class won't have any subclasses, so each object having it's own sub-objects is irrelevant. I want to try to avoid setting every variable equal to the one in the other object manually. There are a lot of variables and I don't want to have to change the code whenever I add a new variable or change an existing one.
  3. Slowly but surely figuring out Java :3
  4. Hey. I've been searching for how to fix this problem of mine but I can't find anything. In my main method, I have two objects that are instances of the same class called Robot. I would like all of the variables in one of the objects to equal all of the variables of the other object without setting each one individually. Since they are both instances of the same class, they have all of the same variables. Simply putting Robot1 = Robot2; doesn't work because that just sets the addresses/paths to the data in memory equal to each other. I found the equals(); method, but I think that's just for comparing the data of the objects instead of setting the data. Is there some kind of trick to setting all of the variables equal or do I just have to do it the long way? Thank you for your help.
  5. My First Finished Game

    Looks cool for a first game; simple yet addicting. I could see it as facebook game.
  6. First Arrival

    Well, I just joined Gamedev.net. I'm looking forward to learning a lot about game programming in Java. I'm currently trying to figure out how to use the paint method to make graphics, but it won't work. I'll figure it out soon.
  • Advertisement