#include "Game.h" #include "rendering/Renderer.h" #include "rendering/wrapper/GLFW.h" #include "utils/String.h" float x = 0.0f; float y = 0.0f; float lastX = 0.0f; float lastY = 0.0f; float playerWidth = 80.0f; float playerHeight = 80.0f; float width = 800.0f; float height = 480.0f; float motionY = 0.0f; bool onGround = false; Game::Game(const Controller& c, const Clock& fps, const Clock& tps) : controller(c), fps(fps), tps(tps) { } void Game::tick() { /*lastX = x; lastY = y; if(controller.isDown(Button::LEFT)) { x -= 7; } if(controller.isDown(Button::RIGHT)) { x += 7; } if(controller.isDown(Button::A) && onGround) { motionY = -15.0f; onGround = false; } motionY += 0.5f; y += motionY; if(y > height - playerHeight) { y = height - playerHeight; motionY = 0.0f; onGround = true; } while(x > width) { x -= width + playerWidth; lastX -= width + playerWidth; } while(x < -playerWidth) { x += width + playerWidth; lastX += width + playerWidth; }*/ } void Game::render(float lag, Renderer& renderer) const { renderer.translateTo(0.0f, 0.0f).update(); renderer.drawRectangle(lastX + (x - lastX) * lag, lastY + (y - lastY) * lag, playerWidth, playerHeight, 0xFF0000FF); renderer.translateTo(0.0f, 0.0f).scale(4).update(); String s("A"); s.append(": ").append(controller.getDownTime(0)).append(" "); renderer.drawString(0, 10, s); } bool Game::isRunning() const { return true;//!controller.isDown(Button::SELECT); }