6#define EXTERNC extern "C"
16#include "machineDependent.h"
33#define LIGHT_YELLOW 10
35#define LIGHT_PURPLE 12
39#define CHARACTER_WIDTH 6
40#define CHARACTER_HEIGHT 6
42#define SOUND_EFFECT_TYPE_COUNT 9
53#define TEXT_PATTERN_COUNT 94
54#define MAX_CHARACTER_PATTERN_COUNT 26
55#define ASCII_CHARACTER_COUNT 127
56#define MAX_CACHED_CHARACTER_PATTERN_COUNT 128
59#define M_PI 3.14159265358979323846
65 bool text[ASCII_CHARACTER_COUNT];
118EXTERNC
Collision box(
float x,
float y,
float w,
float h);
119EXTERNC
Collision line(
float x1,
float y1,
float x2,
float y2);
120EXTERNC
Collision bar(
float x,
float y,
float length,
float angle);
121EXTERNC
Collision arc(
float centerX,
float centerY,
float radius,
122 float angleFrom,
float angleTo);
125EXTERNC
void play(
int type);
126EXTERNC
void addScore(
float value,
float x,
float y);
127EXTERNC
float rnd(
float high,
float low);
128EXTERNC
int rndi(
int high,
int low);
130EXTERNC
void particle(
float x,
float y,
float count,
float speed,
float angle,
133EXTERNC
float clamp(
float v,
float low,
float high);
134EXTERNC
float wrap(
float v,
float low,
float high);
149EXTERNC
int currentColorIndex;
150EXTERNC ColorRgb colorRgbs[COLOR_COUNT];
151EXTERNC
int getHashFromString(
char *str);
154EXTERNC
void setButtonState(
bool left,
bool right,
bool up,
bool down,
bool b,
160#define FOR_EACH(array, index) \
161 for (int index = 0; index < sizeof(array) / sizeof(array[0]); index++)
163#define ASSIGN_ARRAY_ITEM(array, index, type, item) type *item = &array[index]
165#define SKIP_IS_NOT_ALIVE(item) \
166 if (!item->isAlive) continue
168#define TIMES(count, index) for (int index = 0; index < count; index++)
171#define COUNT_IS_ALIVE(array, counter) \
174 for (int i = 0; i < sizeof(array) / sizeof(array[0]); i++) { \
175 if (array[i].isAlive) { \
181#define INIT_UNALIVED_ARRAY(array) \
183 for (int i = 0; i < sizeof(array) / sizeof(array[0]); i++) { \
184 array[i].isAlive = false; \
188#define RNDPM() (rndi(0, 2) * 2 - 1)
EMSCRIPTEN_KEEPALIVE void updateFrame()
Definition: cglp.c:1016
void gameOver()
Transit to the game-over state.
Definition: cglp.c:951
Collision line(float x1, float y1, float x2, float y2)
Draw a line. Returns information on objects that collided while drawing.
Definition: cglp.c:225
Input currentInput
Input state (used to get input on title screen) (readonly).
Definition: cglp.c:56
int color
Definition: cglp.c:40
void particle(float x, float y, float count, float speed, float angle, float angleWidth)
Add particles.
Definition: cglp.c:624
EMSCRIPTEN_KEEPALIVE void initGame()
Definition: cglp.c:1002
float tempo
Tempo of background music.
Definition: cglp.c:52
float difficulty
Definition: cglp.c:34
int rndi(int low, int high)
Get a random int value of [low, high - 1].
Definition: cglp.c:746
float clamp(float v, float low, float high)
Clamp a value to [low, high].
Definition: cglp.c:759
float barCenterPosRatio
Definition: cglp.c:45
float wrap(float v, float low, float high)
Wrap a value to [low, high).
Definition: cglp.c:762
void play(int type)
Definition: cglp.c:529
bool isInMenu
Set to true when the menu screen is open (readonly).
Definition: cglp.c:58
CharacterOptions characterOptions
Options for drawing text() and character().
Definition: cglp.c:47
void consoleLog(char *format,...)
Definition: cglp.c:750
void addScore(float value, float x, float y)
Definition: cglp.c:591
void disableSound()
Disable playing background music and sound effects.
Definition: cglp.c:535
float score
Game score.
Definition: cglp.c:31
int ticks
A variable incremented by one every 1/60 of a second (readonly).
Definition: cglp.c:29
void enableSound()
Enable playing background music and sound effects.
Definition: cglp.c:532
void toggleSound()
Toggle sound playing flag.
Definition: cglp.c:541
float thickness
Set the thickness for drawing line(), bar() and arc().
Definition: cglp.c:42
Collision bar(float x, float y, float length, float angle)
Draw a bar. Returns information on objects that collided while drawing.
Definition: cglp.c:235
Collision box(float x, float y, float w, float h)
Draw a box. Returns information on objects that collided while drawing.
Definition: cglp.c:190
char * intToChar(int v)
Convert a value of type int to a value of type char*.
Definition: cglp.c:779
float rnd(float low, float high)
Get a random float value of [low, high).
Definition: cglp.c:743
Collision arc(float centerX, float centerY, float radius, float angleFrom, float angleTo)
Draw a arc. Returns information on objects that collided while drawing.
Definition: cglp.c:249
Input input
Input state from the buttons (readonly).
Definition: cglp.c:54
Collision rect(float x, float y, float w, float h)
Definition: cglp.c:180
EMSCRIPTEN_KEEPALIVE void setButtonState(bool left, bool right, bool up, bool down, bool b, bool a)
Definition: cglp.c:670
bool hasCollision
Definition: cglp.c:50
Collision character(char *msg, float x, float y)
Definition: cglp.c:451
void restartGame(int gameIndex)
Restart another game specified by gameIndex.
Definition: cglp.c:992
Collision text(char *msg, float x, float y)
Draw a text. Returns information on objects that collided while drawing.
Definition: cglp.c:444
void goToMenu()
Go to the game selection menu screen.
Definition: cglp.c:983
ButtonState right
Definition: cglp.h:81
bool isPressed
Definition: cglp.h:86
ButtonState left
Definition: cglp.h:80
bool isDarkColor
Definition: cglp.h:95
Collisions isColliding
Definition: cglp.h:70
ButtonState up
Definition: cglp.h:82
bool isJustPressed
Definition: cglp.h:75
int viewSizeY
Definition: cglp.h:93
int viewSizeX
Definition: cglp.h:92
ButtonState down
Definition: cglp.h:83
ButtonState a
Definition: cglp.h:85
bool isJustReleased
Definition: cglp.h:88
int soundSeed
Definition: cglp.h:94
bool isJustReleased
Definition: cglp.h:76
bool isMirrorX
Definition: cglp.h:99
bool isPressed
Definition: cglp.h:74
int rotation
Definition: cglp.h:101
ButtonState b
Definition: cglp.h:84
bool isJustPressed
Definition: cglp.h:87
bool isMirrorY
Definition: cglp.h:100
float angleTo(Vector *vec, float x, float y)
Definition: vector.c:36