Advertisement
mortdeus

gocos2d

Nov 27th, 2012
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 1.13 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "github.com/mortdeus/gocos2d"
  5. )
  6.  
  7. var (
  8.     director  = new(gocos2d.Director)
  9.     lvl1      = new(Level)
  10.     groundhog = new(Groundhog)
  11. )
  12.  
  13. func main() {
  14.     Init()
  15.     defer Cleanup()
  16.     for director.Running {
  17.         Update()
  18.         Draw()
  19.     }
  20.  
  21. }
  22. func Init() {
  23.     director.Init()
  24.     lvl1.Init("lvl1")
  25.     groundhog.Init("Groundhog")
  26.     lvl1.AddChild(groundhog)
  27.     director.Push(lvl1)
  28. }
  29. func Update() {
  30.     director.Update()
  31. }
  32. func Draw() {
  33.     director.Draw()
  34. }
  35. func Cleanup() {
  36.     director.Cleanup()
  37.     lvl1.RemoveChild("Groundhog")
  38.  
  39. }
  40.  
  41.  
  42. type Level struct {
  43.     *gocos2d.Scene
  44. }
  45.  
  46. func (this *Level) Init(id gocos2d.Tag) {
  47.     this.Scene = new(gocos2d.Scene)
  48.     this.Scene.Init(id)
  49. }
  50. func (this *Level) Update() {
  51.  
  52. }
  53. func (this *Level) Draw() {
  54.  
  55. }
  56. func (this *Level) OnEnter() {
  57.  
  58. }
  59. func (this *Level) OnExit() {
  60.  
  61. }
  62.  
  63. type Groundhog struct {
  64.     *gocos2d.Sprite
  65. }
  66.  
  67. func (this *Groundhog) Init(id gocos2d.Tag) {
  68.     this.Sprite = new(gocos2d.Sprite)
  69.     this.Sprite.Init(id)
  70. }
  71.  
  72. func (this *Groundhog) Update() {
  73.  
  74. }
  75. func (this *Groundhog) Draw() {
  76.  
  77. }
  78. func (this *Groundhog) OnEnter() {
  79.  
  80. }
  81. func (this *Groundhog) OnExit() {
  82.  
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement