Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. import bgfx, glm
  2.  
  3. import
  4. asset
  5. , dEngine
  6. , app
  7. , log
  8. , spritebatch
  9. , texture
  10.  
  11. type
  12. Derelict = ref object of AbstractApp
  13. batch: SpriteBatch
  14.  
  15. var derelict : Derelict
  16.  
  17. proc init*(derelict: Derelict) =
  18. logInfo("Initializing derelict...")
  19. load("assets/textures/spritesheet.png")
  20. # load("assets/textures/megaman.png")
  21.  
  22. derelict.batch = newSpriteBatch(1000, 0)
  23.  
  24. proc update(derelict: Derelict, deltaTime: float) =
  25. discard
  26.  
  27. proc render(derelict: Derelict, deltaTime: float) =
  28. var textureRegion = newTextureRegion(Texture(get("assets/textures/spritesheet.png")), 0, 0, 24, 24)
  29.  
  30. #let texture = Texture(get("assets/textures/megaman.png"))
  31.  
  32. derelict.batch.begin()
  33. #derelict.batch.draw(textureRegion, 100.0, 100.0, 0xffffffff'u32)
  34. derelict.batch.draw(Texture(get("assets/textures/spritesheet.png")), 100.0, 100.0, 24, 48, 0xffffffff'u32)
  35. #derelict.batch.draw(texture, 0.0, 0.0, float texture.width, float texture.height, 0xffffffff'u32, [0.2'f32, 0.2'f32 , 1.0'f32])
  36. derelict.batch.`end`()
  37.  
  38. proc dispose(derelict: Derelict) =
  39. unload("assets/textures/spritesheet.png")
  40. #unload("assets/textures/megaman.png")
  41. destroy(derelict.batch)
  42.  
  43.  
  44. proc newGame() : Derelict =
  45. result = Derelict()
  46.  
  47. proc toDerelict*(derelict: Derelict) : IApp =
  48. return (
  49. init: proc() = derelict.init()
  50. , update: proc(deltaTime: float) = derelict.update(deltaTime)
  51. , render: proc(deltaTime: float) = derelict.render(deltaTime)
  52. , dispose: proc() = derelict.dispose()
  53. )
  54.  
  55. derelict = newGame()
  56. let engine = newDEngine(toDerelict(derelict), false)
  57. engine.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement