Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 1.73 KB  |  hits: 7  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. //Many of these throughout the rule section of the game.
  2. //They are loosely connected by the parameters.
  3. public static void RatCollision(GameLevel level, Collision<Hero,Rat> impact)
  4. {
  5.         impact.First.HP--;
  6.         impact.Second.Movement.bounce();
  7.         level.Sounds.Play(Sounds.RatSqueal);
  8. }
  9.  
  10.  
  11. // The engine will take all rules and build the game loop itself.  They are not manually connected.
  12. // Generated at compile time:
  13. foreach(var collision in collisionList)
  14. {
  15.         CollisionType1 = Typeof(collision.First);
  16.         CollisionType2 = Typeof(collision.First);
  17.  
  18.         If (CollisionType1 == Hero && CollisionType2 == Rat)
  19.         {
  20.                 HeroCollisions.RatImpact(level, new Collision(collision.First, collision.Second));
  21.         }
  22.         else if (CollisionType1 == Rat && CollisionType2 == Hero)
  23.         {
  24.                 HeroCollisions.RatImpact(level, new Collision(collision.Second, collision.First));
  25.         }
  26.  
  27.         //Many more collision type checks and calls.
  28. }
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35. //A game of tag in pseudocode.
  36. class gameObject<T>
  37. {
  38.         T Movement
  39.         int x
  40.         int y
  41.         int width
  42.         int height
  43.        
  44.         move()
  45.         render()
  46. }
  47.  
  48. class Hero : gameObject<Player8WayMovement>
  49. {
  50. }
  51.  
  52. class Opponent : gameObject<ComputerAvoidance8WayMovement>
  53. {
  54.         avoid(gameObject)
  55.  
  56. }
  57.  
  58.  
  59. //Level:
  60. main
  61. {
  62.         var hero = new Hero()
  63.         Add(hero)
  64.         var opponent = new Opponent()
  65.         opponent.avoid(hero)
  66.         Add(opponent)
  67. }
  68.  
  69.  
  70.  
  71. //rules:
  72. public static function win(Collision<Hero,Opponent> impact, gameLevel level)
  73. {
  74.         impact.Second.Destroy()
  75.         level.ShowMessage("You caught him!")
  76.         level.Sound.Play(Sounds.Fanfair)
  77. }
  78.  
  79. public static function mockingSound(GameLevel level)
  80. {
  81.         RestrictBySeconds(10)
  82.        
  83.         level.Sound.Play(Sounds.OpponentMocking)
  84. }
  85.  
  86. public static function addObstacle(GameLevel level)
  87. {
  88.         RestrictBySeconds(14)
  89.         var pointBetweenPlayerAndOpponent = point(5,5) //for example
  90.         level.CreateObject<obstacle>(point)
  91. }