Welcome! Log In Create A New Profile


Game conceptualization

Posted by dancinninja 
Game conceptualization
March 31, 2010 04:58AM
Hey everybody, I am having trouble conceptualizing how to go about this project, and I need some help. For example, to have two people talking on screen. The events are as follows:

Person A says "I enjoy fun, much more than doing laundry." Person B says "I know man! It's like we're supposed to wear clean clothes all the time or something" The sound of a bag of laundry hitting the floor is heard at the word "clean" while Person A makes a disgusted face. [...]

After awhile, I have arrived at a possible solution to this: a queue. The events could be expressed as so:

1. Make Person A say "I enjoy fun, much more than doing laundry."
2. Make Person B say "I know man! It's like we're supposed to wear"
3. Play the sound of laundry bag landing
4. Change Person A's expression
5. Make Person B say "clean clothes all the time or something."
6. Wait for the player to click the "next" button to move on to more text.

...And have them play out in order. When one is done (like when we've scrolled through all the text), it will move on and "play" the next one in line.

The problem is in the implementation. If I had a linked list format, that might work, I think. This is where stuff gets fuzzy and I need to bounce ideas off of someone other than the strange man who lives in my mirror.

Here's some pseudo code of my idea:

class Event{
    virtual bool start() = 0;
    bool done;	 //Tells us when to move to the next event

class Speech : public Event{
    Speech(PersonObject person, string text);
    bool start(){
         // Display text
class Sound : public Event{
    Sound(string soundFile);
    bool start(){
         // Play sound
class Pose : public Event{
    Pose(PersonObject person, string whichPose);
    bool start(){
        //Change the person's emotional state and play that animation

queue.enqueue (new Speech(PersonA, "I enjoy fun...")  );
queue.enqueue (new Speech(PersonB, "I know man...")  );
queue.enqueue (new Sound( "laundrybag.ogg")  );
queue.enqueue (new Pose( PersonA, "yuck")  );

Did that garbled mess make sense? Any thoughts would be greatly appreciated. Thanks all!
Re: Game conceptualization
April 01, 2010 03:01PM
Yeah, that looks good! At least I can't find any problems with it except I would have used a pointer to queue and done the last part like this
queue->enqueue (new Speech(PersonA, "I enjoy fun...")  );

(but I doubt that's even a problem)
Re: Game conceptualization
April 01, 2010 05:57PM
I personally would use lua for these kinds of things. Makes it easy to modify the events without recompiling. And gives a ton of flexibility.

By making use of the "lua_yield" function you can make scripts like this:
Say(PersonA, "Bla bla bla...");
Say(PersonB, "Bla bla bla...");
SetPose(PersonA, "Cheer");
if ChooseAction("Run away", "Kick in the nuts") == "Run away" then
  SetPose(PersonA, "Win");
  SetPose(PersonA, "Death");
Where each of the functions waits till that action was completed.

(Lua documentation only talks about the lua_yield + lua_resume API with new threads, but you can also use them on the main thread)
Re: Game conceptualization
April 02, 2010 10:43PM
That is fascinating! I never would have thought of that. I'll have to brush up on my Lua skills. Am I correct in assuming that this is implementing a thread, or rather (in this case) highjacking the main thread? I'll have to brush up on that too...

Re: Game conceptualization
April 03, 2010 11:14AM
You can run it in a different thread, but I kinda hate multithreaded programming. With the yield/resume you can run it in your main thread. I could create some example code if you wish.
Re: Game conceptualization
April 06, 2010 05:58PM
Very simple example: [pastebin.org]

Run it with this script:
And it will print Start!, wait 1 second and then print End! but during the 1 second sleep you can still do processing in the main loop.
Re: Game conceptualization
April 06, 2010 08:32PM
Thank you so much! I'm still working through it, trying to piece everything together, but it's a great start! Thanks again.
Sorry, only registered users may post in this forum.

Click here to login