Compare commits
No commits in common. "1008b7b34bad0b9ace53d88a679d64ee643d2e47" and "cc8f8da5dfaef58342d3de432b6b89567fab77ce" have entirely different histories.
1008b7b34b
...
cc8f8da5df
5
game.go
5
game.go
@ -163,11 +163,6 @@ func (g *Game) Load() {
|
|||||||
func (g *Game) Pause() { g.setSpeed(GameSpeedPaused) }
|
func (g *Game) Pause() { g.setSpeed(GameSpeedPaused) }
|
||||||
|
|
||||||
func (g *Game) PlantFlower(id string, tile Point) {
|
func (g *Game) PlantFlower(id string, tile Point) {
|
||||||
if g.Terrain.HasFlower(tile) {
|
|
||||||
// TODO: notify user it tried to plant on tile with flower?
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
flower, ok := g.Herbarium.Find(id)
|
flower, ok := g.Herbarium.Find(id)
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Println("user was able to plant a flower that doesn't exist")
|
log.Println("user was able to plant a flower that doesn't exist")
|
||||||
|
@ -87,10 +87,7 @@ func (c *GameControls) Init(ctx *Context) error {
|
|||||||
c.game.SpeedChanged().RegisterItf(c.speedChanged)
|
c.game.SpeedChanged().RegisterItf(c.speedChanged)
|
||||||
c.game.ToolChanged().RegisterItf(c.toolChanged)
|
c.game.ToolChanged().RegisterItf(c.toolChanged)
|
||||||
c.dialogs.DialogOpened().Register(func() { c.game.Pause() })
|
c.dialogs.DialogOpened().Register(func() { c.game.Pause() })
|
||||||
c.dialogs.DialogClosed().Register(func() {
|
c.dialogs.DialogClosed().Register(func() { c.game.Resume() })
|
||||||
c.updateFlowerControls(ctx)
|
|
||||||
c.game.Resume()
|
|
||||||
})
|
|
||||||
|
|
||||||
c.flowers.Background = MustHexColor("#356dad")
|
c.flowers.Background = MustHexColor("#356dad")
|
||||||
c.flowers.ButtonLength = 64
|
c.flowers.ButtonLength = 64
|
||||||
|
5
map.go
5
map.go
@ -24,11 +24,6 @@ func (m *Map) DigFlower(pos Point) string {
|
|||||||
return flower.ID
|
return flower.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Map) HasFlower(pos Point) bool {
|
|
||||||
_, ok := m.Flowers[pos]
|
|
||||||
return ok
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *Map) NewFlower(pos Point, id string, traits FlowerTraits) Flower {
|
func (m *Map) NewFlower(pos Point, id string, traits FlowerTraits) Flower {
|
||||||
flower := Flower{
|
flower := Flower{
|
||||||
ID: id,
|
ID: id,
|
||||||
|
@ -42,13 +42,12 @@ func (r *terrainRenderer) Handle(ctx *Context, event sdl.Event) bool {
|
|||||||
case *sdl.MouseButtonEvent:
|
case *sdl.MouseButtonEvent:
|
||||||
if r.project.windowInteractRect.IsPointInside(e.X, e.Y) {
|
if r.project.windowInteractRect.IsPointInside(e.X, e.Y) {
|
||||||
if e.Type == sdl.MOUSEBUTTONDOWN {
|
if e.Type == sdl.MOUSEBUTTONDOWN {
|
||||||
controlKeyDown := isControlKeyDown()
|
if e.Button == sdl.BUTTON_MIDDLE || (e.Button == sdl.BUTTON_LEFT && isControlKeyDown()) {
|
||||||
if e.Button == sdl.BUTTON_MIDDLE || (e.Button == sdl.BUTTON_LEFT && controlKeyDown) {
|
|
||||||
if !r.drag.IsDragging() {
|
if !r.drag.IsDragging() {
|
||||||
r.drag.Start(Pt(e.X, e.Y))
|
r.drag.Start(Pt(e.X, e.Y))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if e.Button == sdl.BUTTON_LEFT && !controlKeyDown {
|
if e.Button == sdl.BUTTON_LEFT {
|
||||||
pos := r.project.screenToMapInt(e.X, e.Y)
|
pos := r.project.screenToMapInt(e.X, e.Y)
|
||||||
r.game.UserClickedTile(pos)
|
r.game.UserClickedTile(pos)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user