c80acb478b
- stats are now based on a 1-100 ranged and mapped to sensibles - turnspeed and fire rate are available stats - bugs in movement are squished
56 lines
1.3 KiB
Go
56 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"code.google.com/p/go.net/websocket"
|
|
"flag"
|
|
"log"
|
|
"math/rand"
|
|
"net/http"
|
|
"os"
|
|
"runtime/pprof"
|
|
"time"
|
|
)
|
|
|
|
var addr = flag.String("addr", ":8666", "http service address")
|
|
var tick = flag.Int("tick", 60, "")
|
|
var verbose = flag.Bool("verbose", false, "")
|
|
var width = flag.Float64("width", 800, "width of field")
|
|
var height = flag.Float64("height", 550, "height of field")
|
|
var profile = flag.String("pprof", "", "if specified will run with pprof")
|
|
var debug = flag.Bool("debug", false, "automatically create games if they don't exist")
|
|
|
|
var delta float64
|
|
|
|
var idg *IdGenerator
|
|
|
|
// This is the main, global collection of games
|
|
var games MapLock
|
|
|
|
func main() {
|
|
rand.Seed(time.Now().UnixNano())
|
|
flag.Parse()
|
|
if *profile != "" {
|
|
f, err := os.Create(*profile)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
pprof.StartCPUProfile(f)
|
|
}
|
|
|
|
games = MapLock{m: make(map[string]*game)}
|
|
idg = NewIdGenerator()
|
|
|
|
delta = float64(*tick) / 1000
|
|
|
|
http.Handle("/ws/", websocket.Handler(addPlayer))
|
|
http.Handle("/game/start/", JsonHandler(startGame))
|
|
http.Handle("/game/list/", JsonHandler(listGames))
|
|
http.HandleFunc("/game/stop/", stopGame)
|
|
http.HandleFunc("/fuck/shit/up/", killServer)
|
|
|
|
err := http.ListenAndServe(*addr, nil)
|
|
if err != nil {
|
|
log.Fatal("unable to start server")
|
|
}
|
|
}
|