From 4b59b44db6d4ba3ec1c1b1cc399d6d6499e249ac Mon Sep 17 00:00:00 2001 From: Luka Burjanadze Date: Sun, 11 Jan 2026 17:41:00 +0400 Subject: [PATCH 01/13] changed project settings --- Engine/Engine.vcxproj | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Engine/Engine.vcxproj b/Engine/Engine.vcxproj index c6e66c51..d3c55c52 100644 --- a/Engine/Engine.vcxproj +++ b/Engine/Engine.vcxproj @@ -21,32 +21,32 @@ {FFCA512B-49FC-4FC8-8A73-C4F87D322FF2} Engine - 8.1 + 10.0 Application true - v140 + v143 Unicode Application false - v140 + v143 true Unicode Application true - v140 + v143 Unicode Application false - v140 + v143 true Unicode From fd483c55b85b170668f7b253f646df57d4fdf93c Mon Sep 17 00:00:00 2001 From: Luka Burjanadze Date: Wed, 14 Jan 2026 22:16:37 +0400 Subject: [PATCH 02/13] added drawrect funcion --- Engine/Graphics.cpp | 11 +++++++++++ Engine/Graphics.h | 1 + 2 files changed, 12 insertions(+) diff --git a/Engine/Graphics.cpp b/Engine/Graphics.cpp index bdff4ebf..59dba460 100644 --- a/Engine/Graphics.cpp +++ b/Engine/Graphics.cpp @@ -316,6 +316,17 @@ void Graphics::PutPixel( int x,int y,Color c ) pSysBuffer[Graphics::ScreenWidth * y + x] = c; } +void Graphics::DrawRectDim(int x, int y, int width, int height, Color c) +{ + for (int y0 = y; y0 < y + height; y0++) + { + for (int x0 = x; x0 < x + width; x0++) + { + PutPixel(x0, y0, c); + } + } +} + ////////////////////////////////////////////////// // Graphics Exception diff --git a/Engine/Graphics.h b/Engine/Graphics.h index 9a44e3fe..b3860d57 100644 --- a/Engine/Graphics.h +++ b/Engine/Graphics.h @@ -57,6 +57,7 @@ class Graphics PutPixel( x,y,{ unsigned char( r ),unsigned char( g ),unsigned char( b ) } ); } void PutPixel( int x,int y,Color c ); + void DrawRectDim(int x, int y, int width, int height, Color c); ~Graphics(); private: Microsoft::WRL::ComPtr pSwapChain; From dfa43f146fdb094f29669cd24b72ef348089b3c3 Mon Sep 17 00:00:00 2001 From: Luka Burjanadze Date: Thu, 15 Jan 2026 00:21:36 +0400 Subject: [PATCH 03/13] added board --- Engine/Board.cpp | 14 ++++++++++++++ Engine/Board.h | 17 +++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 Engine/Board.cpp create mode 100644 Engine/Board.h diff --git a/Engine/Board.cpp b/Engine/Board.cpp new file mode 100644 index 00000000..c57000fe --- /dev/null +++ b/Engine/Board.cpp @@ -0,0 +1,14 @@ +#include "Board.h" + +Board::Board(int in_width, int in_height, Color in_color) + : + width(in_width), + height(in_height), + c(in_color) +{ +} + +void Board::DrawCell(const Vei2& gridPos, Graphics& gfx) +{ + gfx.DrawRectDim(gridPos * cellSize, cellSize, cellSize, c); +} \ No newline at end of file diff --git a/Engine/Board.h b/Engine/Board.h new file mode 100644 index 00000000..da13aa06 --- /dev/null +++ b/Engine/Board.h @@ -0,0 +1,17 @@ +#pragma once + +#include "Graphics.h" +#include "Colors.h" +#include "Vei2.h" + +class Board +{ +public: + Board(int in_width, int in_height, Color in_color); + void DrawCell(const Vei2& gridPos, Graphics& gfx); +private: + Color c; + static constexpr int cellSize = 15; + int width; + int height; +}; \ No newline at end of file From dc23da1a6370eeeb8fafbc6fed83ef4ecd06eaca Mon Sep 17 00:00:00 2001 From: Luka Burjanadze Date: Thu, 15 Jan 2026 00:22:14 +0400 Subject: [PATCH 04/13] changed DrawRectDim to use Vector --- Engine/Graphics.cpp | 6 +++--- Engine/Graphics.h | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Engine/Graphics.cpp b/Engine/Graphics.cpp index 59dba460..7d8421ce 100644 --- a/Engine/Graphics.cpp +++ b/Engine/Graphics.cpp @@ -316,11 +316,11 @@ void Graphics::PutPixel( int x,int y,Color c ) pSysBuffer[Graphics::ScreenWidth * y + x] = c; } -void Graphics::DrawRectDim(int x, int y, int width, int height, Color c) +void Graphics::DrawRectDim(Vei2 pos, int width, int height, Color c) { - for (int y0 = y; y0 < y + height; y0++) + for (int y0 = pos.y; y0 < pos.y + height; y0++) { - for (int x0 = x; x0 < x + width; x0++) + for (int x0 = pos.x; x0 < pos.x + width; x0++) { PutPixel(x0, y0, c); } diff --git a/Engine/Graphics.h b/Engine/Graphics.h index b3860d57..7818ab23 100644 --- a/Engine/Graphics.h +++ b/Engine/Graphics.h @@ -24,6 +24,7 @@ #include #include "ChiliException.h" #include "Colors.h" +#include "Vei2.h" class Graphics { @@ -57,7 +58,7 @@ class Graphics PutPixel( x,y,{ unsigned char( r ),unsigned char( g ),unsigned char( b ) } ); } void PutPixel( int x,int y,Color c ); - void DrawRectDim(int x, int y, int width, int height, Color c); + void DrawRectDim(Vei2 pos, int width, int height, Color c); ~Graphics(); private: Microsoft::WRL::ComPtr pSwapChain; From afabb11e073e56f3227f6b8f1972ff7914de5e05 Mon Sep 17 00:00:00 2001 From: Luka Burjanadze Date: Thu, 15 Jan 2026 00:22:33 +0400 Subject: [PATCH 05/13] added vector --- Engine/Vei2.cpp | 13 +++++++++++++ Engine/Vei2.h | 11 +++++++++++ 2 files changed, 24 insertions(+) create mode 100644 Engine/Vei2.cpp create mode 100644 Engine/Vei2.h diff --git a/Engine/Vei2.cpp b/Engine/Vei2.cpp new file mode 100644 index 00000000..165b7e11 --- /dev/null +++ b/Engine/Vei2.cpp @@ -0,0 +1,13 @@ +#include "Vei2.h" + +Vei2::Vei2(int x, int y) + : + x(x), + y(y) +{ +} + +const Vei2 Vei2::operator*(int val) const +{ + return Vei2(x * val, y * val); +} \ No newline at end of file diff --git a/Engine/Vei2.h b/Engine/Vei2.h new file mode 100644 index 00000000..918c0a17 --- /dev/null +++ b/Engine/Vei2.h @@ -0,0 +1,11 @@ +#pragma once + +class Vei2 +{ +public: + Vei2(int x, int y); + const Vei2 operator * (int val) const; +public: + int x; + int y; +}; \ No newline at end of file From 8205375871cd2360422d598094ab5161bce753cd Mon Sep 17 00:00:00 2001 From: Luka Burjanadze Date: Thu, 15 Jan 2026 00:22:58 +0400 Subject: [PATCH 06/13] tested drawing cell --- Engine/Engine.vcxproj | 4 ++++ Engine/Engine.vcxproj.filters | 12 ++++++++++++ Engine/Game.cpp | 4 +++- Engine/Game.h | 7 ++++--- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Engine/Engine.vcxproj b/Engine/Engine.vcxproj index d3c55c52..2ad36fd1 100644 --- a/Engine/Engine.vcxproj +++ b/Engine/Engine.vcxproj @@ -136,6 +136,7 @@ + @@ -149,8 +150,10 @@ + + @@ -160,6 +163,7 @@ + diff --git a/Engine/Engine.vcxproj.filters b/Engine/Engine.vcxproj.filters index 2026aaba..5669ba62 100644 --- a/Engine/Engine.vcxproj.filters +++ b/Engine/Engine.vcxproj.filters @@ -57,6 +57,12 @@ Header Files + + Header Files + + + Header Files + @@ -86,6 +92,12 @@ Source Files + + Source Files + + + Source Files + diff --git a/Engine/Game.cpp b/Engine/Game.cpp index dbdb5218..7f0862d9 100644 --- a/Engine/Game.cpp +++ b/Engine/Game.cpp @@ -24,7 +24,8 @@ Game::Game( MainWindow& wnd ) : wnd( wnd ), - gfx( wnd ) + gfx( wnd ), + brd(20, 20, Colors::Magenta) { } @@ -42,4 +43,5 @@ void Game::UpdateModel() void Game::ComposeFrame() { + brd.DrawCell(pos, gfx); } diff --git a/Engine/Game.h b/Engine/Game.h index 1702e223..1527315c 100644 --- a/Engine/Game.h +++ b/Engine/Game.h @@ -23,6 +23,8 @@ #include "Keyboard.h" #include "Mouse.h" #include "Graphics.h" +#include "Board.h" +#include "Vei2.h" class Game { @@ -40,7 +42,6 @@ class Game private: MainWindow& wnd; Graphics gfx; - /********************************/ - /* User Variables */ - /********************************/ + Board brd; + Vei2 pos = { 2, 4 }; }; \ No newline at end of file From f7f5f6d64d9790b842de44d6768cb5057aff32f0 Mon Sep 17 00:00:00 2001 From: Luka Burjanadze Date: Thu, 15 Jan 2026 00:49:43 +0400 Subject: [PATCH 07/13] deleted color from constructor and instead added it in DrawCell function --- Engine/Board.cpp | 7 +++---- Engine/Board.h | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Engine/Board.cpp b/Engine/Board.cpp index c57000fe..9b69a8c0 100644 --- a/Engine/Board.cpp +++ b/Engine/Board.cpp @@ -1,14 +1,13 @@ #include "Board.h" -Board::Board(int in_width, int in_height, Color in_color) +Board::Board(int in_width, int in_height) : width(in_width), - height(in_height), - c(in_color) + height(in_height) { } -void Board::DrawCell(const Vei2& gridPos, Graphics& gfx) +void Board::DrawCell(const Vei2& gridPos, Graphics& gfx, Color c) { gfx.DrawRectDim(gridPos * cellSize, cellSize, cellSize, c); } \ No newline at end of file diff --git a/Engine/Board.h b/Engine/Board.h index da13aa06..a62ee1c6 100644 --- a/Engine/Board.h +++ b/Engine/Board.h @@ -1,14 +1,14 @@ #pragma once #include "Graphics.h" -#include "Colors.h" #include "Vei2.h" +#include "Colors.h" class Board { public: - Board(int in_width, int in_height, Color in_color); - void DrawCell(const Vei2& gridPos, Graphics& gfx); + Board(int in_width, int in_height); + void DrawCell(const Vei2& gridPos, Graphics& gfx, Color c); private: Color c; static constexpr int cellSize = 15; From f5edd7c86afd9d4db3a765ecbd6a3701fc02c1f6 Mon Sep 17 00:00:00 2001 From: Luka Burjanadze Date: Thu, 15 Jan 2026 00:50:00 +0400 Subject: [PATCH 08/13] added default constructor --- Engine/Vei2.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Engine/Vei2.h b/Engine/Vei2.h index 918c0a17..d4909c1e 100644 --- a/Engine/Vei2.h +++ b/Engine/Vei2.h @@ -3,6 +3,7 @@ class Vei2 { public: + Vei2() = default; Vei2(int x, int y); const Vei2 operator * (int val) const; public: From a61191b022ff8b7cb5194af8990740ed867e39e9 Mon Sep 17 00:00:00 2001 From: Luka Burjanadze Date: Thu, 15 Jan 2026 00:50:24 +0400 Subject: [PATCH 09/13] tested player drawing --- Engine/Game.cpp | 7 ++++--- Engine/Game.h | 6 ++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Engine/Game.cpp b/Engine/Game.cpp index 7f0862d9..4b3fc24b 100644 --- a/Engine/Game.cpp +++ b/Engine/Game.cpp @@ -25,7 +25,8 @@ Game::Game( MainWindow& wnd ) : wnd( wnd ), gfx( wnd ), - brd(20, 20, Colors::Magenta) + brd(20, 20), + player({2, 1}) { } @@ -43,5 +44,5 @@ void Game::UpdateModel() void Game::ComposeFrame() { - brd.DrawCell(pos, gfx); -} + player.Draw(brd, gfx, Colors::Green); +} \ No newline at end of file diff --git a/Engine/Game.h b/Engine/Game.h index 1527315c..98452df4 100644 --- a/Engine/Game.h +++ b/Engine/Game.h @@ -25,6 +25,7 @@ #include "Graphics.h" #include "Board.h" #include "Vei2.h" +#include "Player.h" class Game { @@ -36,12 +37,9 @@ class Game private: void ComposeFrame(); void UpdateModel(); - /********************************/ - /* User Functions */ - /********************************/ private: MainWindow& wnd; Graphics gfx; Board brd; - Vei2 pos = { 2, 4 }; + Player player; }; \ No newline at end of file From 9e8cb8af6bc87e61c9f8057ad50e9e436d14ce23 Mon Sep 17 00:00:00 2001 From: Luka Burjanadze Date: Thu, 15 Jan 2026 01:13:25 +0400 Subject: [PATCH 10/13] added player --- Engine/Player.cpp | 16 ++++++++++++++++ Engine/Player.h | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 Engine/Player.cpp create mode 100644 Engine/Player.h diff --git a/Engine/Player.cpp b/Engine/Player.cpp new file mode 100644 index 00000000..d0916d38 --- /dev/null +++ b/Engine/Player.cpp @@ -0,0 +1,16 @@ +#include "Player.h" + +Player::Player(const Vei2& in_pos) +{ + pos = in_pos; +} + +void Player::Draw(Board& brd, Graphics& gfx, Color c) const +{ + brd.DrawCell(pos, gfx, c); +} + +void Player::MoveBy(const Vei2& delta_loc) +{ + pos += delta_loc; +} \ No newline at end of file diff --git a/Engine/Player.h b/Engine/Player.h new file mode 100644 index 00000000..31682e2c --- /dev/null +++ b/Engine/Player.h @@ -0,0 +1,16 @@ +#pragma once + +#include "Vei2.h" +#include "Board.h" +#include "Colors.h" + +class Player +{ +public: + Player(const Vei2& in_pos); + void Draw(Board& brd, Graphics& gfx, Color c) const; + void MoveBy(const Vei2& delta_loc); +private: + Vei2 pos; + Color c; +}; \ No newline at end of file From 9f6707d3798a8b8f889a5a040fccd36a4f74526d Mon Sep 17 00:00:00 2001 From: Luka Burjanadze Date: Thu, 15 Jan 2026 01:13:54 +0400 Subject: [PATCH 11/13] added addition operator overloading for Vei2 class --- Engine/Vei2.cpp | 7 +++++++ Engine/Vei2.h | 1 + 2 files changed, 8 insertions(+) diff --git a/Engine/Vei2.cpp b/Engine/Vei2.cpp index 165b7e11..965b6184 100644 --- a/Engine/Vei2.cpp +++ b/Engine/Vei2.cpp @@ -7,6 +7,13 @@ Vei2::Vei2(int x, int y) { } +Vei2& Vei2::operator+=(const Vei2& rhs) +{ + x += rhs.x; + y += rhs.y; + return *this; +} + const Vei2 Vei2::operator*(int val) const { return Vei2(x * val, y * val); diff --git a/Engine/Vei2.h b/Engine/Vei2.h index d4909c1e..36d73c58 100644 --- a/Engine/Vei2.h +++ b/Engine/Vei2.h @@ -5,6 +5,7 @@ class Vei2 public: Vei2() = default; Vei2(int x, int y); + Vei2& operator += (const Vei2& rhs); const Vei2 operator * (int val) const; public: int x; From 1f0c6578f9a004a2af2387ec1bb91e8d795d8552 Mon Sep 17 00:00:00 2001 From: Luka Burjanadze Date: Thu, 15 Jan 2026 01:14:11 +0400 Subject: [PATCH 12/13] added player movement --- Engine/Engine.vcxproj | 2 ++ Engine/Engine.vcxproj.filters | 6 ++++++ Engine/Game.cpp | 24 ++++++++++++++++++++++++ Engine/Game.h | 5 +++++ 4 files changed, 37 insertions(+) diff --git a/Engine/Engine.vcxproj b/Engine/Engine.vcxproj index 2ad36fd1..f1dfa506 100644 --- a/Engine/Engine.vcxproj +++ b/Engine/Engine.vcxproj @@ -147,6 +147,7 @@ + @@ -162,6 +163,7 @@ + diff --git a/Engine/Engine.vcxproj.filters b/Engine/Engine.vcxproj.filters index 5669ba62..8ceaf89c 100644 --- a/Engine/Engine.vcxproj.filters +++ b/Engine/Engine.vcxproj.filters @@ -63,6 +63,9 @@ Header Files + + Header Files + @@ -98,6 +101,9 @@ Source Files + + Source Files + diff --git a/Engine/Game.cpp b/Engine/Game.cpp index 4b3fc24b..fe61de65 100644 --- a/Engine/Game.cpp +++ b/Engine/Game.cpp @@ -40,6 +40,30 @@ void Game::Go() void Game::UpdateModel() { + if (wnd.kbd.KeyIsPressed(VK_RIGHT) && !rightPressed) + { + rightPressed = true; + playerDelta_Loc = { 1, 0 }; + player.MoveBy(playerDelta_Loc); + } + if (wnd.kbd.KeyIsPressed(VK_LEFT) && !leftPressed) + { + leftPressed = true; + playerDelta_Loc = { -1, 0 }; + player.MoveBy(playerDelta_Loc); + } + if (wnd.kbd.KeyIsPressed(VK_DOWN) && !downPressed) + { + downPressed = true; + playerDelta_Loc = { 0, 1 }; + player.MoveBy(playerDelta_Loc); + } + if (wnd.kbd.KeyIsPressed(VK_UP) && !upPressed) + { + upPressed = true; + playerDelta_Loc = { 0, -1 }; + player.MoveBy(playerDelta_Loc); + } } void Game::ComposeFrame() diff --git a/Engine/Game.h b/Engine/Game.h index 98452df4..3ab397a0 100644 --- a/Engine/Game.h +++ b/Engine/Game.h @@ -42,4 +42,9 @@ class Game Graphics gfx; Board brd; Player player; + Vei2 playerDelta_Loc = { 0, 0 }; + bool rightPressed = false; + bool leftPressed = false; + bool upPressed = false; + bool downPressed = false; }; \ No newline at end of file From 05ce3d0777a1d0f21d7ce39c41da92d8f5d7863f Mon Sep 17 00:00:00 2001 From: Luka Burjanadze Date: Thu, 15 Jan 2026 02:10:25 +0400 Subject: [PATCH 13/13] added FrameTimer --- Engine/FrameTimer.cpp | 14 ++++++++++++++ Engine/FrameTimer.h | 12 ++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 Engine/FrameTimer.cpp create mode 100644 Engine/FrameTimer.h diff --git a/Engine/FrameTimer.cpp b/Engine/FrameTimer.cpp new file mode 100644 index 00000000..3538f006 --- /dev/null +++ b/Engine/FrameTimer.cpp @@ -0,0 +1,14 @@ +#include "FrameTimer.h" + +FrameTimer::FrameTimer() +{ + last = std::chrono::steady_clock::now(); +} + +float FrameTimer::GetDeltaTime() +{ + std::chrono::steady_clock::time_point current = std::chrono::steady_clock::now(); + std::chrono::duration deltaTime = current - last; + last = current; + return deltaTime.count(); +} \ No newline at end of file diff --git a/Engine/FrameTimer.h b/Engine/FrameTimer.h new file mode 100644 index 00000000..7ef79edb --- /dev/null +++ b/Engine/FrameTimer.h @@ -0,0 +1,12 @@ +#pragma once + +#include + +class FrameTimer +{ +public: + FrameTimer(); + float GetDeltaTime(); +private: + std::chrono::steady_clock::time_point last; +}; \ No newline at end of file