summaryrefslogtreecommitdiff
path: root/level.go
blob: 0f18085bf541cae20b575ec43e88e4233219df0d (plain)
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
package main

import (
    "fmt"
)

func ReverseLevel(g *Game) {
    fmt.Printf("pframe %d/%d\n", 0, len(g.playerAi))
    g.SetReversing()
}

func playTheEnd(g *Game) {
    g.animStart = g.time
    g.state = END
}

func afterReversed(g *Game) {
    g.shaderName = "none"
    g.ResetAll()
    g.playerAiIdx = 0
    g.TransitionState()
}

func levelStart(g *Game) {
    g.ResetAll()
    g.playerAiIdx = 0
    g.SetInGame()
    for _, o := range g.objects {
        o.movable = false
    }
}

func StartGame(g *Game) {
    StartLevel4(g)
}

func StartLevel1(g *Game ) {
    g.SetInGame()

    tilemap := NewTilemap([][]int{
            {
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 51, 36, 34, 35, 36, 34, 35, 36, 34, 35, 36, 34, 35, 36, 34, 35, 36, 34, 35, 36, 34, 67, 0,
                0, 50, 54, 55, 53, 54, 55, 53, 54, 55, 53, 54, 55, 53, 54, 55, 53, 54, 55, 53, 54, 55, 53, 54, 0,
                0, 53, 70, 71, 69, 70, 71, 69, 70, 71, 69, 70, 71, 69, 70, 71, 69, 70, 71, 69, 70, 71, 69, 70, 0,
                0, 69, 38, 39, 37, 38, 39, 37, 38, 39, 37, 38, 39, 37, 38, 39, 37, 38, 39, 37, 38, 39, 37, 38, 0,
                0, 69, 38, 39, 37, 38, 39, 37, 38, 39, 37, 38, 39, 37, 38, 39, 37, 38, 39, 37, 38, 39, 37, 38, 0,
			},
		}, 25)

    g.tilemap = &tilemap
    g.tilemap.UpdateSurface()

    // when hit end
    g.QueueState(func (g *Game){
        g.animStart = g.time
        playTheEnd(g)
        g.state = END

    })
    // after end
    g.QueueState(ReverseLevel)
    // after reversed
    g.QueueState(afterReversed)
    g.QueueState(StartLevel2)
}

func StartLevel2(g *Game) {
    g.SetPlacing()

    g.toPlace = append(g.toPlace, NewLeftSpike(g, 0, 0))

    // after end
    g.QueueState(ReverseLevel)
    // after reversed
    g.QueueState(afterReversed)
    g.QueueState(StartLevel3)
}

func StartLevel3(g *Game) {
    g.SetPlacing()

    g.toPlace = append(g.toPlace, NewSpike(g, 0, 0))

    // after end
    g.QueueState(ReverseLevel)
    // after reversed
    g.QueueState(afterReversed)
    g.QueueState(StartLevel4)
}

func StartLevel4(g *Game) {
    g.SetPlacing()
    g.toPlace = append(g.toPlace, NewSpring(g, 0, 0))

    g.ClearAll()
    tilemap := NewTilemap([][]int{
            {
                0, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
                0, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
                0, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
                0, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
                0, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
                0, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
                0, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
                0, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
                0, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  35, 36, 34, 35, 36, 34, 35, 36, 34, 67, 0,
                0, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  38, 39, 37, 38, 39, 37, 38, 39, 37, 38, 0,
                0, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  54, 55, 53, 54, 55, 53, 54, 55, 53, 54, 0,
                0, 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  70, 71, 69, 70, 71, 69, 70, 71, 69, 70, 0,
                0, 0,  51, 36, 34, 35, 36, 34, 35, 36, 34, 35, 36, 34, 38, 39, 37, 38, 39, 37, 38, 39, 37, 38, 0,
                0, 50, 54, 55, 53, 54, 55, 53, 54, 55, 53, 54, 55, 53, 54, 55, 53, 54, 55, 53, 54, 55, 53, 54, 0,
                0, 53, 70, 71, 69, 70, 71, 69, 70, 71, 69, 70, 71, 69, 70, 71, 69, 70, 71, 69, 70, 71, 69, 70, 0,
                0, 69, 38, 39, 37, 38, 39, 37, 38, 39, 37, 38, 39, 37, 38, 39, 37, 38, 39, 37, 38, 39, 37, 38, 39,
			},
		}, 25)

    g.tilemap = &tilemap
    g.tilemap.UpdateSurface()
    g.exit.startx = 20 * tileSize
    g.exit.starty = 6 * tileSize

    g.ResetAll()
    g.playerAi = g.playerAi[:0]

    g.QueueState(levelStart)
    // after end
    g.QueueState(ReverseLevel)
    // after reversed
    g.QueueState(afterReversed)
    g.QueueState(StartLevel5)
}

func StartLevel5(g *Game) {
    g.SetPlacing()
    g.toPlace = append(g.toPlace, NewSpike(g, 0, 0))
    g.exit.movable = true

    // after end
    g.QueueState(ReverseLevel)
    // after reversed
    g.QueueState(afterReversed)
    g.QueueState(StartLevel5)
}