Trivial style fixes
This commit is contained in:
@@ -53,10 +53,10 @@ glm::vec3 ballDirection(1, 1, 0.2f);
|
||||
|
||||
CommandLineOptions options;
|
||||
|
||||
bool hasStarted = false;
|
||||
bool hasLost = false;
|
||||
bool hasStarted = false;
|
||||
bool hasLost = false;
|
||||
bool jumpedToNextFrame = false;
|
||||
bool isPaused = false;
|
||||
bool isPaused = false;
|
||||
|
||||
bool mouseLeftPressed = false;
|
||||
bool mouseLeftReleased = false;
|
||||
@@ -131,14 +131,14 @@ void initGame(GLFWwindow* window, CommandLineOptions gameOptions) {
|
||||
rootNode->children.push_back(padNode);
|
||||
rootNode->children.push_back(ballNode);
|
||||
|
||||
boxNode->vertexArrayObjectID = boxVAO;
|
||||
boxNode->VAOIndexCount = box.indices.size();
|
||||
boxNode->vertexArrayObjectID = boxVAO;
|
||||
boxNode->VAOIndexCount = box.indices.size();
|
||||
|
||||
padNode->vertexArrayObjectID = padVAO;
|
||||
padNode->VAOIndexCount = pad.indices.size();
|
||||
padNode->vertexArrayObjectID = padVAO;
|
||||
padNode->VAOIndexCount = pad.indices.size();
|
||||
|
||||
ballNode->vertexArrayObjectID = ballVAO;
|
||||
ballNode->VAOIndexCount = sphere.indices.size();
|
||||
ballNode->VAOIndexCount = sphere.indices.size();
|
||||
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ void updateFrame(GLFWwindow* window) {
|
||||
mouseRightReleased = mouseRightPressed;
|
||||
mouseRightPressed = false;
|
||||
}
|
||||
|
||||
|
||||
if(!hasStarted) {
|
||||
if (mouseLeftPressed) {
|
||||
if (options.enableMusic) {
|
||||
@@ -296,7 +296,8 @@ void updateFrame(GLFWwindow* window) {
|
||||
if ( ballPosition.x < padLeftX
|
||||
|| ballPosition.x > padRightX
|
||||
|| ballPosition.z < padFrontZ
|
||||
|| ballPosition.z > padBackZ) {
|
||||
|| ballPosition.z > padBackZ
|
||||
) {
|
||||
hasLost = true;
|
||||
if (options.enableMusic) {
|
||||
sound->stop();
|
||||
@@ -313,7 +314,7 @@ void updateFrame(GLFWwindow* window) {
|
||||
|
||||
// Some math to make the camera move in a nice way
|
||||
float lookRotation = -0.6 / (1 + exp(-5 * (padPositionX-0.5))) + 0.3;
|
||||
glm::mat4 cameraTransform =
|
||||
glm::mat4 cameraTransform =
|
||||
glm::rotate(0.3f + 0.2f * float(-padPositionZ*padPositionZ), glm::vec3(1, 0, 0)) *
|
||||
glm::rotate(lookRotation, glm::vec3(0, 1, 0)) *
|
||||
glm::translate(-cameraPosition);
|
||||
@@ -327,9 +328,9 @@ void updateFrame(GLFWwindow* window) {
|
||||
ballNode->scale = glm::vec3(ballRadius);
|
||||
ballNode->rotation = { 0, totalElapsedTime*2, 0 };
|
||||
|
||||
padNode->position = {
|
||||
boxNode->position.x - (boxDimensions.x/2) + (padDimensions.x/2) + (1 - padPositionX) * (boxDimensions.x - padDimensions.x),
|
||||
boxNode->position.y - (boxDimensions.y/2) + (padDimensions.y/2),
|
||||
padNode->position = {
|
||||
boxNode->position.x - (boxDimensions.x/2) + (padDimensions.x/2) + (1 - padPositionX) * (boxDimensions.x - padDimensions.x),
|
||||
boxNode->position.y - (boxDimensions.y/2) + (padDimensions.y/2),
|
||||
boxNode->position.z - (boxDimensions.z/2) + (padDimensions.z/2) + (1 - padPositionZ) * (boxDimensions.z - padDimensions.z)
|
||||
};
|
||||
|
||||
|
||||
12
src/main.cpp
12
src/main.cpp
@@ -40,11 +40,7 @@ GLFWwindow* initialise()
|
||||
glfwWindowHint(GLFW_SAMPLES, windowSamples); // MSAA
|
||||
|
||||
// Create window using GLFW
|
||||
GLFWwindow* window = glfwCreateWindow(windowWidth,
|
||||
windowHeight,
|
||||
windowTitle.c_str(),
|
||||
nullptr,
|
||||
nullptr);
|
||||
GLFWwindow* window = glfwCreateWindow(windowWidth, windowHeight, windowTitle.c_str(), nullptr, nullptr);
|
||||
|
||||
// Ensure the window is set up correctly
|
||||
if (!window)
|
||||
@@ -71,8 +67,8 @@ GLFWwindow* initialise()
|
||||
int main(int argc, const char* argb[])
|
||||
{
|
||||
arrrgh::parser parser("glowbox", "Small breakout like juggling game");
|
||||
const auto& showHelp = parser.add<bool>("help", "Show this help message.", 'h', arrrgh::Optional, false);
|
||||
const auto& enableMusic = parser.add<bool>("enable-music", "Play background music while the game is playing", 'm', arrrgh::Optional, false);
|
||||
const auto& showHelp = parser.add<bool>("help", "Show this help message.", 'h', arrrgh::Optional, false);
|
||||
const auto& enableMusic = parser.add<bool>("enable-music", "Play background music while the game is playing", 'm', arrrgh::Optional, false);
|
||||
const auto& enableAutoplay = parser.add<bool>("autoplay", "Let the game play itself automatically. Useful for testing.", 'a', arrrgh::Optional, false);
|
||||
|
||||
// If you want to add more program arguments, define them here,
|
||||
@@ -96,7 +92,7 @@ int main(int argc, const char* argb[])
|
||||
}
|
||||
|
||||
CommandLineOptions options;
|
||||
options.enableMusic = enableMusic.value();
|
||||
options.enableMusic = enableMusic.value();
|
||||
options.enableAutoplay = enableAutoplay.value();
|
||||
|
||||
// Initialise window using GLFW
|
||||
|
||||
@@ -5,8 +5,9 @@
|
||||
#include <string>
|
||||
|
||||
typedef struct PNGImage {
|
||||
unsigned int width, height;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
std::vector<unsigned char> pixels;
|
||||
} PNGImage;
|
||||
|
||||
PNGImage loadPNGFile(std::string fileName);
|
||||
PNGImage loadPNGFile(std::string fileName);
|
||||
|
||||
@@ -17,7 +17,9 @@ namespace Gloom
|
||||
class Shader
|
||||
{
|
||||
public:
|
||||
Shader() { mProgram = glCreateProgram(); }
|
||||
Shader() {
|
||||
mProgram = glCreateProgram();
|
||||
}
|
||||
|
||||
// Public member functions
|
||||
void activate() { glUseProgram(mProgram); }
|
||||
|
||||
Reference in New Issue
Block a user