Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


In game periodic notice question


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

#1 Lee_Hillvith   Members   -  Reputation: 143

Like
0Likes
Like

Posted 15 July 2014 - 08:30 PM

Hi, guys

 

I m currently designing a in game notice system, which basically broadcasts in game notices to all player periodically.

I have already implemented one and it works but something tells me it's not good enough, so I am seeking some advice to

make it better. Any suggestion would be appreciated

 

Here is my design

struct Notice
{
  int        NoticeId;              
  char*      pNoticeContent;         
  time_t     NoticeBeginTime;                 
  time_t     NoticeEndTime;                    
  time_t     NoticeGap;           // every NoticeGap , broadcast Notice Once
}

Timer

Timer
struct Timer
{
  time_t     currentTick;
  time_t     Interval;           
}

My initial design is assign every Notice a Timer, and update all these Timer.currentTick in the game loop, so when Timer.currentTick is larger than the Timer.Interval(the NoticeGap), it means this notice can be send now.

 

My question is , when the number of notices increases, There would be more and more Timers to tick, and I do not like this.

How can I use only one Timer to do the same thing?



Sponsor:

#2 frob   Moderators   -  Reputation: 25683

Like
3Likes
Like

Posted 15 July 2014 - 09:00 PM

I've worked on games that relied on them. Ultimately we learned that players hate them. From telemetry we learned that most players don't use them for their intended purposes.

Of course, you might be making a game where players like to interrupt their gameplay by reading the rough equivalents of popup spam windows. Perhaps your game's demographics enjoy reading and re-reading the same text blurb thousands of times. In that case, all you need is a begin and end time index, and the update loop can cycle through them every frame without any performance problems. If the end time index is reached drop the notice, if the begin time index is reached display it if necessary. Iterating over a list of usually zero items but sometimes one or two items is not a performance concern.

Check out my book, Game Development with Unity, aimed at beginners who want to build fun games fast.

Also check out my personal website at bryanwagstaff.com, where I write about assorted stuff.


#3 LorenzoGatti   Crossbones+   -  Reputation: 2869

Like
0Likes
Like

Posted 18 July 2014 - 02:03 AM

I followed you up to "Here is my design". But then, instead of describing your design, you take creating "the rough equivalents of popup spam windows" for granted and give low-level details of how you do it.

Actual design discussion should cover at least:

  • What situations justify disturbing the player with notices (the only ones I've ever seen in games are of a sporadic and blocking nature: network errors, crashing levels, etc.),
  • Pop-up user interfaces vs leaving the notices on permanent display.
  • How to avoid accidentally missing important notices (for instance, a pop-up could be closed without reading it).
  • The time scale of repeated notices: for example, a leaderboard report every week or the status of the current game every 20 seconds.
  • Why did you design all notices to be periodically repeated (which seems a very narrow special case of repeating a notice whenever an event reoccurs).
  • For each notice type, the best time to display it (In many cases, spouting notices whenever the game is started and before actually playing is less annoying and technically simpler than interrupting the game)
  • For each notice type, how can players react to notices in order to dismiss them and/or avoid their reappearance (if you don't have a good answer, the notice is annoying).

After designing these and other aspects of notices, you'll be ready to think of data structures and algorithms that can do everything you need.

Meanwhile:

 

My question is , when the number of notices increases, There would be more and more Timers to tick, and I do not like this.

How can I use only one Timer to do the same thing?

Avoiding explicit timers completely, you can use a priority queue of future events (at time T, display notice N), sorted by scheduled time and for the same time by the order in which events are added.

Given a reference time for each tick of your game loop, repeatedly execute and remove the earliest entry of the event queue until all remaining events in the queue are scheduled in the future. If a notice is periodic, the function that displays it can compute when it should be scheduled again and add the next repeat of that notice to the queue.

This sort of event queue, which is typically used for much more general purposes with much more polymorphic command objects, is a suitable way to process things that will happen later in a uniform way: any system can schedule events, and putting all events in the same place allows managing them smartly (e.g. automatically delaying low priority notices if too many are already on display).


Edited by LorenzoGatti, 18 July 2014 - 02:08 AM.

Produci, consuma, crepa

#4 Stainless   Members   -  Reputation: 1161

Like
0Likes
Like

Posted 18 July 2014 - 02:50 AM

And please don't repeat them all the time!

 

Nothing worse than a game that nags, I have a wife for that.






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