oh noooo lol

master
Jordan Orelli 4 years ago
parent b1cc63e471
commit 8e2144c20f

@ -2,6 +2,8 @@ package sim
import ( import (
"time" "time"
"github.com/jordanorelli/astro-domu/internal/wire"
) )
type Entity struct { type Entity struct {
@ -11,6 +13,12 @@ type Entity struct {
behavior behavior
} }
func (Entity) NetTag() string { return "entity" }
func init() {
wire.Register(func() wire.Value { return new(Entity) })
}
type behavior interface { type behavior interface {
// update is the standard tick function // update is the standard tick function
update(time.Duration) update(time.Duration)

@ -34,12 +34,9 @@ func (m *Move) exec(r *room, p *player, seq int) result {
return result{reply: wire.Errorf("target cell (%d, %d) is occupied", target[0], target[1])} return result{reply: wire.Errorf("target cell (%d, %d) is occupied", target[0], target[1])}
} }
p.entity.Position = target p.entity.Position = target
return result{reply: wire.OK{}} return result{reply: p.entity, announce: p.entity}
} }
// type pawn struct {
// }
// SpawnPlayer is a request to spawn a player // SpawnPlayer is a request to spawn a player
type SpawnPlayer struct { type SpawnPlayer struct {
Outbox chan wire.Response Outbox chan wire.Response

@ -23,16 +23,16 @@ func (m *roomDisplay) handleEvent(ui *UI, e tcell.Event) bool {
if key == tcell.KeyRune { if key == tcell.KeyRune {
switch v.Rune() { switch v.Rune() {
case 'w': case 'w':
ui.client.Send(sim.Move{0, -1}) go ui.client.Send(sim.Move{0, -1})
// m.move(0, -1) // m.move(0, -1)
case 'a': case 'a':
ui.client.Send(sim.Move{-1, 0}) go ui.client.Send(sim.Move{-1, 0})
// m.move(-1, 0) // m.move(-1, 0)
case 's': case 's':
ui.client.Send(sim.Move{0, 1}) go ui.client.Send(sim.Move{0, 1})
// m.move(0, 1) // m.move(0, 1)
case 'd': case 'd':
ui.client.Send(sim.Move{1, 0}) go ui.client.Send(sim.Move{1, 0})
// m.move(1, 0) // m.move(1, 0)
} }
} }

Loading…
Cancel
Save