Skip to content

Commit

Permalink
client: Made the HOME center the line
Browse files Browse the repository at this point in the history
And also marked the current player line in green so it's easy to identify
  • Loading branch information
xescugc committed Jan 31, 2024
1 parent 52ad2b2 commit 359e212
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
4 changes: 3 additions & 1 deletion client/camera.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ func (cs *CameraStore) Reduce(state, a interface{}) interface{} {
cstate.H = float64(act.WindowResizing.Height)
case action.GoHome:
cp := cs.Store.Players.FindCurrent()
cstate.X, cstate.Y = cs.Store.Map.GetHomeCoordinates(cp.LineID)
x, y := cs.Store.Map.GetHomeCoordinates(cp.LineID)
x -= (cstate.W / 2) - ((18 * 16) / 2)
cstate.X, cstate.Y = x, y
}

return cstate
Expand Down
27 changes: 27 additions & 0 deletions client/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,31 @@ func (m *Map) Draw(screen *ebiten.Image) {
inverseZoom := maxZoom - s.Zoom + zoomScale
mi := ebiten.NewImageFromImage(m.game.Store.Map.GetState().(store.MapState).Image)
screen.DrawImage(mi.SubImage(image.Rect(int(s.X), int(s.Y), int((s.X+s.W)*inverseZoom), int((s.Y+s.H)*inverseZoom))).(*ebiten.Image), op)

cs := m.game.Camera.GetState().(CameraState)
cp := m.game.Store.Players.FindCurrent()
x, y := m.game.Store.Map.GetHomeCoordinates(cp.LineID)
// Color TOP and Bottom
for i := x - 4; i <= x+(18*16)+3; i++ {
// We draw 3 lines so it's kind of **bold**
// and it's easier to see
screen.Set(int(i-cs.X), int(y-cs.Y-4), green)
screen.Set(int(i-cs.X), int(y-cs.Y-3), green)
screen.Set(int(i-cs.X), int(y-cs.Y-2), green)

screen.Set(int(i-cs.X), int((y+86*16)-cs.Y+3), green)
screen.Set(int(i-cs.X), int((y+86*16)-cs.Y+2), green)
screen.Set(int(i-cs.X), int((y+86*16)-cs.Y+1), green)
}

// Color Left and Right
for i := y - 1; i <= y+(86*16); i++ {
screen.Set(int(x-cs.X-4), int(i-cs.Y), green)
screen.Set(int(x-cs.X-3), int(i-cs.Y), green)
screen.Set(int(x-cs.X-2), int(i-cs.Y), green)

screen.Set(int((x+18*16)-cs.X+3), int(i-cs.Y), green)
screen.Set(int((x+18*16)-cs.X+2), int(i-cs.Y), green)
screen.Set(int((x+18*16)-cs.X+1), int(i-cs.Y), green)
}
}
Binary file modified server/assets/wasm/maze-wars.wasm
Binary file not shown.

0 comments on commit 359e212

Please sign in to comment.