Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This isn't real code, it's just an example of how I'd probably do it.
- public class Frame {
- [...]
- public uint length;
- public string spriteName;
- public uint nextFrame;
- public Frame (uint newLength, string newSpriteName, uint newNextFrame) {
- [...]
- }
- public class Actor {
- [...]
- public uint ticTimeLeft;
- public uint currentFrame;
- public Actor (Frame [] newFrameTable) {
- [...]
- }
- /* ============================================================================================================= */
- [...]
- Frame [] frameTable {
- new Frame (1, "DICKBUTT1", 1),
- new Frame (1, "DICKBUTT2", 2),
- new Frame (1, "DICKBUTT3", 3),
- new Frame (1, "DICKBUTT4", 4),
- new Frame (1, "DICKBUTT5", 5),
- new Frame (1, "DICKBUTT6", 6),
- new Frame (1, "DICKBUTT7", 7),
- new Frame (1, "DICKBUTT8", 8),
- new Frame (1, "DICKBUTT9", 9),
- new Frame (1, "DICKBUTT10", 0),
- }
- actorList.Add (new Actor (frameTable));
- [...]
- /* ============================================================================================================= */
- // Runs the game's ticker
- public void gameLoop {
- [...]
- foreach (Actor actor in actorList) {
- [...]
- if (actor.ticTimeLeft > 0)
- actor.ticTimeLeft--;
- else
- while (actor.ticTimeLeft == 0)
- actor.RunFrame (actor.frameTable [currentFrame].nextFrame);
- [...]
- }
- [...]
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement