Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kemokemo/ebiten-gauge
a gauge parts for ebitengine games
https://github.com/kemokemo/ebiten-gauge
ebiten-parts ebitengine golang
Last synced: 1 day ago
JSON representation
a gauge parts for ebitengine games
- Host: GitHub
- URL: https://github.com/kemokemo/ebiten-gauge
- Owner: kemokemo
- License: apache-2.0
- Created: 2022-11-08T14:21:49.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-23T13:54:15.000Z (over 1 year ago)
- Last Synced: 2024-06-21T07:45:03.806Z (5 months ago)
- Topics: ebiten-parts, ebitengine, golang
- Language: Go
- Homepage:
- Size: 608 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ebiten Gauge
This is a package for displaying a simple gauge.
It is intended to be used in games that use [ebiten](https://ebiten.org/).![sample](media/sample.png)
## How to use
First of all, you need create an instance of the gauge.
```go
// position
x := 50
y := 80
// gauge's max value
max := 100// create gauge instance
gauge1 := gauge.NewGauge(x, y, max)// If you want to specify the dot's color of this gauge,
// you can use NewGaugeWithColor function
//
gaugeGray := gauge.NewGaugeWithColor(x, y, max, color.RGBA{R: 80, G: 80, B: 80, A: 255})// If you want to specify scale for gauge,
// you can use NewGaugeWithScale function
// gaugeGray := gauge.NewGaugeWithScale(x, y, max, color.RGBA{R: 80, G: 80, B: 80, A: 255}, 2.0)
```In standard operation, the dot of gauge blinks when the current value reaches the MAX value. Blinking can be turned off for gauges that do not require blinking or are mainly used for decreasing values.
```go
gauge1 := gauge.NewGauge(x, y, max)// turn off blinking
gauge1.SetBlink(false)
```Second, you updates on the `ebiten.game`'s update function. Please call `Update` function with the current value for the gauge.
```go
func (g *Game) Update() error {
// currentValue is updated by your game logicg.gauge1.Update(float64(currentValue))
// some logic...
return nil
}
```Third, draw the gauge on the Draw function of your game.
```go
func (g *Game) Draw(screen *ebiten.Image) {
// draw some other itemsg.gauge1.Draw(screen)
// draw some other items
}
```That's all!
Please check [the sample app](https://github.com/kemokemo/ebiten-gauge/tree/main/cmd) for more detail.
### Basic
## License
Apache-2.0 License
## Author
kemokemo