A simple generic tower defense game written C. Using GLFW, OpenGL4.2 (GLEW), stb_image.h libraries.
Enemies start from a start point and move towards the goal. The player's tasked with stopping these enemies by shooting them with turrets they place.
March from spawner to goal cell until they reach it or die. The player gets money for killing them. If they reach the goal they despawn the player loses a life.
Can be used to:
- build towers
- upgrade towers (damage, firerate, range)
Can be altered by the player between set presets of: least/most HP, closest/furthest, slowest/fastest.
Loads the map and puts the player in the interwave state.
Upon pressing the Start wave
button a wave starts (which cannot be cancelled from now on). It spawns a set number of enemies and then waits for the player killing them or them reaching the goal. After which it puts the player back in the interwave state (presenting the start wave button again).
The cells of the map and the spawner's properties are read from the sample.map
file.
money [x:int]
hp [x:int]
Camera will be initially set to the cell set as a cell_camera
:
cell_camera [x:int] [y:int]
cells [rows:int] [cols:int]
cell [x:int] [y:int] [type:string]
...
endcells
"unbuildable" // no tower can be built on it, no enemy can step on it
"buildable" // tower can be built on it, no enemy can step on it (NOTE: all cell is implicitly marked as buildable)
"path" // no tower can be built on it, enemies can step on it
"spawner" // no tower can be built on it, enemies appear from here (there may be only be one spawner)
"goal" // no tower can be built on it, enemies march to here (there may be only be one goal)
spawner
hp_func [type:string] {parameters}
hp_deviation_func [type:string] {parameters}
speed_func [type:string] {parameters}
speed_deviation_func [type:string] {parameters}
money_func [type:string] {parameters}
num_func [type:string] [{parameter}
endspawner
Parameters means fix number of double values. See also next section for function types and their parameters.
constant – 1 parameter p[0]
linear – 2 parameter p[0]+p[1]*x
quadratic – 2 parameter p[0]+p[1]*x^2
power – 3 parameter p[0]+p[1]*x^p[2]
exponential – 3 parameter p[0]+p[1]*p[2]^x
logarithmic – 3 parameter p[0]+p[1]*log_base_p[2](p[2]+x)