Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sdavydouski committed Jul 28, 2017
1 parent 1c9cf12 commit c994a1e
Show file tree
Hide file tree
Showing 12 changed files with 11 additions and 27 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2016 Sergey Davydovsky
Copyright (c) 2016 - 2017 Sergey Davydovsky

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Binary file modified resources/audio/background.ogg
Binary file not shown.
Binary file modified resources/textures/particle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/AssetsLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ void AssetsLoader::loadTextures() {
96, 32, 4, GL_RGBA);
ResourceManager::Instance().createTexture("particle",
OFFSET + "resources/textures/particle.png",
500, 500, 4, GL_RGBA);
50, 50, 4, GL_RGBA);
ResourceManager::Instance().createTexture("powerUp",
OFFSET + "resources/textures/powerup.png",
16, 32, 4, GL_RGBA);
}

void AssetsLoader::loadAudioFiles() {
// https://opengameart.org/content/cyberpunk-moonlight-sonata
// https://opengameart.org/content/tower-defense-theme
AudioManager::Instance().createSource("background", OFFSET + "resources/audio/background.ogg", true);
AudioManager::Instance().createSource("bleep", OFFSET + "resources/audio/bleep.ogg", false);
AudioManager::Instance().createSource("bleepPaddle", OFFSET + "resources/audio/bleep_paddle.ogg", false);
Expand Down
7 changes: 0 additions & 7 deletions src/Window.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "Window.h"
#include "input/InputManager.h"
#include "utils/FileManager.h"
#include "AssetsLoader.h"
#include <iostream>

Window::Window(int width, int height, const std::string& title, bool isFullScreen, bool vsync)
Expand All @@ -17,12 +16,6 @@ Window::Window(int width, int height, const std::string& title, bool isFullScree
}

glfwSetInputMode(window_, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);

GLFWimage icon;
icon.width = 58;
icon.height = 58;
icon.pixels = FileManager::readImage(AssetsLoader::OFFSET + "resources/textures/ball.png", icon.width, icon.height, 4);
glfwSetWindowIcon(window_, 1, &icon);

if (!isFullScreen) {
// Center window on screen
Expand Down
9 changes: 2 additions & 7 deletions src/game/GameObject.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
#include "GameObject.h"
#include <iostream>

GameObject::GameObject(const glm::vec2& position,
const glm::vec2& size,
const glm::vec3& color,
Texture* sprite)
: position_(position), size_(size), color_(color), sprite_(sprite) {
//std::cout << "GameObject constructor" << std::endl;
}
: position_(position), size_(size), color_(color), sprite_(sprite) {}

GameObject::~GameObject() {
//std::cout << "GameObject destructor" << std::endl;
}
GameObject::~GameObject() {}

void GameObject::render(const SpriteRenderer& renderer) {
renderer.renderSprite(sprite_, position_, size_, color_);
Expand Down
2 changes: 1 addition & 1 deletion src/game/PowerUp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void PowerUp::update(float delta, Player& player, Ball& ball, PostProcessor& pos
}
}

void PowerUp::activate(Player& player, Ball& ball, PostProcessor& postProcessor, const glm::vec2 scales) {
void PowerUp::activate(Player& player, Ball& ball, PostProcessor& postProcessor, const glm::vec2& scales) {
isActivated_ = true;
isDestroyed_ = true;

Expand Down
2 changes: 1 addition & 1 deletion src/game/PowerUp.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class PowerUp: public GameObject {
~PowerUp();

void update(float delta, Player& player, Ball& ball, PostProcessor& postProcessor);
void activate(Player& player, Ball& ball, PostProcessor& postProcessor, const glm::vec2 scales);
void activate(Player& player, Ball& ball, PostProcessor& postProcessor, const glm::vec2& scales);

// getters
PowerUpType type() const { return type_; }
Expand Down
2 changes: 1 addition & 1 deletion src/graphics/Particle.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ struct Particle {
float lifespan;

Particle() : position(0.0f), velocity(0.0f), color(1.0f), lifespan(0.0f) {}
};
};
4 changes: 1 addition & 3 deletions src/graphics/Shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <iostream>
#include <string>
#include <vector>
#include <stdexcept>

Shader::Shader(ShaderType type, const std::string& path) {
auto source = FileManager::readAsText(path);
Expand Down Expand Up @@ -34,7 +33,6 @@ void Shader::checkCompilationStatus() const {
std::vector<GLchar> errorLog(static_cast<GLuint>(LOG_LENGTH));

glGetShaderInfoLog(id_, LOG_LENGTH, nullptr, &errorLog[0]);
std::cerr << &errorLog[0] << std::endl;
throw std::runtime_error("Shader compilation failed");
std::cerr << "Shader compilation failed" << std::endl << &errorLog[0] << std::endl;
}
}
4 changes: 1 addition & 3 deletions src/graphics/ShaderProgram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <glm/glm.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <iostream>
#include <stdexcept>
#include <vector>

ShaderProgram::ShaderProgram(const Shader& vertexShader, const Shader& fragmentShader) {
Expand Down Expand Up @@ -125,8 +124,7 @@ void ShaderProgram::checkLinkageStatus() const {
std::vector<GLchar> errorLog((GLuint) LOG_LENGTH);

glGetProgramInfoLog(id_, LOG_LENGTH, nullptr, &errorLog[0]);
std::cerr << &errorLog[0] << std::endl;
throw std::runtime_error("Shader program linkage failed");
std::cerr << "Shader program linkage failed" << std::endl << &errorLog[0] << std::endl;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/FileManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ unsigned char* FileManager::readImage(const std::string& path,
GLint channels,
bool flip) {
stbi_set_flip_vertically_on_load(flip);
unsigned char* image = stbi_load(path.c_str(), &width, &height, &channels, 0);
auto image = stbi_load(path.c_str(), &width, &height, &channels, 0);
if (image == nullptr) {
std::cerr << "Unable to open image file " << path << std::endl
<< "Reason: " << stbi_failure_reason() << std::endl;
Expand Down

0 comments on commit c994a1e

Please sign in to comment.