Convert to 32-bit to save space in the serialization

This commit is contained in:
Fraser Graham
2013-10-19 00:00:51 -07:00
parent c074397c1f
commit f9b18eb253
6 changed files with 47 additions and 46 deletions
+5 -5
View File
@@ -64,7 +64,7 @@ func (ml *MapLock) get(id string, force bool) (*game, error) {
id = idg.Hash()
}
_g := NewGame(id, *width, *height)
_g := NewGame(id, float32(*width), float32(*height))
go _g.run()
ml.Lock()
@@ -82,14 +82,14 @@ type game struct {
register chan *player
unregister chan *player
turn int
width, height float64
width, height float32
spectators map[*Spectator]bool
sregister chan *Spectator
sunregister chan *Spectator
kill chan bool
}
func NewGame(id string, width, height float64) *game {
func NewGame(id string, width, height float32) *game {
g := &game{
id: id,
register: make(chan *player),
@@ -217,7 +217,7 @@ func (g *game) run() {
func (g *game) nudgeProjectiles() (rprojectiles []Projectile) {
rprojectiles = make([]Projectile, 0)
for p := range g.projectiles {
newPos := move(p.Position, p.MoveTo, float64(p.Speed), delta)
newPos := move(p.Position, p.MoveTo, float32(p.Speed), delta)
hit_player := false
for player := range g.players {
@@ -253,7 +253,7 @@ func (g *game) nudgeProjectiles() (rprojectiles []Projectile) {
for player := range g.players {
dist := v.Distance(player.Robot.Position, p.Position)
if dist < float64(p.Radius) {
if dist < float32(p.Radius) {
// TODO map damage Max to Min based on distance from explosion
if player.Robot.Health > 0 {