Added panning with keyboard.

Changed D for digging into H for harvesting.
This commit is contained in:
Sander Schobers 2020-05-14 07:47:29 +02:00
parent c27d43e323
commit 76ac685cbb
5 changed files with 27 additions and 14 deletions

View File

@ -23,13 +23,13 @@ In Botanim you play the role of botanist and your goal is to cultivate flowers i
Flowers can only grow (well) in certain climates based on two properties: humidity and temperature. Watch out for existing vegetation to get an idea how humid the land is and check the appearance of the tile to see how hot it is. When well placed your planted flower will spread soon but an odd choice might kill your flower almost instantly. So choose carefully. When the flower spread significantly you can dig up flowers again to collect more money. Flowers can only grow (well) in certain climates based on two properties: humidity and temperature. Watch out for existing vegetation to get an idea how humid the land is and check the appearance of the tile to see how hot it is. When well placed your planted flower will spread soon but an odd choice might kill your flower almost instantly. So choose carefully. When the flower spread significantly you can dig up flowers again to collect more money.
**Controls:** **Controls:**
- D: Selects shovel - H: Selects shovel
- R: Selects research - R: Selects research
- Spacebar: pauses game - Spacebar: pauses game
- 1: runs game at normal speed - 1: runs game at normal speed
- 2: runs game extra fast - 2: runs game extra fast
- Mouse wheel or plus/minus: zooms landscape - Mouse wheel or plus/minus: zooms landscape
- CTRL + left mouse button or middle mouse button: pans landscape - W, A, S, D keys or CTRL + left mouse button or middle mouse button: pans landscape
Have fun playing! Have fun playing!

View File

@ -163,7 +163,7 @@ func (c *GameControls) Handle(ctx *Context, event sdl.Event) bool {
c.game.Run() c.game.Run()
case sdl.K_2: case sdl.K_2:
c.game.RunFast() c.game.RunFast()
case sdl.K_d: case sdl.K_h:
c.game.SelectShovel() c.game.SelectShovel()
case sdl.K_r: case sdl.K_r:
c.dialogs.ShowResearch(ctx) c.dialogs.ShowResearch(ctx)

View File

@ -12,13 +12,13 @@ func (i *Intro) Init(ctx *Context) error {
"In Botanim you play the role of botanist and your goal is to cultivate flowers in an open landscape.\n\n" + "In Botanim you play the role of botanist and your goal is to cultivate flowers in an open landscape.\n\n" +
"Flowers can only grow (well) in certain climates based on two properties: humidity and temperature. Watch out for existing vegetation to get an idea how humid the land is and check the appearance of the tile to see how hot it is. When well placed your planted flower will spread soon but an odd choice might kill your flower almost instantly. So choose carefully. When the flower spread significantly you can dig up flowers again to collect more money.\n\n" + "Flowers can only grow (well) in certain climates based on two properties: humidity and temperature. Watch out for existing vegetation to get an idea how humid the land is and check the appearance of the tile to see how hot it is. When well placed your planted flower will spread soon but an odd choice might kill your flower almost instantly. So choose carefully. When the flower spread significantly you can dig up flowers again to collect more money.\n\n" +
"Controls:\n" + "Controls:\n" +
" - D: Selects shovel\n" + " - H: Selects shovel\n" +
" - R: Selects research\n" + " - R: Selects research\n" +
" - Spacebar: pauses game\n" + " - Spacebar: pauses game\n" +
" - 1: runs game at normal speed\n" + " - 1: runs game at normal speed\n" +
" - 2: runs game extra fast\n" + " - 2: runs game extra fast\n" +
" - Mouse wheel or plus/minus: zooms landscape\n" + " - Mouse wheel or plus/minus: zooms landscape\n" +
" - CTRL + left mouse button or middle mouse button: pans landscape\n" + " - W, A, S, D keys or CTRL + left mouse button or middle mouse button: pans landscape\n" +
"\n" + "\n" +
"Have fun playing!" "Have fun playing!"
i.SetContent(&i.welcome) i.SetContent(&i.welcome)

View File

@ -101,6 +101,20 @@ func (p *projection) visibleTiles(action func(int32, int32, Point)) {
} }
} }
func (p *projection) Pan(ctx *Context, delta PointF) {
p.center = p.center.Add(delta.Mul(p.zoomInv))
p.update(ctx.Renderer)
}
func (p *projection) SetZoom(ctx *Context, center PointF, zoom float32) {
if p.zoom == zoom {
return
}
p.center = center.Sub(center.Sub(p.center).Mul(p.zoom / zoom))
p.zoom = zoom
p.update(ctx.Renderer)
}
func (p *projection) ZoomOut(ctx *Context, center PointF) { func (p *projection) ZoomOut(ctx *Context, center PointF) {
if p.zoom <= .25 { if p.zoom <= .25 {
return return
@ -114,12 +128,3 @@ func (p *projection) ZoomIn(ctx *Context, center PointF) {
} }
p.SetZoom(ctx, center, 2*p.zoom) p.SetZoom(ctx, center, 2*p.zoom)
} }
func (p *projection) SetZoom(ctx *Context, center PointF, zoom float32) {
if p.zoom == zoom {
return
}
p.center = center.Sub(center.Sub(p.center).Mul(p.zoom / zoom))
p.zoom = zoom
p.update(ctx.Renderer)
}

View File

@ -101,6 +101,14 @@ func (r *terrainRenderer) Handle(ctx *Context, event sdl.Event) bool {
r.project.ZoomOut(ctx, r.project.center) r.project.ZoomOut(ctx, r.project.center)
case sdl.K_KP_MINUS: case sdl.K_KP_MINUS:
r.project.ZoomOut(ctx, r.project.center) r.project.ZoomOut(ctx, r.project.center)
case sdl.K_w:
r.project.Pan(ctx, PtF(-1, -1))
case sdl.K_a:
r.project.Pan(ctx, PtF(-1, 1))
case sdl.K_s:
r.project.Pan(ctx, PtF(1, 1))
case sdl.K_d:
r.project.Pan(ctx, PtF(1, -1))
} }
} }
} }