Compare commits

..

5 Commits

6 changed files with 106 additions and 25 deletions

View File

@@ -9,10 +9,11 @@ import (
) )
type FontBase struct { type FontBase struct {
Title font.Face Title font.Face
Menu font.Face Menu font.Face
Splash font.Face Splash font.Face
BigTitle font.Face BigTitle font.Face
MegaTitle font.Face
} }
var ( var (
@@ -69,4 +70,13 @@ func init() {
log.Fatal(err) log.Fatal(err)
} }
SplashFont.MegaTitle, err = opentype.NewFace(tt, &opentype.FaceOptions{
Size: 70,
DPI: dpi,
Hinting: font.HintingVertical,
})
if err != nil {
log.Fatal(err)
}
} }

View File

@@ -145,6 +145,8 @@ func (b *Bsoft) Update() error {
if b.curtain.IsComplete() { if b.curtain.IsComplete() {
if b.events[groovy.COMPLETED] != nil { if b.events[groovy.COMPLETED] != nil {
b.events[groovy.COMPLETED]() b.events[groovy.COMPLETED]()
b.curtain.Clear()
} }
} }
b.curtain.Update() b.curtain.Update()
@@ -152,6 +154,11 @@ func (b *Bsoft) Update() error {
return nil return nil
} }
func (f *Fader) Clear() {
f.alpha = 0 //reset fader
f.counter = 0
}
func (b *Bsoft) Draw(screen *ebiten.Image) { func (b *Bsoft) Draw(screen *ebiten.Image) {
b.DrawGlitchLogo(screen) b.DrawGlitchLogo(screen)
b.DrawGlitchLogoText(screen) b.DrawGlitchLogoText(screen)

View File

@@ -156,6 +156,8 @@ type SplashPad struct {
heroImpulse impulse heroImpulse impulse
jumping bool jumping bool
jumptimer int jumptimer int
controller bool
} }
func NewSplashPad() SplashPad { func NewSplashPad() SplashPad {
@@ -184,6 +186,7 @@ func NewSplashPad() SplashPad {
hero: h, hero: h,
jumping: false, jumping: false,
jumptimer: 0, jumptimer: 0,
controller: false,
} }
gravity := &force{} gravity := &force{}
@@ -240,6 +243,13 @@ func (s *SplashPad) Update() error {
s.hero.jumptime = 0 s.hero.jumptime = 0
s.hero.jumping = false s.hero.jumping = false
} }
//check for user input to transition scene
if inpututil.IsKeyJustPressed(ebiten.KeyQ) {
if s.events[groovy.COMPLETED] != nil {
s.events[groovy.COMPLETED]()
}
}
return nil return nil
} }
@@ -468,15 +478,19 @@ func (s *SplashPad) handleLeftMovement() {
s.hero.runningLeft = true s.hero.runningLeft = true
log.Println(" left gamepad engaged") log.Println(" left gamepad engaged")
s.hero.facingLeft = true s.hero.facingLeft = true
s.controller = true
} }
if -SENSITIVITY < ebiten.GamepadAxisValue(0, 0) && ebiten.GamepadAxisValue(0, 0) < SENSITIVITY { if s.controller {
s.hero.runningLeft = false if -SENSITIVITY < ebiten.GamepadAxisValue(0, 0) && ebiten.GamepadAxisValue(0, 0) < SENSITIVITY {
if s.hero.runningStopFrame > 0 { s.hero.runningLeft = false
s.hero.runningStopFrame = s.increment if s.hero.runningStopFrame > 0 {
log.Println(" left gamepad released") s.hero.runningStopFrame = s.increment
} log.Println(" left gamepad released")
s.controller = false
}
}
} }
//if running, need to update their position //if running, need to update their position
@@ -501,7 +515,7 @@ func (s *SplashPad) handleLeftMovement() {
deltaT := float32(s.increment - s.hero.runningStopFrame) deltaT := float32(s.increment - s.hero.runningStopFrame)
offset = TOP_SPEED - int(scaler*deltaT) offset = TOP_SPEED - int(scaler*deltaT)
offset = max(0, offset) //should not be less than zero, otherwise player would move wrong way ?? offset = int(math.Max(0, float64(offset))) //should not be less than zero, otherwise player would move wrong way ??
log.Printf(" stopping (%d,%d)...", s.hero.posX, s.hero.posY) log.Printf(" stopping (%d,%d)...", s.hero.posX, s.hero.posY)
} else { } else {
s.hero.runningStopFrame = 0 s.hero.runningStopFrame = 0
@@ -538,15 +552,18 @@ func (s *SplashPad) handleRightMovement() {
s.hero.runningRight = true s.hero.runningRight = true
log.Println(" right gamepad engaged") log.Println(" right gamepad engaged")
s.hero.facingLeft = false s.hero.facingLeft = false
s.controller = true
} }
if s.controller {
if -SENSITIVITY < ebiten.GamepadAxisValue(0, 0) && ebiten.GamepadAxisValue(0, 0) < SENSITIVITY {
s.hero.runningRight = false
if s.hero.runningStopFrame > 0 {
s.hero.runningStopFrame = s.increment
log.Println(" right gamepad released")
s.controller = false
}
if -SENSITIVITY < ebiten.GamepadAxisValue(0, 0) && ebiten.GamepadAxisValue(0, 0) < SENSITIVITY {
s.hero.runningRight = false
if s.hero.runningStopFrame > 0 {
s.hero.runningStopFrame = s.increment
log.Println(" right gamepad released")
} }
} }
//if running, need to update their position //if running, need to update their position

View File

@@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"image" "image"
"image/color" "image/color"
"math"
"github.com/hajimehoshi/ebiten/v2" "github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/inpututil" "github.com/hajimehoshi/ebiten/v2/inpututil"
@@ -105,10 +106,10 @@ func (n *Noisy) SetDimensions(a groovy.Area) {
func (n *Noisy) UpdateNoise() { func (n *Noisy) UpdateNoise() {
//update cursor position and lock it into the game region bounds //update cursor position and lock it into the game region bounds
n.sX, n.sY = ebiten.CursorPosition() n.sX, n.sY = ebiten.CursorPosition()
n.sX = min(n.sX, n.Dimensions.Width-1) n.sX = int(math.Min(float64(n.sX), float64(n.Dimensions.Width-1)))
n.sX = max(n.sX, 0) n.sX = int(math.Max(float64(n.sX), 0))
n.sY = min(n.sY, n.Dimensions.Height-1) n.sY = int(math.Min(float64(n.sY), float64(n.Dimensions.Height-1)))
n.sY = max(n.sY, 0) n.sY = int(math.Max(float64(n.sY), 0))
l := n.Dimensions.Width * n.Dimensions.Height l := n.Dimensions.Width * n.Dimensions.Height

View File

@@ -10,6 +10,7 @@ import (
"math/rand" "math/rand"
"github.com/hajimehoshi/ebiten/v2" "github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/inpututil"
"github.com/hajimehoshi/ebiten/v2/vector" "github.com/hajimehoshi/ebiten/v2/vector"
_ "embed" _ "embed"
@@ -104,6 +105,17 @@ func NewParallax() Parallax {
func (p *Parallax) Update() error { func (p *Parallax) Update() error {
p.increment++ p.increment++
var keysPressed []ebiten.Key
keysPressed = inpututil.AppendJustPressedKeys(keysPressed[:0])
//check for user input to transition scene
if inpututil.IsKeyJustPressed(ebiten.KeyQ) {
if p.events[groovy.COMPLETED] != nil {
p.events[groovy.COMPLETED]()
}
}
return nil return nil
} }
@@ -251,4 +263,27 @@ func (p *Parallax) RepositionTest(screen *ebiten.Image) {
vs[i].ColorA = 1 vs[i].ColorA = 1
} }
screen.DrawTriangles(vs, is, whiteSubImage, nil) screen.DrawTriangles(vs, is, whiteSubImage, nil)
//minX := x0 - xd
maxX := x0 + xd
//minY := y0 - yd
//maxY := y0 + yd
//178x229
roX := float64(178 / 4)
roY := float64(229 / 4)
startX := float64(maxX) + roX
startY := float64(y0) + roY/2
adjustment := 400.0
currentX := startX - float64(p.increment) + adjustment*math.Floor(float64(p.increment)/adjustment)
op := &ebiten.DrawImageOptions{}
op.GeoM.Scale(.5, .5)
op.GeoM.Translate(-roX, -roY)
op.GeoM.Rotate(-float64(p.increment) / (math.Pi * 12.0))
op.GeoM.Translate(currentX, startY)
screen.DrawImage(roids[1], op)
} }

View File

@@ -9,6 +9,10 @@ import (
"github.com/hajimehoshi/ebiten/v2/text" "github.com/hajimehoshi/ebiten/v2/text"
) )
const (
splashText = "schmoopysoft"
)
type Splash struct { type Splash struct {
Dimensions groovy.Area Dimensions groovy.Area
bgcolor color.RGBA bgcolor color.RGBA
@@ -26,15 +30,18 @@ func NewSplash() Splash {
func (s *Splash) Update() error { func (s *Splash) Update() error {
s.increment++ s.increment++
s.bgcolor.R = (s.bgcolor.R - 2) % 0xFF s.bgcolor.R = (s.bgcolor.R - 1) % 0xFF
s.bgcolor.G = (s.bgcolor.G - 2) % 0xFF s.bgcolor.G = (s.bgcolor.G - 1) % 0xFF
s.bgcolor.B = (s.bgcolor.B - 2) % 0xFF s.bgcolor.B = (s.bgcolor.B - 1) % 0xFF
if s.bgcolor.R == 0x00 { if s.bgcolor.R == 0x00 {
s.events[groovy.COMPLETED]() s.events[groovy.COMPLETED]()
//scene cleanup (for next time) //scene cleanup (for next time)
s.increment = 0 s.increment = 0
s.bgcolor.R = 0xFF
s.bgcolor.G = 0xFF
s.bgcolor.B = 0xFF
} }
return nil return nil
@@ -42,7 +49,11 @@ func (s *Splash) Update() error {
func (s *Splash) Draw(screen *ebiten.Image) { func (s *Splash) Draw(screen *ebiten.Image) {
screen.Fill(s.bgcolor) screen.Fill(s.bgcolor)
text.Draw(screen, "splash", splashmenu.SplashFont.Splash, 40, 40, color.White) x := s.Dimensions.Width/2 - 400
y := s.Dimensions.Height / 2
text.Draw(screen, splashText, splashmenu.SplashFont.MegaTitle, x, y, color.White)
text.Draw(screen, "\"how was the gravy\"\n- christorpher hollick", splashmenu.SplashFont.Title, x, y+40, color.White)
} }
func (s *Splash) SetEventHandler(event groovy.SceneEvent, f func()) { func (s *Splash) SetEventHandler(event groovy.SceneEvent, f func()) {