This repository has been archived by the owner on Jun 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SweetSorting.zgeproj
195 lines (193 loc) · 6.4 KB
/
SweetSorting.zgeproj
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="Title" ClearColor="0 1 1 1" NoSound="1">
<OnLoaded>
<DefineVariable Name="GameScore"/>
<DefineVariable Name="PlayerLives"/>
<DefineVariable Name="PlayerPosition"/>
<DefineVariable Name="CandyTimer"/>
<DefineVariable Name="CandySwitch"/>
<SetAppState State="Title"/>
</OnLoaded>
<States>
<AppState Name="Title" CollisionsEnabled="0">
<OnStart>
<ZExpression Expression="App.Caption = "Title";"/>
</OnStart>
<OnUpdate>
<KeyPress Comment="Press Space to Continue" Keys=" ">
<OnPressed>
<SetAppState State="Playing"/>
</OnPressed>
</KeyPress>
</OnUpdate>
<OnRender>
<UseMaterial Material="BaseMaterial"/>
<RenderSetColor Color="1 0 0.502 1"/>
<RenderText Text="Sweet Sorting"/>
</OnRender>
</AppState>
<AppState Name="Playing">
<OnStart>
<ZExpression Comment="VariableInitialize">
<Expression>
<![CDATA[GameScore = 0;
PlayerLives = 3;
App.Caption = "Playing";]]>
</Expression>
</ZExpression>
<SpawnModel Model="PlayerModel" Position="0 -5 0"/>
</OnStart>
<OnUpdate>
<ZExpression Expression="CandyTimer = CandyTimer - App.DeltaTime;"/>
<Condition Comment="Spawn Timer" Expression="return CandyTimer <= 0;">
<OnTrue>
<ZExpression Comment="CandySwitch Set" Expression="CandySwitch = random(50, 50);"/>
<Condition Comment="CandySwitch Check" Expression="return CandySwitch < 50;">
<OnTrue>
<SpawnModel Model="CandyLeft" Position="0 6 0"/>
</OnTrue>
<OnFalse>
<SpawnModel Model="CandyRight" Position="0 6 0"/>
</OnFalse>
</Condition>
<ZExpression Comment="Timer Reset" Expression="CandyTimer = random(2, 1.5);"/>
</OnTrue>
</Condition>
<Condition Comment="Game Over" Expression="return PlayerLives <= 0;">
<OnTrue>
<RemoveAllModels/>
<SetAppState State="Title"/>
</OnTrue>
</Condition>
</OnUpdate>
<OnRender>
<UseMaterial Material="BaseMaterial"/>
<RenderSetColor Color="1 0 0 1"/>
<RenderText Text="Red" X="-0.75" Y="0.6"/>
<RenderSetColor Color="0 0 1 1"/>
<RenderText Text="Blue" X="0.75" Y="0.6"/>
</OnRender>
</AppState>
</States>
<OnRender>
<UseMaterial Material="BaseMaterial"/>
<RenderSetColor Color="0.502 0 0 1"/>
<RenderText Text="Score:" TextFloatRef="GameScore Value" X="-0.95" Y="0.95" Scale="0.5" Align="1"/>
<RenderSetColor Color="0 0.502 0 1"/>
<RenderText Text="Lives:" TextFloatRef="PlayerLives Value" X="0.6" Y="0.95" Scale="0.5" Align="1"/>
</OnRender>
<Content>
<Material Name="BaseMaterial" Blend="1"/>
<Group Name="Player">
<Children>
<Mesh Name="PlayerBody">
<Producers>
<MeshBox Scale="0.75 0.75 0.5"/>
</Producers>
</Mesh>
<Model Name="PlayerModel" Rotation="0 0 0.125" Scale="2 2 1">
<Definitions>
<DefineVariable Name="PlayerSpeed"/>
</Definitions>
<OnRender>
<UseMaterial Material="PlayerMaterial"/>
<RenderSetColor Color="0.502 0.502 0.502 1"/>
<RenderMesh Mesh="PlayerBody"/>
</OnRender>
<OnUpdate>
<ZExpression Expression="CurrentModel.Velocity.X = 0;"/>
<KeyPress Keys=">">
<OnPressed>
<ZExpression Expression="CurrentModel.Velocity.X = PlayerSpeed;"/>
</OnPressed>
</KeyPress>
<KeyPress Keys="<">
<OnPressed>
<ZExpression Expression="CurrentModel.Velocity.X = PlayerSpeed * -1;"/>
</OnPressed>
</KeyPress>
<ZExpression Name="RestrictMovement">
<Expression>
<![CDATA[CurrentModel.Position.X = clamp(CurrentModel.Position.X, -5, 5);
PlayerPosition = CurrentModel.Position.X;]]>
</Expression>
</ZExpression>
</OnUpdate>
<OnSpawn>
<ZExpression Expression="PlayerSpeed = 10;"/>
</OnSpawn>
</Model>
<Material Name="PlayerMaterial"/>
</Children>
</Group> <!-- Player -->
<Group Name="Candy">
<Children>
<Model Name="CandyLeft">
<OnRender>
<RenderSetColor Color="1 0 0 1"/>
<RenderMesh Mesh="CandyMesh"/>
</OnRender>
<OnUpdate>
<Condition Expression=" return CurrentModel.Position.Y < -5;">
<OnTrue>
<ZExpression>
<Expression>
<![CDATA[if(CurrentModel.Position.X > PlayerPosition) {
PlayerLives = PlayerLives - 1;
} else {
GameScore = GameScore + 1;
}]]>
</Expression>
</ZExpression>
<RemoveModel/>
</OnTrue>
</Condition>
</OnUpdate>
<OnSpawn>
<ZExpression>
<Expression>
<![CDATA[CurrentModel.Position.X = random(0, 4);
CurrentModel.Velocity.Y = -7;]]>
</Expression>
</ZExpression>
</OnSpawn>
</Model>
<Mesh Name="CandyMesh">
<Producers>
<MeshSphere Scale="0.7 0.7 0.7" ZSamples="15" RadialSamples="15"/>
</Producers>
</Mesh>
<Model Name="CandyRight">
<OnRender>
<RenderSetColor Color="0 0 1 1"/>
<RenderMesh Mesh="CandyMesh"/>
</OnRender>
<OnUpdate>
<Condition Expression=" return CurrentModel.Position.Y < -5;">
<OnTrue>
<ZExpression>
<Expression>
<![CDATA[if(CurrentModel.Position.X < PlayerPosition) {
PlayerLives = PlayerLives - 1;
} else {
GameScore = GameScore + 1;
}]]>
</Expression>
</ZExpression>
<RemoveModel/>
</OnTrue>
</Condition>
</OnUpdate>
<OnSpawn>
<ZExpression>
<Expression>
<![CDATA[CurrentModel.Position.X = random(0, 4);
CurrentModel.Velocity.Y = -7;]]>
</Expression>
</ZExpression>
</OnSpawn>
</Model>
</Children>
</Group> <!-- Candy -->
</Content>
</ZApplication>