float32-d the whole thang
This commit is contained in:
parent
9fad1a7ad3
commit
384d6c5ca2
28
main.go
28
main.go
@ -27,13 +27,13 @@ var verbose = flag.Bool("verbose", false, "run verbosly")
|
|||||||
|
|
||||||
type infos struct {
|
type infos struct {
|
||||||
id string
|
id string
|
||||||
width, height float64
|
width, height float32
|
||||||
}
|
}
|
||||||
|
|
||||||
type Stats struct {
|
type Stats struct {
|
||||||
Hp int `json:"hp"`
|
Hp int `json:"hp"`
|
||||||
Speed float64 `json:"speed"`
|
Speed float32 `json:"speed"`
|
||||||
Acceleration float64 `json:"acceleration"`
|
Acceleration float32 `json:"acceleration"`
|
||||||
WeaponRadius int `json:"weapon_radius"`
|
WeaponRadius int `json:"weapon_radius"`
|
||||||
ScannerRadius int `json:"scanner_radius"`
|
ScannerRadius int `json:"scanner_radius"`
|
||||||
FireRate int `json:"fire_rate"`
|
FireRate int `json:"fire_rate"`
|
||||||
@ -48,8 +48,8 @@ type Robot struct {
|
|||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Stats Stats `json:"stats"`
|
Stats Stats `json:"stats"`
|
||||||
TargetSpeed float64 `json:"speed"`
|
TargetSpeed float32 `json:"speed"`
|
||||||
Speed float64 `json:"speed"`
|
Speed float32 `json:"speed"`
|
||||||
Health int `json:"health"`
|
Health int `json:"health"`
|
||||||
Position govector.Point2d `json:"position"`
|
Position govector.Point2d `json:"position"`
|
||||||
Heading govector.Vector2d `json:"heading"`
|
Heading govector.Vector2d `json:"heading"`
|
||||||
@ -63,7 +63,7 @@ type Projectile struct {
|
|||||||
Position govector.Point2d `json:"position"`
|
Position govector.Point2d `json:"position"`
|
||||||
MoveTo govector.Point2d `json:"move_to"`
|
MoveTo govector.Point2d `json:"move_to"`
|
||||||
Radius int `json:"radius"`
|
Radius int `json:"radius"`
|
||||||
Speed float64 `json:"speed"`
|
Speed float32 `json:"speed"`
|
||||||
Damage int `json:"damage"`
|
Damage int `json:"damage"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,8 +140,8 @@ func negociate(ws *websocket.Conn, gameid string) (i *infos, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type BoardSize struct {
|
type BoardSize struct {
|
||||||
Width float64 `json:"width"`
|
Width float32 `json:"width"`
|
||||||
Height float64 `json:"height"`
|
Height float32 `json:"height"`
|
||||||
}
|
}
|
||||||
var gameparam struct {
|
var gameparam struct {
|
||||||
BoardSize BoardSize `json:"boardsize"`
|
BoardSize BoardSize `json:"boardsize"`
|
||||||
@ -165,8 +165,8 @@ func negociate(ws *websocket.Conn, gameid string) (i *infos, err error) {
|
|||||||
Name: *botname,
|
Name: *botname,
|
||||||
Stats: Stats{
|
Stats: Stats{
|
||||||
Hp: *hp,
|
Hp: *hp,
|
||||||
Speed: *speed,
|
Speed: float32(*speed),
|
||||||
Acceleration: *acceleration,
|
Acceleration: float32(*acceleration),
|
||||||
WeaponRadius: *weaponRadius,
|
WeaponRadius: *weaponRadius,
|
||||||
ScannerRadius: *scannerRadius,
|
ScannerRadius: *scannerRadius,
|
||||||
FireRate: *fireRate,
|
FireRate: *fireRate,
|
||||||
@ -215,8 +215,8 @@ func main() {
|
|||||||
|
|
||||||
// TODO: var target govector.Point2d
|
// TODO: var target govector.Point2d
|
||||||
moveto := govector.Point2d{
|
moveto := govector.Point2d{
|
||||||
X: rand.Float64() * board_info.width,
|
X: rand.Float32() * board_info.width,
|
||||||
Y: rand.Float64() * board_info.height,
|
Y: rand.Float32() * board_info.height,
|
||||||
}
|
}
|
||||||
log.Printf("%+v", moveto)
|
log.Printf("%+v", moveto)
|
||||||
|
|
||||||
@ -248,8 +248,8 @@ func main() {
|
|||||||
if govector.Distance(me.Position, moveto) < 3.0 {
|
if govector.Distance(me.Position, moveto) < 3.0 {
|
||||||
log.Printf("old: %+v: %+v", me.Position, moveto)
|
log.Printf("old: %+v: %+v", me.Position, moveto)
|
||||||
moveto = govector.Point2d{
|
moveto = govector.Point2d{
|
||||||
X: rand.Float64() * board_info.width,
|
X: rand.Float32() * board_info.width,
|
||||||
Y: rand.Float64() * board_info.height,
|
Y: rand.Float32() * board_info.height,
|
||||||
}
|
}
|
||||||
log.Printf("new: %+v: %+v", me.Position, moveto)
|
log.Printf("new: %+v: %+v", me.Position, moveto)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user