Advertisement
snake5

SGScript - expected game code from now on

May 1st, 2014
439
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // components
  2.  
  3. function Component_CharacterPhysics( pos )
  4. {
  5.     this.position = clone( pos );
  6.     // ...
  7. }
  8.  
  9. function Component_CharacterPhysics_Tick( delta )
  10. {
  11.     this.position.y += delta;
  12.     // ...
  13. }
  14.  
  15. function Component_Sprite( texture )
  16. {
  17.     this.sprite = MakeSprite( texture );
  18. }
  19.  
  20. function Component_Sprite_Draw()
  21. {
  22.     if( @this.sprite )
  23.         DrawSprite( this.sprite );
  24. }
  25.  
  26. // entities
  27.  
  28. function Entity_Player( params )
  29. {
  30.     Player =
  31.     {
  32.     };
  33.    
  34.     Player!Component_CharacterPhysics( params.position );
  35.     Player!Component_Sprite( "textures/player.png" );
  36.    
  37.     function Player.tick( delta )
  38.     {
  39.         this!Component_CharacterPhysics_Tick( delta );
  40.     }
  41.    
  42.     function Player.draw()
  43.     {
  44.         this!Component_Sprite_Draw();
  45.     }
  46.    
  47.     return Player;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement