func NewApp(conf Config) *App { runtime.LockOSThread() err := sdl.Init(sdl.INIT_EVERYTHING &^ sdl.INIT_AUDIO) ck(err) sdl.SetHint(sdl.HINT_RENDER_SCALE_QUALITY, "best") wflag := sdl.WINDOW_RESIZABLE if conf.Fullscreen { wflag |= sdl.WINDOW_FULLSCREEN_DESKTOP } window, renderer, err := sdl.CreateWindowAndRenderer(DisplayWidth, DisplayHeight, wflag) ck(err) window.SetTitle("Arkanoid") renderer.SetLogicalSize(DisplayWidth, DisplayHeight) return &App{ window: window, renderer: renderer, } }
func main() { log.SetFlags(0) runtime.LockOSThread() flag.Parse() err := sdl.Init(sdl.INIT_VIDEO | sdl.INIT_TIMER) ck(err) defer sdl.Quit() sdl.SetHint(sdl.HINT_RENDER_SCALE_QUALITY, "best") window, renderer, err = sdl.CreateWindowAndRenderer(W, H, sdl.WINDOW_RESIZABLE) ck(err) renderer.SetLogicalSize(W, H) window.SetTitle("Cat Clock") cat = loadImage(catb) eyes = loadImage(eyesb) hand.minute = makeTexture(ML*2, ML*2) hand.hour = makeTexture(HL+5, HL+5) for i := 0; i <= C; i++ { tail = append(tail, renderTail(float64(i)*math.Pi/C)) eye = append(eye, renderEye(float64(i)*math.Pi/C)) } renderer.SetTarget(nil) ticker := time.Tick(FPS) for { event() select { case <-ticker: update() default: } draw() } }