aboutsummaryrefslogtreecommitdiff
path: root/unicorn/FakeUnicorn.go
diff options
context:
space:
mode:
authorMartin Ashby <martin@martin-laptop.lan>2018-05-28 16:31:18 +0100
committerMartin Ashby <martin@martin-laptop.lan>2018-05-28 16:31:18 +0100
commit28f0ac19eb3b42601b0511131b5e39c77b80da9c (patch)
treea0765d2742926bb418ce623175876a68cb000c8b /unicorn/FakeUnicorn.go
parent5766b0c285052d48ab7756c9c3eef6ae41ecd36e (diff)
parentf20896ef3b147ac07769eb36c67ba436c6d2ed22 (diff)
downloadunicornpaint-28f0ac19eb3b42601b0511131b5e39c77b80da9c.tar.gz
unicornpaint-28f0ac19eb3b42601b0511131b5e39c77b80da9c.tar.bz2
unicornpaint-28f0ac19eb3b42601b0511131b5e39c77b80da9c.tar.xz
unicornpaint-28f0ac19eb3b42601b0511131b5e39c77b80da9c.zip
Merge branch 'master' of github.com:MFAshby/unicornpaint
Diffstat (limited to 'unicorn/FakeUnicorn.go')
-rw-r--r--unicorn/FakeUnicorn.go66
1 files changed, 6 insertions, 60 deletions
diff --git a/unicorn/FakeUnicorn.go b/unicorn/FakeUnicorn.go
index eaec4f2..8db71d5 100644
--- a/unicorn/FakeUnicorn.go
+++ b/unicorn/FakeUnicorn.go
@@ -8,10 +8,7 @@ import (
type FakeUnicorn struct {
BaseUnicorn
- displayWidth int32
- displayHeight int32
- window *sdl.Window
- renderer *sdl.Renderer
+ *BaseFakeUnicorn
}
// NewUnicorn ...
@@ -19,7 +16,9 @@ type FakeUnicorn struct {
func NewUnicorn() (*FakeUnicorn, error) {
width := uint8(16)
height := uint8(16)
- if err := sdl.Init(sdl.INIT_EVERYTHING); err != nil {
+
+ baseFake, err := NewBaseFakeUnicorn(300, 300)
+ if err != nil {
return nil, err
}
@@ -27,47 +26,10 @@ func NewUnicorn() (*FakeUnicorn, error) {
BaseUnicorn{
pixels: makePixels(width, height),
},
- 300,
- 300,
- nil,
- nil,
- }
- if err := unicorn.createWindow(); err != nil {
- unicorn.Close()
- return nil, err
- }
- if err := unicorn.createRenderer(); err != nil {
- unicorn.Close()
- return nil, err
+ baseFake,
}
- return unicorn, nil
-}
-func (f *FakeUnicorn) createWindow() error {
- window, err := sdl.CreateWindow("Fake Unicorn",
- sdl.WINDOWPOS_UNDEFINED,
- sdl.WINDOWPOS_UNDEFINED,
- f.displayWidth,
- f.displayHeight,
- sdl.WINDOW_SHOWN)
- f.window = window
- return err
-}
-
-func (f *FakeUnicorn) createRenderer() error {
- renderer, err := sdl.CreateRenderer(f.window, -1, sdl.RENDERER_ACCELERATED)
- f.renderer = renderer
- return err
-}
-
-func (f *FakeUnicorn) Close() error {
- if f.window != nil {
- f.window.Destroy()
- }
- if f.renderer != nil {
- f.renderer.Destroy()
- }
- return nil
+ return unicorn, nil
}
func (f *FakeUnicorn) Show() {
@@ -96,19 +58,3 @@ func (f *FakeUnicorn) Show() {
func (f *FakeUnicorn) Off() {
f.Close()
}
-
-// MainLoop ...
-// Handle UI events so OS doesn't think we're frozen
-func (f *FakeUnicorn) MainLoop() {
- running := true
- for running {
- for event := sdl.PollEvent(); event != nil; event = sdl.PollEvent() {
- switch event.(type) {
- case *sdl.QuitEvent:
- println("Quit")
- running = false
- break
- }
- }
- }
-}