Advertisement
Chronos_Ouroboros

Frame Table Thing

Jul 7th, 2015
486
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.55 KB | None | 0 0
  1. // This isn't real code, it's just an example of how I'd probably do it.
  2. public class Frame {
  3.     [...]
  4.     public uint length;
  5.     public string spriteName;
  6.     public uint nextFrame;
  7.     public Frame (uint newLength, string newSpriteName, uint newNextFrame) {
  8.     [...]
  9. }
  10. public class Actor {
  11.     [...]
  12.     public uint ticTimeLeft;
  13.     public uint currentFrame;
  14.     public Actor (Frame [] newFrameTable) {
  15.     [...]
  16. }
  17.  
  18. /* ============================================================================================================= */
  19.  
  20.     [...]
  21.         Frame [] frameTable {
  22.             new Frame (1, "DICKBUTT1", 1),
  23.             new Frame (1, "DICKBUTT2", 2),
  24.             new Frame (1, "DICKBUTT3", 3),
  25.             new Frame (1, "DICKBUTT4", 4),
  26.             new Frame (1, "DICKBUTT5", 5),
  27.             new Frame (1, "DICKBUTT6", 6),
  28.             new Frame (1, "DICKBUTT7", 7),
  29.             new Frame (1, "DICKBUTT8", 8),
  30.             new Frame (1, "DICKBUTT9", 9),
  31.             new Frame (1, "DICKBUTT10", 0),
  32.         }
  33.  
  34.         actorList.Add (new Actor (frameTable));
  35.     [...]
  36.  
  37. /* ============================================================================================================= */
  38.  
  39. // Runs the game's ticker
  40. public void gameLoop {
  41.     [...]
  42.     foreach (Actor actor in actorList) {
  43.         [...]
  44.         if (actor.ticTimeLeft > 0)
  45.             actor.ticTimeLeft--;
  46.         else
  47.             while (actor.ticTimeLeft == 0)
  48.                 actor.RunFrame (actor.frameTable [currentFrame].nextFrame);
  49.         [...]
  50.     }
  51.     [...]
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement