Initial commit

This commit is contained in:
Noah 2017-10-26 18:03:11 -07:00
commit 8c884d4cab
6 changed files with 143 additions and 0 deletions

23
.editorconfig Normal file
View File

@ -0,0 +1,23 @@
# Top-most EditorConfig file
root = true
# Common settings for all files. I don't specify indent type here, because
# some EditorConfig implementations (notably Atom) will cause default settings
# and behaviors (like tab type auto-detection) to be overridden.
[*]
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
[*.go]
indent_style = tab
indent_size = 4
[*.md]
indent_style = space
indent_size = 2
[*.yml]
indent_style = space
indent_size = 2

0
.gitignore vendored Normal file
View File

34
Makefile Normal file
View File

@ -0,0 +1,34 @@
SHELL := /bin/bash
VERSION=$(shell grep -e 'Version' doodle.go | head -n 1 | cut -d '"' -f 2)
BUILD=$(shell git describe --always)
CURDIR=$(shell curdir)
# Inject the build version (commit hash) into the executable.
LDFLAGS := -ldflags "-X main.Build=$(BUILD)"
# `make setup` to set up a new environment, pull dependencies, etc.
.PHONY: setup
setup: clean
go get -u ./...
# `make build` to build the binary.
.PHONY: build
build:
gofmt -w .
go build $(LDFLAGS) -i -o bin/doodle cmd/doodle/main.go
# `make run` to run it in debug mode.
.PHONY: run
run:
go run cmd/doodle/main.go -debug
# `make test` to run unit tests.
.PHONY: test
test:
go test ./...
# `make clean` cleans everything up.
.PHONY: clean
clean:
rm -rf bin dist

1
README.md Normal file
View File

@ -0,0 +1 @@
# Doodle

26
cmd/doodle/main.go Normal file
View File

@ -0,0 +1,26 @@
package main
import (
"flag"
"github.com/kirsle/doodle"
)
// Build number is the git commit hash.
var Build string
// Command line args
var (
debug bool
)
func init() {
flag.BoolVar(&debug, "debug", false, "Debug mode")
}
func main() {
flag.Parse()
app := doodle.New(debug)
_ = app
}

59
doodle.go Normal file
View File

@ -0,0 +1,59 @@
package doodle
import "github.com/veandco/go-sdl2/sdl"
// Version number.
const Version = "0.0.0-alpha"
// Doodle is the game object.
type Doodle struct {
Debug bool
window *sdl.Window
renderer *sdl.Renderer
}
// New initializes the game object.
func New(debug bool) *Doodle {
d := &Doodle{
Debug: debug,
}
// Initialize SDL.
if err := sdl.Init(sdl.INIT_EVERYTHING); err != nil {
panic(err)
}
defer sdl.Quit()
// Create our window.
window, err := sdl.CreateWindow(
"Doodle v"+Version,
sdl.WINDOWPOS_CENTERED,
sdl.WINDOWPOS_CENTERED,
800,
600,
sdl.WINDOW_SHOWN,
)
if err != nil {
panic(err)
}
defer window.Destroy()
surface, err := window.GetSurface()
if err != nil {
panic(err)
}
rect := sdl.Rect{
X: 0,
Y: 0,
W: 200,
H: 200,
}
surface.FillRect(&rect, 0xffff0000)
window.UpdateSurface()
sdl.Delay(2500)
return d
}