-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathREADME
95 lines (75 loc) · 4.39 KB
/
README
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
This is a combined effort (mainly mine) at making a cross-platform version of Snake! This is my first attempt at a game, so I'm still riding the learning curve quite a bit.
--------------------------------------------
THE GAME
--------------------------------------------
So far, it's really not much. There is game configuration in game.cfg (see CONFIG).
The game is played with a constantly-moving Snake. The Snake is turned using the arrow keys or mouse, but cannot be stopped. Turning the Snake so that it collides with a wall or itself causes the player to lose. The object of the game is to get as many points as possible before dying. Points can be gained or lost by eating different types of food. The Snake also grows longer after eating food, and gains points or speed intermittently.
Additionally, there are magenta mines which appear, which cause the player to die upon contact
--------------------------------------------
LANGUAGE
--------------------------------------------
This is written in C++ with Boost & SDL, with the nonstandard addition of #pragma once, due to common usage. As far as I'm aware, everything else is standards-conformant and should compile & run on any platform.
--------------------------------------------
DEPENDENCIES
--------------------------------------------
To compile, you will need:
-Boost C++ libraries (http://www.boost.org/users/download/)
-SDL SDK (http://www.libsdl.org/)
-SDL Runtime (http://www.libsdl.org/)
-CMake (http://www.cmake.org/cmake/resources/software.html)
To work with the audio files, you'll need a MIDI editor (I'm using Finale 2011)
--------------------------------------------
SNAKE GROWTH
--------------------------------------------
Snake growth is based on multiple factors:
-Linear coefficient of food
-Global linear coefficient
-Current snake length
-Growth cap
The amount by which the snake grows is:
min(length * global coefficient, growthCap) * food coefficient
It should be noted that the growth cap caps growth BEFORE being multiplied by the food coefficient.
--------------------------------------------
CONFIG
--------------------------------------------
The game config file (game.cfg) is organized as sets of key-value pairs. Related keys can be organized in Scopes.
Scopes are collections of key-value pairs surrounded by curly braces. The first string inside the curly braces is the Scope's name. Scopes can be nested within one another.
music/sound: Toggle audio effects (1 or 0)
FPS: The approximate FPS at which the game should run (unsigned short)
screen:
w/h: Width/height (unsigned long)
color: background color (3 unsigned bytes)
resources:
eat: path of the eating sound
spawn: path of the spawning sound
die: path of the dying sound
theme: path of the theme music
worldBounds: boundaries of the world (dictates the regions in which spawns can spawn)
min/max: pairs of (long, long)
walls: the set of all wall data
color: color of all the walls
wall:
min/max: rectangular bounds of the wall, as (long, long) pairs
spawns: all the spawn data (foods, mines)
period: the interval of time between spawn appearances (unsigned int)
mines: collection of mine data
mine: snake-killing mines
size: square size of the mine (unsigned short)
cushion: amount of space required around the mine for it to spawn (unsigned short)
expiry: time it takes in milliseconds for the mine to disappear (unsigned int)
foods: collection of food data
food:
rate: the odds that every spawn period, this food appears (double)
lengthFactor: a linear coefficient of the snake's growth amount (double)
points: points given for eating this food (long long)
speedChange: amount by which the food changes the snake speed (short)
pointGainPeriod: the interval of time between snake point gains/losses
pointGainAmount: how many points the player gains each pointGainPeriod (long long)
snake:
startingLength: the starting length of the snake (unsigned long)
width: the width of the snake (unsigned short)
startingSpeed: the initial frequency at which the snake moves (unsigned short)
speedupAmount: the amount by which snake speed changes, every speedupPeriod (unsigned short)
speedupPeriod: the interval of time between snake speedups (unsigned int)
growthCap: the highest amount by which the snake can grow at once, before being multiplied by the food's growth coefficient (unsigned long)
growthRate: a linear coefficient of the snake's growth amount (double)