Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Snake Blisken on Wed 30/11/2005 07:28:16

Title: Creating a class(SOLVED)
Post by: Snake Blisken on Wed 30/11/2005 07:28:16
The manual mentions that object oriented type stuff is possible, and looking at the Zoom module created by SSH, I can see where he created what appears to be an instance of the class Zoom. He called it zzz.

Where is the class Zoom defined? Anyone care to post a small class definition I can peek at to get the idea of how they are structured in AGS? Any other tips, help, anything you have to say on the subject is greatly appreciated.

Note that I am pretty familiar with classes and instances in C++.
Title: Re: Creating a class
Post by: strazer on Wed 30/11/2005 07:35:32
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=23527.msg247166#msg247166
Title: Re: Creating a class
Post by: Snake Blisken on Wed 30/11/2005 08:03:44
Quote from: strazer on Wed 30/11/2005 07:35:32
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=23527.msg247166#msg247166

Thanks so much. That got me started in the right direction.
Title: Re: Creating a class
Post by: DoorKnobHandle on Thu 01/12/2005 20:38:38
I will hijack this, because I have a small question that fits the thread description perfectly and since the original question is answered, I don't see nothing wrong with it...

Scotch recently mentioned, that there is now the possibility to add functions to a struct (thus acting pretty much like a c++ class). How does that work? I searched but couldn't find anything and scotch didn't answer to my PM...

Thanks!
Title: Re: Creating a class
Post by: monkey0506 on Thu 01/12/2005 20:48:13
You import the function:

struct ExampleStruct {
  import int DoSomething(int param);
  import static void DoNothing();
  protected int value;
  };

int ExampleStruct::DoSomething(int param) {
  this.value += param;
  return this.value;
  }

static void ExampleStruct::DoNothing() {
  /* this function does nothing, but note due to it's static nature it does not contain a 'this' pointer or access to member variables */
  }

// in game_start
ExampleStruct ExampleItem;
ExampleItem.DoSomething(5);
ExampleStruct.DoNothing();
Title: Re: Creating a class
Post by: DoorKnobHandle on Thu 01/12/2005 20:50:53
Ah, thanks a bunch, monkey_05_06!