mirror of
https://github.com/make-42/xyosc
synced 2025-03-21 03:13:19 +01:00
yes
This commit is contained in:
parent
853354a11f
commit
4c182ccb8a
18
main.go
18
main.go
@ -6,6 +6,7 @@ import (
|
|||||||
"image/color"
|
"image/color"
|
||||||
"log"
|
"log"
|
||||||
"math/rand/v2"
|
"math/rand/v2"
|
||||||
|
"slices"
|
||||||
"sort"
|
"sort"
|
||||||
"xyosc/audio"
|
"xyosc/audio"
|
||||||
"xyosc/config"
|
"xyosc/config"
|
||||||
@ -34,7 +35,17 @@ func (g *Game) Update() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var prevFrame *ebiten.Image
|
||||||
|
var firstFrame = true
|
||||||
|
var ColorScale ebiten.ColorScale
|
||||||
|
|
||||||
func (g *Game) Draw(screen *ebiten.Image) {
|
func (g *Game) Draw(screen *ebiten.Image) {
|
||||||
|
if firstFrame {
|
||||||
|
prevFrame = screen
|
||||||
|
firstFrame = false
|
||||||
|
} else {
|
||||||
|
screen.DrawImage(prevFrame, &ebiten.DrawImageOptions{ColorScale: ColorScale})
|
||||||
|
}
|
||||||
scale := min(config.Config.WindowWidth, config.Config.WindowHeight) / 2
|
scale := min(config.Config.WindowWidth, config.Config.WindowHeight) / 2
|
||||||
var AX float32
|
var AX float32
|
||||||
var AY float32
|
var AY float32
|
||||||
@ -42,7 +53,9 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
|||||||
var BY float32
|
var BY float32
|
||||||
var numSamples = config.Config.ReadBufferSize / audio.SampleSizeInBytes * 4
|
var numSamples = config.Config.ReadBufferSize / audio.SampleSizeInBytes * 4
|
||||||
var FFTBuffer = make([]float64, numSamples)
|
var FFTBuffer = make([]float64, numSamples)
|
||||||
if inpututil.IsKeyJustPressed(ebiten.KeyF) {
|
var pressedKeys []ebiten.Key
|
||||||
|
inpututil.AppendPressedKeys(pressedKeys)
|
||||||
|
if slices.Contains(pressedKeys, ebiten.KeyF) {
|
||||||
config.SingleChannel = !config.SingleChannel
|
config.SingleChannel = !config.SingleChannel
|
||||||
}
|
}
|
||||||
if !config.SingleChannel {
|
if !config.SingleChannel {
|
||||||
@ -154,7 +167,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
|||||||
Size: 32,
|
Size: 32,
|
||||||
}, op)
|
}, op)
|
||||||
}
|
}
|
||||||
|
prevFrame = screen
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) {
|
func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) {
|
||||||
@ -177,6 +190,7 @@ func main() {
|
|||||||
screenW, screenH := ebiten.Monitor().Size()
|
screenW, screenH := ebiten.Monitor().Size()
|
||||||
ebiten.SetWindowPosition(screenW/2-int(config.Config.WindowWidth)/2, screenH/2-int(config.Config.WindowHeight)/2)
|
ebiten.SetWindowPosition(screenW/2-int(config.Config.WindowWidth)/2, screenH/2-int(config.Config.WindowHeight)/2)
|
||||||
ebiten.SetVsyncEnabled(true)
|
ebiten.SetVsyncEnabled(true)
|
||||||
|
ColorScale.SetA(0.8)
|
||||||
if err := ebiten.RunGameWithOptions(&Game{}, &ebiten.RunGameOptions{ScreenTransparent: true}); err != nil {
|
if err := ebiten.RunGameWithOptions(&Game{}, &ebiten.RunGameOptions{ScreenTransparent: true}); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user