title: How to implement scripted events for videogame design?
body: <p>I'm building a game in C++ (using SDL) for a college project, I'm trying to figure out how to script events that happens when a player does something, or some time passes etc.</p>
  
  <p>I have a and idea of how to do it but I don't want to go against how it's commonly done.</p>
  
  <hr>
  
  <p>Right now I have a class called Obj from where enemies, items and the player are child classes, my idea is to add 3 public variables to it like this:</p>
  
  <pre><code>class Obj{
      int eventDeath,eventTouch,eventTalk,eventMeet;
  }
  </code></pre>
  
  <p>Then I could create an Obj with eventDeath=1 and when it died it would fire event(1). event() would be something like this:</p>
  
  <pre><code>void event(int n){
     switch(n){
     case 1: 
        dialog("I'm dying");
        break;   
     }
  }
  </code></pre>
  
  <p>I could also add invisible "Obj" in specific places for when a player walks over a certain place. I don't know if this is a good idea but I can't think of other means to do it. How is it commonly done? Also how do I keep track of events that already happened?</p>