Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Way to treat game entities  (Read 1783 times)
0 Members and 1 Guest are viewing this topic.
Offline chrbarrol

Senior Newbie

« Posted 2010-05-28 22:34:33 »

I'm kinda stuck trying to find an effective way to treat the entities in my game, currently everything is stored in their own array so there is one array called terrain_content which contains the grass and rocks and soon of my map then there is one for trees, one for enemies and so on, so if i want to hit something with my sword I have to look up what is in the enemy array at the the location above the one the player is in, this poses many problems so what I'm asking is what is a good way for me to handle enemies so I can easily acquire them, run methods trough them and display them on my screen and so on?
Offline Markus_Persson

JGO Wizard

Medals: 19
Projects: 19

Mojang Specifications

« Reply #1 - Posted 2010-05-29 10:50:16 »

I usually end up storing entities in two ways, one list of ALL entities for when I want to iterate over them all (like to drive game ticks or such), and one spatial structure (for example just having a List<Entity> in each Tile on the level, if the level is small, or a quadtree for large levels) for quickly finding entities in an area of the world.

Storing stuff twice is slightly more bug prone, so I'd suggest just using one, however. If iterating through your spatial structure is fast, just use that one.

Play Minecraft!
Offline JL235

JGO Coder

Medals: 10

« Reply #2 - Posted 2010-05-31 22:50:04 »

This sounds similar to what was discussed in this topic. Does this help solve your issues?

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline appel

JGO Wizard

Medals: 80
Projects: 4

I always win!

« Reply #3 - Posted 2010-05-31 23:35:40 »

Component based entity system is the way to go, well, IMO Smiley
Pages: [1]
  ignore  |  Print  

EgonOlsen (47 views)
2018-06-10 19:43:48

EgonOlsen (29 views)
2018-06-10 19:43:44

EgonOlsen (49 views)
2018-06-10 19:43:20

DesertCoockie (214 views)
2018-05-13 18:23:11

nelsongames (130 views)
2018-04-24 18:15:36

nelsongames (129 views)
2018-04-24 18:14:32

ivj94 (870 views)
2018-03-24 14:47:39

ivj94 (131 views)
2018-03-24 14:46:31

ivj94 (782 views)
2018-03-24 14:43:53

Solater (146 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!