Colliding Doodads #1

Closed
kirsle wants to merge 6 commits from dev into master
7 changed files with 102 additions and 43 deletions
Showing only changes of commit f473609bb5 - Show all commits

View File

@ -2,10 +2,11 @@ SHELL := /bin/bash
VERSION=$(shell grep -e 'Version' doodle.go | head -n 1 | cut -d '"' -f 2) VERSION=$(shell grep -e 'Version' doodle.go | head -n 1 | cut -d '"' -f 2)
BUILD=$(shell git describe --always) BUILD=$(shell git describe --always)
BUILD_DATE=$(shell date -Iseconds)
CURDIR=$(shell curdir) CURDIR=$(shell curdir)
# Inject the build version (commit hash) into the executable. # Inject the build version (commit hash) into the executable.
LDFLAGS := -ldflags "-X main.Build=$(BUILD)" LDFLAGS := -ldflags "-X main.Build=$(BUILD) -X main.BuildDate=$(BUILD_DATE)"
# `make setup` to set up a new environment, pull dependencies, etc. # `make setup` to set up a new environment, pull dependencies, etc.
.PHONY: setup .PHONY: setup

View File

@ -11,10 +11,10 @@ import (
"image/png" "image/png"
"git.kirsle.net/apps/doodle"
"git.kirsle.net/apps/doodle/doodads"
"git.kirsle.net/apps/doodle/level"
"git.kirsle.net/apps/doodle/lib/render" "git.kirsle.net/apps/doodle/lib/render"
"git.kirsle.net/apps/doodle/src"
"git.kirsle.net/apps/doodle/src/doodads"
"git.kirsle.net/apps/doodle/src/level"
"github.com/urfave/cli" "github.com/urfave/cli"
"golang.org/x/image/bmp" "golang.org/x/image/bmp"
) )

View File

@ -2,22 +2,38 @@
package main package main
import ( import (
"fmt"
"log" "log"
"os" "os"
"sort" "sort"
"time"
"git.kirsle.net/apps/doodle"
"git.kirsle.net/apps/doodle/cmd/doodad/commands" "git.kirsle.net/apps/doodle/cmd/doodad/commands"
"git.kirsle.net/apps/doodle/src"
"github.com/urfave/cli" "github.com/urfave/cli"
) )
var Build = "N/A" // Build number is the git commit hash.
var (
Build = "<dynamic>"
BuildDate string
)
func init() {
if BuildDate == "" {
BuildDate = time.Now().Format(time.RFC3339)
}
}
func main() { func main() {
app := cli.NewApp() app := cli.NewApp()
app.Name = "doodad" app.Name = "doodad"
app.Usage = "command line interface for Doodle" app.Usage = "command line interface for Doodle"
app.Version = doodle.Version + " build " + Build app.Version = fmt.Sprintf("%s build %s. Built on %s",
doodle.Version,
Build,
BuildDate,
)
app.Flags = []cli.Flag{ app.Flags = []cli.Flag{
cli.BoolFlag{ cli.BoolFlag{

View File

@ -1,40 +1,72 @@
package main package main
import ( import (
"flag" "fmt"
"log"
"os"
"runtime" "runtime"
"sort"
"time"
"git.kirsle.net/apps/doodle/lib/render/sdl" "git.kirsle.net/apps/doodle/lib/render/sdl"
"git.kirsle.net/apps/doodle/src" "git.kirsle.net/apps/doodle/src"
"git.kirsle.net/apps/doodle/src/balance" "git.kirsle.net/apps/doodle/src/balance"
"github.com/urfave/cli"
_ "image/png" _ "image/png"
) )
// Build number is the git commit hash. // Build number is the git commit hash.
var Build string
// Command line args
var ( var (
debug bool Build = "<dynamic>"
edit bool BuildDate string
guitest bool
) )
func init() { func init() {
flag.BoolVar(&debug, "debug", false, "Debug mode") if BuildDate == "" {
flag.BoolVar(&edit, "edit", false, "Edit the map given on the command line. Default is to play the map.") BuildDate = time.Now().Format(time.RFC3339)
flag.BoolVar(&guitest, "guitest", false, "Enter the GUI Test scene.") }
} }
func main() { func main() {
runtime.LockOSThread() runtime.LockOSThread()
flag.Parse()
args := flag.Args() app := cli.NewApp()
app.Name = "doodle"
app.Usage = "command line interface for Doodle"
app.Version = fmt.Sprintf("%s build %s. Built on %s",
doodle.Version,
Build,
BuildDate,
)
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "debug, d",
Usage: "enable debug level logging",
},
cli.BoolFlag{
Name: "edit, e",
Usage: "edit the map given on the command line (instead of play it)",
},
cli.BoolFlag{
Name: "guitest",
Usage: "enter the GUI Test scene on startup",
},
}
app.Action = func(c *cli.Context) error {
if c.Bool("version") {
fmt.Printf("This is Project Doodle, v%s build %s ",
doodle.Version,
Build,
)
return nil
}
var filename string var filename string
if len(args) > 0 { if c.NArg() > 0 {
filename = args[0] filename = c.Args().Get(0)
} }
// SDL engine. // SDL engine.
@ -44,16 +76,26 @@ func main() {
balance.Height, balance.Height,
) )
app := doodle.New(debug, engine) game := doodle.New(c.Bool("debug"), engine)
app.SetupEngine() game.SetupEngine()
if guitest { if c.Bool("guitest") {
app.Goto(&doodle.GUITestScene{}) game.Goto(&doodle.GUITestScene{})
} else if filename != "" { } else if filename != "" {
if edit { if c.Bool("edit") {
app.EditFile(filename) game.EditFile(filename)
} else { } else {
app.PlayLevel(filename) game.PlayLevel(filename)
} }
} }
app.Run() game.Run()
return nil
}
sort.Sort(cli.FlagsByName(app.Flags))
sort.Sort(cli.CommandsByName(app.Commands))
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
} }

View File

@ -7,8 +7,8 @@ import (
"image" "image"
"os" "os"
"git.kirsle.net/apps/doodle/pkg/userdir"
"git.kirsle.net/apps/doodle/lib/render" "git.kirsle.net/apps/doodle/lib/render"
"git.kirsle.net/apps/doodle/pkg/userdir"
"golang.org/x/image/bmp" "golang.org/x/image/bmp"
) )

View File

@ -4,9 +4,9 @@ import (
"fmt" "fmt"
"git.kirsle.net/apps/doodle/lib/render" "git.kirsle.net/apps/doodle/lib/render"
"git.kirsle.net/apps/doodle/lib/ui"
"git.kirsle.net/apps/doodle/src/balance" "git.kirsle.net/apps/doodle/src/balance"
"git.kirsle.net/apps/doodle/src/events" "git.kirsle.net/apps/doodle/src/events"
"git.kirsle.net/apps/doodle/lib/ui"
) )
// GUITestScene implements the main menu of Doodle. // GUITestScene implements the main menu of Doodle.

View File

@ -2,9 +2,9 @@ package doodle
import ( import (
"git.kirsle.net/apps/doodle/lib/render" "git.kirsle.net/apps/doodle/lib/render"
"git.kirsle.net/apps/doodle/lib/ui"
"git.kirsle.net/apps/doodle/src/balance" "git.kirsle.net/apps/doodle/src/balance"
"git.kirsle.net/apps/doodle/src/events" "git.kirsle.net/apps/doodle/src/events"
"git.kirsle.net/apps/doodle/lib/ui"
) )
// MainScene implements the main menu of Doodle. // MainScene implements the main menu of Doodle.