• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Collecting Ores

 
Steven Joost
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

Own-defined
 
Darryl Burke
Bartender
Posts: 5132
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steven Joost wrote:how can I avoid this?

Avoid what, exactly?

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.
 
Steven Joost
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Avoid, That the Ore is regerneratet If you collect it
 
Winston Gutkowski
Bartender
Pie
Posts: 10422
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

HIH

Winston

 
Steven Joost
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I know, I wouldn't ask
 
fred rosenberger
lowercase baba
Bartender
Posts: 12145
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Few people (if any) are going to slog through 200 lines of code trying to figure out an answer to a question that is, at best, vaguely hinted at.

When you post something here, you want to make it as EASY as possible for folks to help you.

I would suggest that, at minimum, you read our HowToAskQuestionsOnJavaRanch FAQ, follow all of Winston's advice, and add a new reply with your trimmed down code and a clear, concise question.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic