Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Level data organisation advice?


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
2 replies to this topic

#1 lion123   Members   -  Reputation: 111

Like
0Likes
Like

Posted 05 March 2013 - 08:11 AM

I'm looking for an effective way to store level data. In my game levels are fully predetermined. At certain times some events should happen, ie: at 180th game tick an enemy2 should appear, at 250th tick some text should appear, at 300th tick boss1 should appear. The problem is that there are different number of arguments for different actions. Arguments for text: message. Arguments for enemy2: HP,x.
Earlier I used to have two arrays: one for storing times of actions, another for strings "action_number|argument0|argument1|...|". So, when time for Nth action has come, Nth string from second array splits into a temporary array with arguments and corresponding function for this action is called.
If you're aware of a more efficient way to organize actions, please respond. Preferred languages are C# and AS.

Sponsor:

#2 Tapped   Members   -  Reputation: 243

Like
2Likes
Like

Posted 05 March 2013 - 12:51 PM

Why not make an event structure like following:





public struct Event_t
{
char eventType;//Byte alignment error, for more memory efficient storage, should this byte be the last element of the struct!
int eventDuration;
short eventSize;
}

Event duration is the time from this event to next event. The event duration can be zero, which means that the event would be processed simultaneously with the next event. The event size are the number of bytes of the event(can be discarded if the size of the types of events are static). From here you can make different Event types. For example:





public struct EventMessage_t
{
int nMessageLength;
string szMessage;
}

After you have loaded the level. You can derive the event structs from a base event struct. Then you can make an array of base event structs, which you can easily process, by casting the base struct to the right event type structure.


Edited by Tapped, 05 March 2013 - 12:58 PM.


#3 lion123   Members   -  Reputation: 111

Like
0Likes
Like

Posted 06 March 2013 - 08:25 PM

Thanks for the advice.






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