Compare commits
2 Commits
c926ae2ef9
...
ad7c149baf
Author | SHA1 | Date | |
---|---|---|---|
ad7c149baf | |||
7150d03d16 |
@ -20,10 +20,10 @@
|
|||||||
|
|
||||||
In Botanim you play the role of botanist and your goal is to cultivate flowers in an open landscape.
|
In Botanim you play the role of botanist and your goal is to cultivate flowers in an open landscape.
|
||||||
|
|
||||||
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 harvest flowers again to collect more money.
|
||||||
|
|
||||||
**Controls:**
|
**Controls:**
|
||||||
- H: Selects shovel
|
- H: Selects harvest tool
|
||||||
- R: Selects research
|
- R: Selects research
|
||||||
- Spacebar: pauses game
|
- Spacebar: pauses game
|
||||||
- 1: runs game at normal speed
|
- 1: runs game at normal speed
|
||||||
|
@ -45,7 +45,7 @@ func (c *ControlBase) ActualFont(ctx *Context) *Font {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *ControlBase) ActualFontName() string {
|
func (c *ControlBase) ActualFontName() string {
|
||||||
if len(c.FontName) == 0 {
|
if c.FontName == "" {
|
||||||
return "default"
|
return "default"
|
||||||
}
|
}
|
||||||
return c.FontName
|
return c.FontName
|
||||||
|
4
intro.go
4
intro.go
@ -10,9 +10,9 @@ func (i *Intro) Init(ctx *Context) error {
|
|||||||
i.welcome.Text =
|
i.welcome.Text =
|
||||||
"Welcome to Botanim!\n\n" +
|
"Welcome to Botanim!\n\n" +
|
||||||
"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 harvest flowers again to collect more money.\n\n" +
|
||||||
"Controls:\n" +
|
"Controls:\n" +
|
||||||
" - H: Selects shovel\n" +
|
" - H: Selects harvest tool\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" +
|
||||||
|
16
research.go
16
research.go
@ -52,6 +52,10 @@ type Digit struct {
|
|||||||
highlight int
|
highlight int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *Digit) Blink() {
|
||||||
|
d.highlight = 4
|
||||||
|
}
|
||||||
|
|
||||||
func (d *Digit) Render(ctx *Context) {
|
func (d *Digit) Render(ctx *Context) {
|
||||||
font := ctx.Fonts.Font("title")
|
font := ctx.Fonts.Font("title")
|
||||||
color := White
|
color := White
|
||||||
@ -61,10 +65,6 @@ func (d *Digit) Render(ctx *Context) {
|
|||||||
font.RenderCopyAlign(ctx.Renderer, d.Value, Pt(d.Bounds.X+d.Bounds.W/2, d.Bounds.Y+int32(font.Height())), color, TextAlignmentCenter)
|
font.RenderCopyAlign(ctx.Renderer, d.Value, Pt(d.Bounds.X+d.Bounds.W/2, d.Bounds.Y+int32(font.Height())), color, TextAlignmentCenter)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Digit) Blink() {
|
|
||||||
d.highlight = 4
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *Digit) Tick() {
|
func (d *Digit) Tick() {
|
||||||
if d.highlight > 0 {
|
if d.highlight > 0 {
|
||||||
d.highlight--
|
d.highlight--
|
||||||
@ -80,10 +80,15 @@ func (r *Research) Init(ctx *Context) error {
|
|||||||
r.AddChild(&r.description)
|
r.AddChild(&r.description)
|
||||||
r.AddChild(&r.specialists)
|
r.AddChild(&r.specialists)
|
||||||
r.AddChild(&r.input)
|
r.AddChild(&r.input)
|
||||||
|
|
||||||
r.description.Text = "Call a specialist to conduct research with."
|
r.description.Text = "Call a specialist to conduct research with."
|
||||||
r.digits = make([]Digit, 10)
|
r.digits = make([]Digit, 10)
|
||||||
for i := range r.digits {
|
for i := range r.digits {
|
||||||
|
j := i
|
||||||
r.digits[i].Value = strconv.Itoa(i)
|
r.digits[i].Value = strconv.Itoa(i)
|
||||||
|
r.digits[i].OnLeftMouseButtonClick = func(*Context) {
|
||||||
|
r.userTyped(j)
|
||||||
|
}
|
||||||
r.AddChild(&r.digits[i])
|
r.AddChild(&r.digits[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,6 +140,9 @@ func (r *Research) userTyped(i int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *Research) Handle(ctx *Context, event sdl.Event) bool {
|
func (r *Research) Handle(ctx *Context, event sdl.Event) bool {
|
||||||
|
if r.Container.Handle(ctx, event) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
switch e := event.(type) {
|
switch e := event.(type) {
|
||||||
case *sdl.KeyboardEvent:
|
case *sdl.KeyboardEvent:
|
||||||
if e.Type == sdl.KEYDOWN {
|
if e.Type == sdl.KEYDOWN {
|
||||||
|
25
tooltip.go
25
tooltip.go
@ -9,15 +9,26 @@ type Tooltip struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const tooltipBorderThickness = 1
|
const tooltipBorderThickness = 1
|
||||||
const tooltipHorizontalPadding = 4
|
const tooltipHorizontalPadding = 6
|
||||||
|
const tooltipVerticalPadding = 2
|
||||||
const tooltipMouseDistance = 12
|
const tooltipMouseDistance = 12
|
||||||
|
|
||||||
|
func (t *Tooltip) ActualFontName() string {
|
||||||
|
if t.FontName == "" {
|
||||||
|
return "small"
|
||||||
|
}
|
||||||
|
return t.FontName
|
||||||
|
}
|
||||||
|
|
||||||
func (t *Tooltip) Handle(ctx *Context, event sdl.Event) bool {
|
func (t *Tooltip) Handle(ctx *Context, event sdl.Event) bool {
|
||||||
if len(t.Text) == 0 {
|
if len(t.Text) == 0 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
font := ctx.Fonts.Font(t.ActualFontName())
|
font := ctx.Fonts.Font(t.ActualFontName())
|
||||||
|
if font == nil {
|
||||||
|
font = ctx.Fonts.Font("default")
|
||||||
|
}
|
||||||
windowW, windowH, err := ctx.Renderer.GetOutputSize()
|
windowW, windowH, err := ctx.Renderer.GetOutputSize()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
@ -30,7 +41,7 @@ func (t *Tooltip) Handle(ctx *Context, event sdl.Event) bool {
|
|||||||
|
|
||||||
mouse := ctx.MousePosition
|
mouse := ctx.MousePosition
|
||||||
width := int32(labelW) + 2*tooltipBorderThickness + 2*tooltipHorizontalPadding
|
width := int32(labelW) + 2*tooltipBorderThickness + 2*tooltipHorizontalPadding
|
||||||
height := int32(labelH) + 2*tooltipBorderThickness
|
height := int32(labelH) + 2*tooltipBorderThickness + 2*tooltipVerticalPadding
|
||||||
|
|
||||||
left := mouse.X + tooltipMouseDistance
|
left := mouse.X + tooltipMouseDistance
|
||||||
top := mouse.Y + tooltipMouseDistance
|
top := mouse.Y + tooltipMouseDistance
|
||||||
@ -46,14 +57,16 @@ func (t *Tooltip) Handle(ctx *Context, event sdl.Event) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *Tooltip) Render(ctx *Context) {
|
func (t *Tooltip) Render(ctx *Context) {
|
||||||
SetDrawColor(ctx.Renderer, Black)
|
almostBlack := MustHexColor("#0000007f")
|
||||||
|
SetDrawColor(ctx.Renderer, almostBlack)
|
||||||
ctx.Renderer.FillRect(t.Bounds.SDLPtr())
|
ctx.Renderer.FillRect(t.Bounds.SDLPtr())
|
||||||
|
|
||||||
SetDrawColor(ctx.Renderer, White)
|
almostWhite := MustHexColor("ffffff7f")
|
||||||
|
SetDrawColor(ctx.Renderer, almostWhite)
|
||||||
ctx.Renderer.DrawRect(t.Bounds.SDLPtr())
|
ctx.Renderer.DrawRect(t.Bounds.SDLPtr())
|
||||||
|
|
||||||
font := t.ActualFont(ctx)
|
font := ctx.Fonts.Font(t.ActualFontName())
|
||||||
|
|
||||||
bottomLeft := Pt(t.Bounds.X+tooltipBorderThickness+tooltipHorizontalPadding, t.Bounds.Y+t.Bounds.H-tooltipBorderThickness)
|
bottomLeft := Pt(t.Bounds.X+tooltipBorderThickness+tooltipHorizontalPadding, t.Bounds.Y+t.Bounds.H-tooltipBorderThickness-tooltipVerticalPadding)
|
||||||
font.RenderCopy(ctx.Renderer, t.Text, bottomLeft, White)
|
font.RenderCopy(ctx.Renderer, t.Text, bottomLeft, White)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user