Advertisement
snake5

SGScript - OOP syntax prototype

Feb 22nd, 2014
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Renderable
  2. {
  3.     - render();
  4. }
  5. class Thing
  6. {
  7.     name = "unnamed thing";
  8.     size = 0;
  9.     data = null;
  10.    
  11.     > types = {};
  12.    
  13.     > __construct()
  14.     {
  15.         this.data = {};
  16.     }
  17.     > rename( name )
  18.     {
  19.         this.name = name;
  20.     }
  21.     - move( pos );
  22.     > create( type )
  23.     {
  24.         found_class = @Thing.types[ type ];
  25.         return new found_class();
  26.     }
  27. }
  28. class Box extends Thing implements Renderable
  29. {
  30.     position = vec3(0,0,0);
  31.     > move( pos )
  32.     {
  33.         this.position = pos;
  34.     }
  35.     > render()
  36.     {
  37.         print "#";
  38.     }
  39. }
  40. Thing.types[ "Box" ] = Box;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement