aspose file tools*
The moose likes Beginning Java and the fly likes Collecting Ores Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Collecting Ores" Watch "Collecting Ores" New topic
Author

Collecting Ores

Steven Joost
Greenhorn

Joined: Sep 29, 2012
Posts: 28
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

Joined: May 03, 2008
Posts: 4523
    
    5

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.


luck, db
There are no new questions, but there may be new answers.
Steven Joost
Greenhorn

Joined: Sep 29, 2012
Posts: 28
Avoid, That the Ore is regerneratet If you collect it
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7064
    
  16

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


Isn't it funny how there's always time and money enough to do it WRONG?
Artlicles by Winston can be found here
Steven Joost
Greenhorn

Joined: Sep 29, 2012
Posts: 28
If I know, I wouldn't ask
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10916
    
  12

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.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Collecting Ores
 
Similar Threads
placing images in applets
Problem with GUI
how to make zooming slowly
Movable Objects
How to make Lines I draw Draggable and Moveable etc??