|
|
|
@ -180,17 +180,17 @@ func (u *UISystem) Update(e gohan.Entity) error {
|
|
|
|
|
return etk.Update()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (u *UISystem) drawBox(screen *ebiten.Image, fillColor color.Color, x float64, y float64, w int, h int) {
|
|
|
|
|
func (u *UISystem) drawBox(screen *ebiten.Image, fillColor color.Color, r image.Rectangle) {
|
|
|
|
|
bounds := u.hitboxImg.Bounds()
|
|
|
|
|
if bounds.Dx() != w || bounds.Dy() != h {
|
|
|
|
|
u.hitboxImg = ebiten.NewImage(w, h)
|
|
|
|
|
if bounds.Dx() != r.Dx() || bounds.Dy() != r.Dy() {
|
|
|
|
|
u.hitboxImg = ebiten.NewImage(r.Dx(), r.Dy())
|
|
|
|
|
}
|
|
|
|
|
u.hitboxImg.Clear()
|
|
|
|
|
u.hitboxImg.Fill(color.RGBA{255, 255, 255, 255})
|
|
|
|
|
u.hitboxImg.SubImage(image.Rect(2, 2, w-2, h-2)).(*ebiten.Image).Fill(fillColor)
|
|
|
|
|
u.hitboxImg.SubImage(image.Rect(2, 2, r.Dx()-2, r.Dy()-2)).(*ebiten.Image).Fill(fillColor)
|
|
|
|
|
|
|
|
|
|
// Get screen position of top left corner of player.
|
|
|
|
|
drawX, drawY := world.GameCoordsToScreen(x, y)
|
|
|
|
|
drawX, drawY := world.GameCoordsToScreen(float64(r.Min.X), float64(r.Min.Y+r.Dy()))
|
|
|
|
|
|
|
|
|
|
op := &ebiten.DrawImageOptions{}
|
|
|
|
|
op.GeoM.Translate(float64(drawX), float64(drawY))
|
|
|
|
@ -209,31 +209,38 @@ func (u *UISystem) Draw(e gohan.Entity, screen *ebiten.Image) error {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
} else if world.Debug > 1 { // In-game and debug mode is enabled
|
|
|
|
|
var p *component.Player
|
|
|
|
|
var p, o *component.Player
|
|
|
|
|
for i := 0; i < 2; i++ {
|
|
|
|
|
if i == 0 {
|
|
|
|
|
p = &world.Player1
|
|
|
|
|
o = &world.Player2
|
|
|
|
|
} else {
|
|
|
|
|
p = &world.Player2
|
|
|
|
|
o = &world.Player1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if p.ActionTicksLeft != 0 {
|
|
|
|
|
// Draw a rect over stunned players.
|
|
|
|
|
if p.Action == component.ActionStunned {
|
|
|
|
|
playerRect := world.FloatRect(p.X, p.Y, p.X+float64(component.PlayerSize), p.Y+float64(component.PlayerSize))
|
|
|
|
|
|
|
|
|
|
fillColor := color.RGBA{123, 30, 255, 255}
|
|
|
|
|
u.drawBox(screen, fillColor, p.X, p.Y+component.PlayerSize, component.PlayerSize, component.PlayerSize)
|
|
|
|
|
u.drawBox(screen, fillColor, playerRect)
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Draw frame data rects.
|
|
|
|
|
allData := component.FrameDataForActionTick(p.Action, p.ActionTicksLeft)
|
|
|
|
|
for _, data := range allData {
|
|
|
|
|
for _, frame := range allData {
|
|
|
|
|
frameRect := component.FlipRect(frame.R, component.PlayerOnRightSide(*p, *o))
|
|
|
|
|
frameRect = component.TranslateRect(frameRect, int(p.X), int(p.Y))
|
|
|
|
|
|
|
|
|
|
fillColor := color.RGBA{0, 255, 0, 255}
|
|
|
|
|
switch data.T {
|
|
|
|
|
switch frame.T {
|
|
|
|
|
case component.HitboxHurt:
|
|
|
|
|
fillColor = color.RGBA{0, 0, 255, 255}
|
|
|
|
|
}
|
|
|
|
|
u.drawBox(screen, fillColor, p.X, p.Y+float64(data.R.Dy()), data.R.Dx(), data.R.Dy())
|
|
|
|
|
u.drawBox(screen, fillColor, frameRect)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|