From 2e34a1f4e2fdce0a49c510d847bb43d012dff126 Mon Sep 17 00:00:00 2001 From: tkarrass Date: Sat, 6 Feb 2016 15:44:09 +0100 Subject: [PATCH] compiler basics --- cmd/compile.go | 45 +++++++++++++++++++ cmd/server.go | 2 + default.lvl => levelinfo.txt | 0 levels/locoworld/Manifest.json | 4 ++ .../locoworld/locomotive}/1.frame | 0 .../locoworld/locomotive}/2.frame | 0 .../locoworld/locomotive}/3.frame | 0 .../locoworld/locomotive}/4.frame | 0 .../locoworld/locomotive}/5.frame | 0 .../locoworld/locomotive}/6.frame | 0 .../locoworld/locomotive}/lokomotive_wörk | 0 11 files changed, 51 insertions(+) create mode 100644 cmd/compile.go rename default.lvl => levelinfo.txt (100%) create mode 100644 levels/locoworld/Manifest.json rename {locomotive => levels/locoworld/locomotive}/1.frame (100%) rename {locomotive => levels/locoworld/locomotive}/2.frame (100%) rename {locomotive => levels/locoworld/locomotive}/3.frame (100%) rename {locomotive => levels/locoworld/locomotive}/4.frame (100%) rename {locomotive => levels/locoworld/locomotive}/5.frame (100%) rename {locomotive => levels/locoworld/locomotive}/6.frame (100%) rename {locomotive => levels/locoworld/locomotive}/lokomotive_wörk (100%) diff --git a/cmd/compile.go b/cmd/compile.go new file mode 100644 index 0000000..d60e991 --- /dev/null +++ b/cmd/compile.go @@ -0,0 +1,45 @@ +package cmd // code.bitsetter.de/fun/gosl/cmd + +import ( + "github.com/spf13/cobra" + "log" + "path" +) + +var ( + levelDir string + levelFile string +) + +var cmdCompile = &cobra.Command{ + Use: "compile ", + Short: "Compiles a gosl level into a loadable level file", + Long: `Compiles a level file from a given input directory. +It's contents contain at least: + + / leveldir + +-- Manifest.json Basic level Info + +-- Layer1/ At least one layer dir containing … + +-- Manifest.json Basic layer Info + +-- 1.Frame At least one frame + +See the example level for further details (which does not exist, yet :p)`, +} + +func compile(cmd *cobra.Command, args []string) { + if len(args) < 1 { + log.Fatal("You need to specify a level directory to compile!") + } + levelDir = args[0] + if levelFile == "" { + levelFile = path.Base(levelDir) + ".lvl" + } + log.Println("will compile to", levelFile) + +} + +func init() { + CmdGosl.AddCommand(cmdCompile) + cmdCompile.Run = compile + cmdCompile.Flags().StringVarP(&levelFile, "output", "o", "", "Output filename") +} diff --git a/cmd/server.go b/cmd/server.go index c96a832..235557a 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -2,6 +2,7 @@ package cmd // code.bitsetter.de/fun/gosl/cmd import ( "encoding/gob" + "fmt" "log" "net" "sort" @@ -68,6 +69,7 @@ func serveClients() { if id > 0 { enc := gob.NewEncoder(client.con) enc.Encode(oFrame) + //log.Println("ID:", id, "Client:", client) } } diff --git a/default.lvl b/levelinfo.txt similarity index 100% rename from default.lvl rename to levelinfo.txt diff --git a/levels/locoworld/Manifest.json b/levels/locoworld/Manifest.json new file mode 100644 index 0000000..1241bee --- /dev/null +++ b/levels/locoworld/Manifest.json @@ -0,0 +1,4 @@ +{ + "Name": "The locomotive!", + "FPS": 10 +} diff --git a/locomotive/1.frame b/levels/locoworld/locomotive/1.frame similarity index 100% rename from locomotive/1.frame rename to levels/locoworld/locomotive/1.frame diff --git a/locomotive/2.frame b/levels/locoworld/locomotive/2.frame similarity index 100% rename from locomotive/2.frame rename to levels/locoworld/locomotive/2.frame diff --git a/locomotive/3.frame b/levels/locoworld/locomotive/3.frame similarity index 100% rename from locomotive/3.frame rename to levels/locoworld/locomotive/3.frame diff --git a/locomotive/4.frame b/levels/locoworld/locomotive/4.frame similarity index 100% rename from locomotive/4.frame rename to levels/locoworld/locomotive/4.frame diff --git a/locomotive/5.frame b/levels/locoworld/locomotive/5.frame similarity index 100% rename from locomotive/5.frame rename to levels/locoworld/locomotive/5.frame diff --git a/locomotive/6.frame b/levels/locoworld/locomotive/6.frame similarity index 100% rename from locomotive/6.frame rename to levels/locoworld/locomotive/6.frame diff --git a/locomotive/lokomotive_wörk b/levels/locoworld/locomotive/lokomotive_wörk similarity index 100% rename from locomotive/lokomotive_wörk rename to levels/locoworld/locomotive/lokomotive_wörk