World Map - Entity detection

Posted 09 August 2012 - 10:26 PM

Hey DIC. I'm running a simulation style game. No actual interaction with the events by the user.

Basically the program has a world map, vegitation and herbivore/carnivore creatures. The creatures can eat other objects on the map and grow as the simulation progresses. Only problem is I can't seem to figure out a design to make each entity aware of every other entity. I don't want to pass a copy of the world object to each entity because I don't believe Java supports pass by reference for user created classes.

Re: World Map - Entity detection

Posted 13 August 2012 - 12:58 PM

Alright thanks so far. Now as far as actually detecting other creatures, I was thinking that I might have to do some sort of pixel detection.

First thing I do is create several random water pools. Then I create grass. Now I don't want to create grass where the water pools are located, and with my approach to random placement, it's causing me a bit of problems.

Then when the creatures are moving around, naturally I don't want them to move through the water pools. I have a feeling I'll need to design some sort of complex pixel collision class but I'd like your opinions first.

Re: World Map - Entity detection

Posted 13 August 2012 - 01:13 PM

Quote

Alright thanks so far. Now as far as actually detecting other creatures, I was thinking that I might have to do some sort of pixel detection.

Eeh.. why would you be using pixel detection? Your objects have descrete locations, right? Actual plots of space that they occupy? why not use those exact numbers versus something overly complex and fuzzy like a visual pixel?

Quote

First thing I do is create several random water pools. Then I create grass. Now I don't want to create grass where the water pools are located, and with my approach to random placement, it's causing me a bit of problems.

Explain how this is causing "a bit of a problem"...

Quote

Then when the creatures are moving around, naturally I don't want them to move through the water pools. I have a feeling I'll need to design some sort of complex pixel collision class but I'd like your opinions first.

If it's a top down thing then no.. everything's on a grid.. each node of the grid is a "ground" object... ground objects can be water... or grass. If water they can't be moved over.. if grass.. not a problem.