Guest User

Untitled

a guest
Feb 15th, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1.  
  2. type
  3. Game* = object
  4. running*: bool
  5. savePath*: cstring
  6. biosPath*: cstring
  7. file*: File
  8. gamePath: cstring
  9.  
  10. proc log*( output: varargs[string] ): void =
  11. var strBuilder = ""
  12. for line in output:
  13. strBuilder = strBuilder & line
  14.  
  15. echo( "nimCore: ", strBuilder )
  16.  
  17. proc createVideoFrame*( self: Game ): void =
  18. discard
  19.  
  20. proc createAudioFrame*( self: Game ): void =
  21. discard
  22.  
  23. proc pollForInputFrame*( self: Game ): void =
  24. discard
  25.  
  26. proc run*( self: var Game ): void =
  27.  
  28. # Game loop
  29. while self.running:
  30. self.createVideoFrame()
  31. self.createAudioFrame()
  32. self.pollForInputFrame()
  33.  
  34. proc unload*( self: var Game ): void =
  35. if self.file != nil:
  36. self.file.close()
  37. self.running = false
  38. log( "Game unloaded" )
  39. else:
  40. log( "(unload): game was never loaded." )
  41.  
  42. proc load*( self: var Game, filePath: string ): void =
  43. try:
  44. if self.file != nil:
  45. self.file.reopen( filePath )
  46. else:
  47. self.file = open( filePath )
  48. copyMem( addr(filePath), self.gamePath, len(filePath) )
  49. self.running = true
  50. log( "Game loaded" )
  51.  
  52. except IOError:
  53. log( filePath, "(load): was not found. Cannot move beyond this." )
  54.  
  55. proc reset( self: var Game ): void =
  56. self.running = false
  57. self.unload()
  58. self.load( self.gamePath )
  59.  
  60.  
  61. proc initGame*( self: var Game ): void =
  62. self.running = false
  63. self.savePath = "/home/lee/Desktop"
  64. self.biosPath = self.savePath
  65. self.file = nil
  66. self.gamePath = ""
Advertisement
Add Comment
Please, Sign In to add comment