Jump to content

  • Log In with Google      Sign In   
  • Create Account


Layer and Frame?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 HeExists   Members   -  Reputation: 193

Like
0Likes
Like

Posted 15 June 2014 - 01:30 PM

Hi,

   I am making a small game, where, now I want to implement layer and frame. Something like timeline. Each scene will consists of some layer and each layer will have some frames. Each frame will be used as a level and each layer will decide which entity will be visible. If a layer is invisible, all the entity belongs to that layer will be invisible.

   I just need some idea how do I implement them! As a class, struct or vectors etc. I only need idea, nothing else.

 

Thank you.


Edited by HeExists, 15 June 2014 - 01:31 PM.


Sponsor:

#2 Servant of the Lord   Crossbones+   -  Reputation: 18734

Like
0Likes
Like

Posted 15 June 2014 - 02:28 PM

I'm not sure I understand what you mean. Could you try re-explaining it another way? Maybe do a very rough mockup in MS Paint to help me understand it better?


It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.
All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.
Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal

[Fly with me on Twitter] [Google+] [My broken website]

[Need web hosting? I personally like A Small Orange]


#3 Tom Sloper   Moderators   -  Reputation: 9677

Like
0Likes
Like

Posted 15 June 2014 - 02:36 PM

I just need some idea how do I implement [layers and frames]! As a class, struct or vectors etc. I only need idea, nothing else.


This doesn't sound like a Game Design question. I'm moving it elsewhere.
-- Tom Sloper
Sloperama Productions
Making games fun and getting them done.
www.sloperama.com

Please do not PM me. My email address is easy to find, but note that I do not give private advice.

#4 HeExists   Members   -  Reputation: 193

Like
0Likes
Like

Posted 15 June 2014 - 03:08 PM

Sorry for not explaining clearly. Generaly a timeline looks like this -

http://wam.inrialpes.fr/publications/2003/smileurope_editingtimelines/timeline_view.png

I also want something like this, but it will not be visible graphically in my game. It will only work internally. What I wanted to do is, load the resources at the initialization and setup all the levels at the same time, frame by frame. Each frame will be a separate level. And during runtime, just change the frame to change the level. Each level will have some layers, which will decide the visibility of the entities. What I wanted to know is, how do I implement them, as a class, as a struct, as a vector or something else. A simple example will be, Flash actionScript 2. The levels are created frame by frame during initialization and nothing is freed/loaded during runtime.



#5 papulko   Members   -  Reputation: 868

Like
0Likes
Like

Posted 15 June 2014 - 05:58 PM

I think you need to specify what exactly some of your concept keywords actually means. We can't help you if we don't understand your concept of:

  • Level
  • Frame
  • Layer


#6 SeanMiddleditch   Members   -  Reputation: 5288

Like
4Likes
Like

Posted 15 June 2014 - 06:04 PM

as a class, as a struct, as a vector or something else.


All of the above? It's not going to be "a" class or "a" vector. You're asking for a syntactical solution to a complex question of data structures and algorithms.

A typical way of dealing with this is keeping a list of events. For instance, something like:
 
enum class FrameEventTypes
{
  Show,
  Hide,
};

struct FrameEventRecord
{
  double time =0.0; 
  int layerId = 0;
  FrameEventTypes type = FrameEventTypes::Show;
};

class Frame
{
  vector<Layer> layers;
  vector<FramgEventRecord> events;
  double time = 0.0;
  size_t next = 0;

  void ExecuteEvent(size_t index);

public:
  void Update(double delta_time);
};
The list of events is sorted in order of `time`. Then you iterate over the list of events with a delta time and execute them as needed:
 
void Frame::Update(double dt)
{
  time += dt;
  while (next < events.size() && events[next].time <= time)
    ExecuteEvent(next++);
}

void Frame::ExecuteEvent(size_t index)
{
  switch (events[index].type)
  {
  case FrameEventTypes::Show:
    layers[events[index].layer].Show();
    break;
  case FrameEventTypes::Hide:
    layers[events[index].layer].Hide();
    break;
  }
}
And then you can add in more events as needed. You might have events to add or remove elements, show or hide individual elements, play sounds, run animations, whatever.

#7 HeExists   Members   -  Reputation: 193

Like
0Likes
Like

Posted 15 June 2014 - 11:15 PM

It is a 2d game. So basically what I am trying to do is, rather then making game states and clrearing/loading the game resources during runtime, I am thinking to load everything at the application start and set all levels frame by frame. Then when I have to change the level, I will just skip the frame. I have implemented the scene, resource loading etc, now I have to implement only the layer and frames. it is like -

Scene -- Layers -- Frames

If I hide one layer, every entity belongs to that layer will hide and remain invisible to all frames(levels).

 

Thank you for your reply.



#8 Aardvajk   Crossbones+   -  Reputation: 5968

Like
2Likes
Like

Posted 16 June 2014 - 04:10 AM

You are over-thinking this. If for some reason you need to load everything at startup (highly unlikely actually but hey-ho) then design your architecture so that any given level or however you compartmentalise is stored in some kind of structure hierachy - e.g. a Level class, containing a list of Entity instances etc.

 

All the code then uses a reference to the current structure. You can load all the structures at startup and just change this reference when you want to switch levels.

 

All this hokum about layers and frames is entirely distracting from a far simpler question.



#9 HeExists   Members   -  Reputation: 193

Like
0Likes
Like

Posted 16 June 2014 - 07:30 AM

I have already implemented this and it is working as expected :)

 

Thanks for the reply.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS