1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-01 18:43:33 +02:00
VVVVVV/desktop_version/src/BlockV.cpp
Misa 6a3a1fe147
Explicitly declare void for all void parameter functions (#628)
Apparently in C, if you have `void test();`, it's completely okay to do
`test(2);`. The function will take in the argument, but just discard it
and throw it away. It's like a trash can, and a rude one at that. If you
declare it like `void test(void);`, this is prevented.

This is not a problem in C++ - doing `void test();` and `test(2);` is
guaranteed to result in a compile error (this also means that right now,
at least in all `.cpp` files, nobody is ever calling a void parameter
function with arguments and having their arguments be thrown away).
However, we may not be using C++ in the future, so I just want to lay
down the precedent that if a function takes in no arguments, you must
explicitly declare it as such.

I would've added `-Wstrict-prototypes`, but it produces an annoying
warning message saying it doesn't work in C++ mode if you're compiling
in C++ mode. So it can be added later.
2021-02-25 17:23:59 -05:00

107 lines
1.2 KiB
C++

#include "BlockV.h"
blockclass::blockclass(void)
{
clear();
}
void blockclass::clear(void)
{
type = 0;
trigger = 0;
xp = 0;
yp = 0;
wp = 0;
hp = 0;
rect.x = xp;
rect.y = yp;
rect.w = wp;
rect.h = hp;
r = 0;
g = 0;
b = 0;
x = 0.0f;
y = 0.0f;
/* std::strings get initialized automatically, but this is */
/* in case this function gets called again after construction */
script.clear();
prompt.clear();
}
void blockclass::rectset(const int xi, const int yi, const int wi, const int hi)
{
rect.x = xi;
rect.y = yi;
rect.w = wi;
rect.h = hi;
}
void blockclass::setblockcolour( std::string col )
{
if (col == "cyan")
{
r = 164;
g = 164;
b = 255;
}
else if (col == "red")
{
r = 255;
g = 60;
b = 60;
}
else if (col == "green")
{
r = 144;
g = 255;
b = 144;
}
else if (col == "yellow")
{
r = 255;
g = 255;
b = 134;
}
else if (col == "blue")
{
r = 95;
g = 95;
b = 255;
}
else if (col == "purple")
{
r = 255;
g = 134;
b = 255;
}
else if (col == "white")
{
r = 244;
g = 244;
b = 244;
}
else if (col == "gray")
{
r = 174;
g = 174;
b = 174;
}
else if (col == "orange")
{
r = 255;
g = 130;
b = 20;
}
else
{
//use a gray
r = 174;
g = 174;
b = 174;
}
}