Compare commits
3 Commits
cc8f8da5df
...
1008b7b34b
Author | SHA1 | Date | |
---|---|---|---|
1008b7b34b | |||
905aad2afa | |||
9f19e4bd92 |
5
game.go
5
game.go
@ -163,6 +163,11 @@ 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,7 +87,10 @@ 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.game.Resume() })
|
c.dialogs.DialogClosed().Register(func() {
|
||||||
|
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,6 +24,11 @@ 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,12 +42,13 @@ 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 {
|
||||||
if e.Button == sdl.BUTTON_MIDDLE || (e.Button == sdl.BUTTON_LEFT && isControlKeyDown()) {
|
controlKeyDown := 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 {
|
if e.Button == sdl.BUTTON_LEFT && !controlKeyDown {
|
||||||
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