Jump to content

  • Log In with Google      Sign In   
  • Create Account

ultramailman

Member Since 13 Oct 2012
Offline Last Active Dec 29 2015 02:28 AM

Posts I've Made

In Topic: How to initialize a reference variable in a Quadtree?

31 July 2015 - 01:13 AM

Hey SteveHatcher,

 

I have no idea what multiple managers can achieve, and I wasn't suggesting you to have multiple managers. I was just remarking that *if* for some reason you need multiple managers, passing the manager as a parameter would be the way to go as passing parameter provides the most flexibility out of all the other options. This goes for other similar situations as well.

 

Like BitMaster said, a static variable in a class is just like a global variable outside a class. It may be what you need if you are very sure you will only need one manager.

 

I don't have much to say about your quadtree, since I don't know much about using quadtrees and ECS together. I remember L.Spiro has an article on efficient quad trees though. Here it is: http://lspiroengine.com/?p=530


In Topic: How to initialize a reference variable in a Quadtree?

28 July 2015 - 10:55 PM

If you really don't want to keep a member reference variable to the entity manager, you could pass it as a function parameter to the functions that actually need it.

 

Another way is to make the entity manager a global variable.

 

Personally I think the member reference variable approach is fine, it's pretty simple. Passing the manager as a function parameter is more flexible, but you probably don't need it unless you are considering the possibility of using the same tree node on different entity managers . On the other side, you have the global entity manager approach. That's a fine approach if you will only ever use one manager.


In Topic: Java Challange

30 April 2015 - 11:49 PM

Ooo can somebody explain deftware's code? I didn't know .java files can look like that (looks like some kind of assembly?). How does it call checkCubicRoot? Also Mr L, are you accepting trick answers or are you really looking for a specific mathy solution?


In Topic: Trying to make 2D tile based game in Dart...2D array index confusion nightmar...

08 March 2015 - 10:46 AM

If you are having troubles with ordering of indices, you can make yourself a function that accepts indices in whatever order you want.

 

item = array.atXY(x, y)


In Topic: I think I don't understand dynamic memory

01 March 2015 - 02:16 PM

Maybe I can try using analogy to explain it.

 

automatic allocation:

Imagine there is a restaurant with many tables and seats. You and your family go in the restaurant. The mute receptionist sees that you have 5 people, and leads you to a table G, with 5 seats. Now table G is occupied by your family. When you are done eating, you leave the restaurant. The receptionist sees that and table G is unoccupied. The next family of 5 that comes are able to use table G. This whole time, you did not speak to the receptionist at all, because he is mute.

 

dynamic allocation:

Now Imagine there is another restaurant with many tables and seats. You and your family go in the restaurant. The blind receptionist asks "how many people"? and you tell him 5. The blind receptionist finds an unoccupied table E with enough seats for 5 people. He's blind so he doesn't want to talk and trip, so he tells you where the table is. Now table E is occupied by your family. When you are done eating, you leave the restaurant. However, you forgot to tell the blind receptionist that you left. He still thinks table E is occupied by you, so table E will not be given to any customers.

 

tables and seats = memory, since they are space.

customers = data, since they are the contents that occupy space.

the act of entering/leaving restaurant = entering and leaving a scope.

the act of being led to a table by the mute receptionist = automatic allocation.

the act of telling the blind receptionist how many seats you need at the minimum, and getting the location of the seats/tables = dynamic allocation.

 

This analogy omits some details, but I hope that helps.


PARTNERS