-
Notifications
You must be signed in to change notification settings - Fork 6
/
golfStartup.go
80 lines (72 loc) · 2.31 KB
/
golfStartup.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package golf
import "math"
// startupAnim runs the startup animation for golf engine
func (e *Engine) startupAnim() {
frame := e.Frames()
startLogo, startText := 0, 80
endLogo, endIntro := 180, 180
fadeSpeed := 5
fadeLen := fadeSpeed*8 - 1
fadeFrom := []Col{Col0, Col1, Col2, Col3, Col4, Col5, Col6, Col7}
fadeTo := [][]Col{
[]Col{Col7, Col7, Col7, Col7, Col7, Col7, Col7, Col7},
[]Col{Col3, Col7, Col7, Col7, Col7, Col7, Col7, Col7},
[]Col{Col6, Col3, Col7, Col7, Col7, Col7, Col7, Col7},
[]Col{Col2, Col6, Col3, Col7, Col7, Col7, Col7, Col7},
[]Col{Col5, Col2, Col6, Col3, Col7, Col7, Col7, Col7},
[]Col{Col1, Col5, Col2, Col6, Col3, Col7, Col7, Col7},
[]Col{Col4, Col1, Col5, Col2, Col6, Col3, Col7, Col7},
[]Col{Col0, Col4, Col1, Col5, Col2, Col6, Col3, Col7},
[]Col{Col0, Col0, Col4, Col1, Col5, Col2, Col6, Col3},
[]Col{Col0, Col0, Col0, Col4, Col1, Col5, Col2, Col6},
[]Col{Col0, Col0, Col0, Col0, Col4, Col1, Col5, Col2},
[]Col{Col0, Col0, Col0, Col0, Col0, Col4, Col1, Col5},
[]Col{Col0, Col0, Col0, Col0, Col0, Col0, Col4, Col1},
[]Col{Col0, Col0, Col0, Col0, Col0, Col0, Col0, Col4},
[]Col{Col0, Col0, Col0, Col0, Col0, Col0, Col0, Col0},
}
// Clear the BG
bgCol := Col7
if frame > endIntro {
bgCol = fadeTo[(frame-endIntro)/fadeSpeed][0]
}
if frame > endIntro+fadeLen {
bgCol = Col0
}
e.Cls(bgCol)
// Draw "made with"
txtf := 0
if frame > startText {
txtf = (frame - startText) / fadeSpeed
}
if frame > startText+fadeLen {
txtf = 7
}
tCol := TOp{Col: fadeTo[txtf][0], SH: 2, SW: 2}
e.Text(10, 50, "made with", tCol)
// Draw golf logo
sprf := 0
s := 0.0
if frame > startLogo {
s = math.Sin(float64(frame-startLogo)/30) + 1
sprf = (frame - startLogo) / fadeSpeed
}
if frame > startLogo+fadeLen {
s = 2
sprf = 7
}
if frame > endLogo {
sprf = (frame-endLogo)/fadeSpeed + 7
}
if frame > endLogo+fadeLen {
sprf = 14
}
width := 64.0 * s
// Change to the internal sprite sheet
e.RAM[activeSpriteBuff] = internalSpriteBase >> 8
e.RAM[activeSpriteBuff+1] = internalSpriteBase & 0b0000000011111111
e.SSpr(152, 0, 64, 24, float64(96-(width/2)), 64.0, SOp{TCol: Col1, SW: s, SH: s, PFrom: fadeFrom, PTo: fadeTo[sprf]})
// Change back to the main sprite sheet
e.RAM[activeSpriteBuff] = spriteBase >> 8
e.RAM[activeSpriteBuff+1] = spriteBase & 0b0000000011111111
}