compiler basics
This commit is contained in:
parent
e2c33d16a2
commit
2e34a1f4e2
45
cmd/compile.go
Normal file
45
cmd/compile.go
Normal file
|
@ -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 <leveldir>",
|
||||
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")
|
||||
}
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
4
levels/locoworld/Manifest.json
Normal file
4
levels/locoworld/Manifest.json
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"Name": "The locomotive!",
|
||||
"FPS": 10
|
||||
}
|
Loading…
Reference in New Issue
Block a user