Jump to content

  • Log In with Google      Sign In   
  • Create Account

14 years ago on June 15th Gamedev.net was first launched! We want to thank all of you for being part of our community and hope the best years are ahead of us. Happy birthday Gamedev.net!

willpowered

Member Since 26 Dec 2011
Offline Last Active Today, 04:26 AM
-----

Topics I've Started

Scrolling Horror

04 May 2013 - 11:14 PM

public void scrollUp() {
	if (scroll_index <= 0) return;
	scroll_index--;

	refreshContentsPosition();
}

public void scrollDown() {
	if (scroll_index >= contents.Count() + (2 * 6) - 12) return; //todo: make sure this is the correct index, once you add more levels.
	scroll_index++;

	refreshContentsPosition();
}

 

The code speaks for itself. Obviously, upon review, it was not the correct index.

 

Dunno what came over me when I wrote that.


Layer/Depth management for game objects

03 November 2012 - 11:15 PM

I've been working on a game engine for about a year now, but I still feel like my solution to layer/depth management isn't elegant or robust enough.

Currently, I have the game set up a bunch of layers when it starts, which are essentially just strings representing the layer name- "sprites0", "sprites1", "bg0", "bg1", etc. These strings are mapped to lists of the objects that are on each layer.
When objects are added to the game world, you specify a layer for them to go on, and the object gets added to the corresponding layer's list of objects.

The advantages of this method are that I don't have to sort the objects (because I know the layer order), it's easy to keep different types of objects separate (e.g. players and enemies always go above the background, because the layer "actors" is above the layer "bg"), and it's easy to retrieve all objects on a layer (just get the list associated with the layer name).

The disadvantages are that adding objects is slightly slower (hashtable lookup for the layer name/list), changing an object's layer is difficult, and objects don't know what layer they're on.

Are there any other ways that anybody recommends to manage layers or object depth, or any recommended solutions to mitigate these disadvantages?

PARTNERS