Start trying own game

This commit is contained in:
2025-10-12 19:40:12 +02:00
parent 0a83eb3c10
commit 860d8febe6
8 changed files with 398 additions and 0 deletions

47
Capter1/Game.h Normal file
View File

@@ -0,0 +1,47 @@
#pragma once
#include "SDL2/SDL.h"
// Vector2 struct just stores x/y coordinates
// (for now)
struct Vector2
{
float x;
float y;
};
// Game class
class Game
{
public:
Game();
// Initialize the game
bool Initialize();
// Runs the game loop until the game is over
void RunLoop();
// Shutdown the game
void Shutdown();
private:
// Helper functions for the game loop
void ProcessInput();
void UpdateGame();
void GenerateOutput();
// Window created by SDL
SDL_Window* mWindow;
// Renderer for 2D drawing
SDL_Renderer* mRenderer;
// Number of ticks since start of game
Uint32 mTicksCount;
// Game should continue to run
bool mIsRunning;
// Pong specific
// Direction of paddle
int mPaddleDir;
// Position of paddle
Vector2 mPaddlePos;
// Position of ball
Vector2 mBallPos;
// Velocity of ball
Vector2 mBallVel;
};