Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type
- Game* = object
- running*: bool
- savePath*: cstring
- biosPath*: cstring
- file*: File
- gamePath: cstring
- proc log*( output: varargs[string] ): void =
- var strBuilder = ""
- for line in output:
- strBuilder = strBuilder & line
- echo( "nimCore: ", strBuilder )
- proc createVideoFrame*( self: Game ): void =
- discard
- proc createAudioFrame*( self: Game ): void =
- discard
- proc pollForInputFrame*( self: Game ): void =
- discard
- proc run*( self: var Game ): void =
- # Game loop
- while self.running:
- self.createVideoFrame()
- self.createAudioFrame()
- self.pollForInputFrame()
- proc unload*( self: var Game ): void =
- if self.file != nil:
- self.file.close()
- self.running = false
- log( "Game unloaded" )
- else:
- log( "(unload): game was never loaded." )
- proc load*( self: var Game, filePath: string ): void =
- try:
- if self.file != nil:
- self.file.reopen( filePath )
- else:
- self.file = open( filePath )
- copyMem( addr(filePath), self.gamePath, len(filePath) )
- self.running = true
- log( "Game loaded" )
- except IOError:
- log( filePath, "(load): was not found. Cannot move beyond this." )
- proc reset( self: var Game ): void =
- self.running = false
- self.unload()
- self.load( self.gamePath )
- proc initGame*( self: var Game ): void =
- self.running = false
- self.savePath = "/home/lee/Desktop"
- self.biosPath = self.savePath
- self.file = nil
- self.gamePath = ""
Advertisement
Add Comment
Please, Sign In to add comment