-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixced the mouse position bug for real this time
- Loading branch information
Darkyun991
committed
Jan 18, 2020
1 parent
83df623
commit 7fea97d
Showing
25 changed files
with
97 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,57 @@ | ||
#include "pch.h" | ||
#include "pch.h" | ||
#include "Utilities.h" | ||
#include "Game.h" | ||
std::pair<float, float> Empaerior::get_world_mouse_coords(const Empaerior::Camera& camera) | ||
{ | ||
//get the positions | ||
std::pair<int, int> pos; | ||
std::pair<float, float> f_pos; | ||
|
||
|
||
SDL_GetMouseState(&pos.first, &pos.second); | ||
|
||
|
||
|
||
f_pos.first = float(pos.first); | ||
f_pos.second = float(pos.second); | ||
|
||
|
||
|
||
//Scale down the positions to match the world | ||
float sx = 0; | ||
float sy = 0; | ||
SDL_RenderGetScale(Empaerior::Game::window.renderer, &sx, &sy); | ||
|
||
f_pos.first /= sx; | ||
f_pos.second /= sy; | ||
|
||
|
||
|
||
|
||
//Transform for the position of the renderer | ||
SDL_Rect renderer_viewport; | ||
|
||
SDL_RenderGetViewport(Empaerior::Game::window.renderer, &renderer_viewport); | ||
f_pos.first -= renderer_viewport.x; | ||
f_pos.second -= renderer_viewport.y; | ||
|
||
//Transform the position relative to the camera dimesnions | ||
f_pos.first *= camera.rect.w; | ||
f_pos.second *= camera.rect.h; | ||
|
||
|
||
|
||
f_pos.first /= renderer_viewport.w; | ||
f_pos.second /= renderer_viewport.h; | ||
|
||
|
||
|
||
//Tranform for position | ||
f_pos.first += camera.rect.x; | ||
f_pos.second += camera.rect.y; | ||
|
||
|
||
|
||
|
||
return f_pos; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+0 Bytes
(100%)
bin-int/Debug-windows-/Empaerior/Empaerior.tlog/CL.command.1.tlog
Binary file not shown.
Binary file modified
BIN
+20.9 KB
(110%)
bin-int/Debug-windows-/Empaerior/Empaerior.tlog/CL.read.1.tlog
Binary file not shown.
Binary file modified
BIN
+4.45 KB
(120%)
bin-int/Debug-windows-/Empaerior/Empaerior.tlog/CL.write.1.tlog
Binary file not shown.
Binary file modified
BIN
+252 Bytes
(110%)
bin-int/Debug-windows-/Empaerior/Empaerior.tlog/link.command.1.tlog
Binary file not shown.
Binary file modified
BIN
+922 Bytes
(110%)
bin-int/Debug-windows-/Empaerior/Empaerior.tlog/link.read.1.tlog
Binary file not shown.
Binary file modified
BIN
+160 Bytes
(110%)
bin-int/Debug-windows-/Empaerior/Empaerior.tlog/link.write.1.tlog
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
bin-int/Dist-windows-/Empaerior/Empaerior.tlog/CL.command.1.tlog
Binary file not shown.
Binary file modified
BIN
+34.3 KB
(120%)
bin-int/Dist-windows-/Empaerior/Empaerior.tlog/CL.read.1.tlog
Binary file not shown.
Binary file modified
BIN
+4.7 KB
(150%)
bin-int/Dist-windows-/Empaerior/Empaerior.tlog/CL.write.1.tlog
Binary file not shown.
Binary file modified
BIN
+248 Bytes
(110%)
bin-int/Dist-windows-/Empaerior/Empaerior.tlog/link.command.1.tlog
Binary file not shown.
Binary file modified
BIN
-526 Bytes
(94%)
bin-int/Dist-windows-/Empaerior/Empaerior.tlog/link.read.1.tlog
Binary file not shown.
Binary file modified
BIN
+158 Bytes
(110%)
bin-int/Dist-windows-/Empaerior/Empaerior.tlog/link.write.1.tlog
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
workspace "Empaerior" | ||
|
||
architecture "x86" | ||
|
||
configurations | ||
|