Hi, I'm writing a game, because I am bored^^ Now, I want that every ore is just ten times generated, and collectable. If I collect an ore now, it generates on another place on the map If this is real, this would make me rich, but it isnt , so how can I avoid this?
Some other notes:
Using generics for your ArrayLists would remove the need for casting and make your code typesafe.
Use of Random#nextint(...) would give shorter and cleaner code when compared to your present code using Math#random().
Consistent indenting and whitespace would make your code much more readable. See http://www.oracle.com/technetwork/java/codeconvtoc-136057.html All Swing constructors and methods should be invoked on the EDT. Not on the Main thread.
There are no new questions, but there may be new answers.
Joined: Sep 29, 2012
Avoid, That the Ore is regerneratet If you collect it
Steven Joost wrote:Avoid, That the Ore is regerneratet If you collect it
Erm...change the code so that it doesn't do it?
If this is your own code, surely you know how to do that?
However, I have two general tips for you, which are not related to your specific question:
1. StopCoding (←click).
2. Get rid of all that Swing code - It's simply cluttering your mind, and distracting you from the real issue, which is your game.
Get the game logic working first, even if it means just using the console, and only add your Swing stuff back in when you KNOW it's working. And even then, keep the game logic separate from your display.
Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here