-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgo-rtsengine.go
72 lines (56 loc) · 1.47 KB
/
go-rtsengine.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package main
import (
"flag"
"image"
"log"
"rtsengine"
"time"
)
/*
Main entry point for the go rtsengine.
*/
type flags struct {
port *int
host *string
verbose *bool
quiet *bool
width *int
height *int
}
func main() {
var cargs flags
cargs.port = flag.Int("port", 8080, "port of rts server")
cargs.host = flag.String("host", "localhost", "hostname of rts server")
cargs.verbose = flag.Bool("verbose", false, "Emit excessive progress reporting during rts server execution .")
cargs.quiet = flag.Bool("quiet", false, "Silent testing.")
cargs.width = flag.Int("width", 1000, "Width of the world.")
cargs.height = flag.Int("height", 1000, "Height of the world.")
// Command line arguments parsinmg
flag.Parse()
if !*cargs.quiet {
log.Print("GO RTS Engine starting")
}
game, err := rtsengine.NewGame("Game Test", "./maps/tileset/example.tmx", 10000, 1, 3, 50, 50, *cargs.width, *cargs.height)
if err != nil {
log.Print(err)
return
}
// Construct a fence with the pathing as a simple test.
start := time.Now()
pathList, err := game.FindPath(&image.Point{10, 10}, &image.Point{45, 45})
elapsed := time.Since(start)
if err != nil {
log.Print(err)
return
}
game.FreeList(pathList)
game.ItemPool.PrintAllocatedWaypoints()
log.Printf("\n\nPathfinding took %s\n\n", elapsed)
err = game.AcceptNetConnections(*cargs.host, *cargs.port)
if err != nil {
log.Print(err)
return
}
game.Start()
select {} // wait forever without eating CPU.
}