4 Replies - 734 Views - Last Post: 13 August 2012 - 01:13 PM Rate Topic: -----

#1 nunc  Icon User is offline

  • D.I.C Head

Reputation: 36
  • View blog
  • Posts: 131
  • Joined: 20-November 11

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.

Any design ideas here to help me out?

Is This A Good Question/Topic? 0
  • +

Replies To: World Map - Entity detection

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9207
  • View blog
  • Posts: 34,589
  • Joined: 12-June 08

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..
Was This Post Helpful? 2
  • +
  • -

#3 Tayacan  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 145
  • View blog
  • Posts: 275
  • Joined: 18-January 11

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.
Was This Post Helpful? 1
  • +
  • -

#4 nunc  Icon User is offline

  • D.I.C Head

Reputation: 36
  • View blog
  • Posts: 131
  • Joined: 20-November 11

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.
Was This Post Helpful? 0
  • +
  • -

#5 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9207
  • View blog
  • Posts: 34,589
  • Joined: 12-June 08

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.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1