|
|
|
@ -188,19 +188,19 @@ func (g *Game) InitNetworking(localPort int, numPlayers int, players []ggpo.Play
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (g *Game) ReadInputs() InputBits {
|
|
|
|
|
func (g *Game) ReadInputsP1() InputBits {
|
|
|
|
|
var in InputBits
|
|
|
|
|
|
|
|
|
|
if ebiten.IsKeyPressed(ebiten.KeyArrowUp) || ebiten.IsKeyPressed(ebiten.KeyW) {
|
|
|
|
|
if ebiten.IsKeyPressed(ebiten.KeyW) {
|
|
|
|
|
in.setButtonOn(ButtonUp)
|
|
|
|
|
}
|
|
|
|
|
if ebiten.IsKeyPressed(ebiten.KeyArrowDown) || ebiten.IsKeyPressed(ebiten.KeyS) {
|
|
|
|
|
if ebiten.IsKeyPressed(ebiten.KeyS) {
|
|
|
|
|
in.setButtonOn(ButtonDown)
|
|
|
|
|
}
|
|
|
|
|
if ebiten.IsKeyPressed(ebiten.KeyArrowLeft) || ebiten.IsKeyPressed(ebiten.KeyA) {
|
|
|
|
|
if ebiten.IsKeyPressed(ebiten.KeyA) {
|
|
|
|
|
in.setButtonOn(ButtonLeft)
|
|
|
|
|
}
|
|
|
|
|
if ebiten.IsKeyPressed(ebiten.KeyArrowRight) || ebiten.IsKeyPressed(ebiten.KeyD) {
|
|
|
|
|
if ebiten.IsKeyPressed(ebiten.KeyD) {
|
|
|
|
|
in.setButtonOn(ButtonRight)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -227,6 +227,45 @@ func (g *Game) ReadInputs() InputBits {
|
|
|
|
|
return in
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (g *Game) ReadInputsP2() InputBits {
|
|
|
|
|
var in InputBits
|
|
|
|
|
|
|
|
|
|
if ebiten.IsKeyPressed(ebiten.KeyArrowUp) {
|
|
|
|
|
in.setButtonOn(ButtonUp)
|
|
|
|
|
}
|
|
|
|
|
if ebiten.IsKeyPressed(ebiten.KeyArrowDown) {
|
|
|
|
|
in.setButtonOn(ButtonDown)
|
|
|
|
|
}
|
|
|
|
|
if ebiten.IsKeyPressed(ebiten.KeyArrowLeft) {
|
|
|
|
|
in.setButtonOn(ButtonLeft)
|
|
|
|
|
}
|
|
|
|
|
if ebiten.IsKeyPressed(ebiten.KeyArrowRight) {
|
|
|
|
|
in.setButtonOn(ButtonRight)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ebiten.IsKeyPressed(ebiten.KeySlash) {
|
|
|
|
|
in.setButtonOn(ButtonPunch)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ebiten.IsKeyPressed(ebiten.KeyQuote) {
|
|
|
|
|
in.setButtonOn(ButtonKick)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ebiten.IsKeyPressed(ebiten.KeyBracketRight) {
|
|
|
|
|
in.setButtonOn(ButtonBlock)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ebiten.IsKeyPressed(ebiten.KeyBackspace) {
|
|
|
|
|
in.setButtonOn(ButtonTaunt)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ebiten.IsKeyPressed(ebiten.KeyEnter) || ebiten.IsKeyPressed(ebiten.KeyKPEnter) {
|
|
|
|
|
in.setButtonOn(ButtonStart)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return in
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (g *Game) applyPhysics() {
|
|
|
|
|
for i := 0; i < 2; i++ {
|
|
|
|
|
opp := 0
|
|
|
|
@ -536,13 +575,6 @@ func (g *Game) UpdateByInputs(inputs []InputBits) {
|
|
|
|
|
g.applyPhysics()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (g *Game) ReadInputsP2() InputBits {
|
|
|
|
|
var in InputBits
|
|
|
|
|
|
|
|
|
|
// TODO Support local multiplayer?
|
|
|
|
|
return in
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (g *Game) playerStateUpdated() {
|
|
|
|
|
if g.Winner != 0 && g.Players[0].PlayAgain && g.Players[1].PlayAgain {
|
|
|
|
|
g.reset()
|
|
|
|
@ -555,7 +587,7 @@ func (g *Game) playerStateUpdated() {
|
|
|
|
|
|
|
|
|
|
func (g *Game) RunLocalFrame() {
|
|
|
|
|
inputs := make([]InputBits, 2)
|
|
|
|
|
inputs[0] = g.ReadInputs()
|
|
|
|
|
inputs[0] = g.ReadInputsP1()
|
|
|
|
|
|
|
|
|
|
if world.AI == world.AIStandard {
|
|
|
|
|
inputs[1] = botInput()
|
|
|
|
@ -564,6 +596,8 @@ func (g *Game) RunLocalFrame() {
|
|
|
|
|
} else if world.AI == world.AIBlock {
|
|
|
|
|
inputs[1] = inputs[0]
|
|
|
|
|
inputs[1].setButtonOn(ButtonBlock)
|
|
|
|
|
} else { // AINone
|
|
|
|
|
inputs[1] = g.ReadInputsP2()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g.UpdateByInputs(inputs)
|
|
|
|
@ -571,7 +605,7 @@ func (g *Game) RunLocalFrame() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (g *Game) RunFrame() {
|
|
|
|
|
input := g.ReadInputs()
|
|
|
|
|
input := g.ReadInputsP1()
|
|
|
|
|
buffer := encodeInputs(input)
|
|
|
|
|
|
|
|
|
|
//fmt.Println("Attempting to add local inputs")
|
|
|
|
@ -637,11 +671,11 @@ func (g *Game) Update() error {
|
|
|
|
|
if inpututil.IsKeyJustPressed(ebiten.KeyO) && ebiten.IsKeyPressed(ebiten.KeyControl) {
|
|
|
|
|
switch world.AI {
|
|
|
|
|
case world.AIStandard:
|
|
|
|
|
world.AI = world.AINone
|
|
|
|
|
case world.AINone:
|
|
|
|
|
world.AI = world.AIMirror
|
|
|
|
|
case world.AIMirror:
|
|
|
|
|
world.AI = world.AIBlock
|
|
|
|
|
case world.AIBlock:
|
|
|
|
|
world.AI = world.AINone
|
|
|
|
|
default:
|
|
|
|
|
world.AI = world.AIStandard
|
|
|
|
|
}
|
|
|
|
|