Ejemplo n.º 1
0
func studioUpdate(window *sdl.Window, rend *sdl.Renderer, screen *Screen) bool {
	var event sdl.Event
	running := true
	for (&event).Poll() {
		switch e := (&event).Get().(type) {
		case sdl.QuitEvent:
			running = false

		case sdl.KeyboardEvent:
			if e.Keysym.Keycode == sdl.K_ESCAPE {
				running = false
			}

		case sdl.MouseMotionEvent:
			screen.stack.OnMouseMotionEvent(&e)

		case sdl.MouseButtonEvent:
			screen.stack.OnMouseButtonEvent(&e)
		}
	}

	neww, newh := window.GetSize()
	screen.UpdateLayout(sdl.Rect{0, 0, int32(neww), int32(newh)})

	//screen.UpdateAnimations(framerate.Delta())

	rend.SetDrawBlendMode(sdl.BLENDMODE_NONE)
	rend.SetDrawColor(screen.rsc.BackgroundColor)
	rend.Clear()
	rend.SetDrawBlendMode(sdl.BLENDMODE_BLEND)
	screen.Draw(rend)
	rend.Present()
	screen.framerate.FramerateDelay()

	return running
}
Ejemplo n.º 2
0
func studioSetup(window *sdl.Window, rend *sdl.Renderer, tracks []string) *Screen {
	rsc := &Resources{}
	rsc.Load(rend)
	//defer rsc.Free()

	w, h := window.GetSize()
	//neww, newh := w, h
	screen := &Screen{}
	screen.Init(sdl.Rect{0, 0, int32(w), int32(h)}, rsc, tracks)
	screen.stack.Add(screen.F1)
	screen.stack.Add(screen.F2)
	screen.stack.Add(screen.Play)
	screen.stack.Add(screen.Stop)
	screen.stack.Add(screen.Canvas)
	//defer screen.Destroy()

	screen.framerate = gfx.NewFramerate()
	screen.framerate.SetFramerate(60)

	return screen
	//running := true
	//for running {
	//}
}