Collision update.
This commit is contained in:
@@ -32,12 +32,14 @@ type ClientData struct {
|
||||
Address string
|
||||
Name string
|
||||
Position gamedata.Coordinates
|
||||
Hit bool
|
||||
}
|
||||
|
||||
type Game struct {
|
||||
name string
|
||||
blocky *elements.Block
|
||||
gameId int
|
||||
name string
|
||||
blocky *elements.Block
|
||||
hitblocky *elements.Block
|
||||
gameId int
|
||||
|
||||
//players map[client.Identity]
|
||||
|
||||
@@ -55,9 +57,13 @@ func NewGame() *Game {
|
||||
g := &Game{
|
||||
gameclient: client.NewClient(),
|
||||
blocky: elements.NewBlock(),
|
||||
hitblocky: elements.NewBlock(),
|
||||
cycle: 0,
|
||||
name: namelist[rand.Intn(len(namelist))],
|
||||
}
|
||||
|
||||
g.hitblocky.SetHit(true)
|
||||
|
||||
g.clients = make(map[string]ClientData)
|
||||
|
||||
//g.gameId = g.gameclient.GetIdentity()
|
||||
@@ -117,6 +123,8 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
screen.Clear()
|
||||
|
||||
g.blocky.Draw()
|
||||
g.hitblocky.Draw()
|
||||
|
||||
op := &ebiten.DrawImageOptions{}
|
||||
op.GeoM.Translate(-float64(g.blocky.Sprite.Bounds().Dx())/2, -float64(g.blocky.Sprite.Bounds().Dy())/2)
|
||||
op.GeoM.Translate(g.blocky.GetPosition().X, g.blocky.GetPosition().Y)
|
||||
@@ -136,7 +144,11 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
op := &ebiten.DrawImageOptions{}
|
||||
op.GeoM.Translate(-float64(g.blocky.Sprite.Bounds().Dx())/2, -float64(g.blocky.Sprite.Bounds().Dy())/2)
|
||||
op.GeoM.Translate(client.Position.X, client.Position.Y)
|
||||
screen.DrawImage(g.blocky.Sprite, op)
|
||||
if !client.Hit {
|
||||
screen.DrawImage(g.blocky.Sprite, op)
|
||||
} else {
|
||||
screen.DrawImage(g.hitblocky.Sprite, op)
|
||||
}
|
||||
|
||||
f2 := &text.GoTextFace{
|
||||
Source: fonts.LaunchyFont.New,
|
||||
@@ -169,6 +181,7 @@ func (g *Game) HandleServerData(envelope *pb.ServerEnvelope) {
|
||||
X: client.Coordinates.X,
|
||||
Y: client.Coordinates.Y,
|
||||
},
|
||||
Hit: client.Hit,
|
||||
}
|
||||
|
||||
g.mu.Lock()
|
||||
|
||||
Reference in New Issue
Block a user