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.
Any design ideas here to help me out?
World Map - Entity detection
Page 1 of 14 Replies - 598 Views - Last Post: 13 August 2012 - 01:13 PM
Replies To: World Map - Entity detection
#2
Re: World Map - Entity detection
Posted 09 August 2012 - 10:53 PM
One possibility - when each creature is being updated by the engine it can ask for an array of X creatures "visible" around it..
#3
Re: World Map - Entity detection
Posted 10 August 2012 - 01:22 PM
More about passing objects around in Java... Tricky stuff. I think you could pass a reference to the world object, and as long as you only look at the variables inside it, you should be fine.
#4
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.
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.
#5
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.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote








|