Camera Zoom now works for input, still needs to be implemented for map drawing - will be done after refactor and merge of that system. Zoom using I and K

main
JanEhehalt 3 years ago
parent de0dacd814
commit 4396ad0abc

@ -50,6 +50,20 @@ void mouseInput(Game *game){
inputHandler->cursorPos.x = GetMousePosition().x; inputHandler->cursorPos.x = GetMousePosition().x;
inputHandler->cursorPos.y = GetMousePosition().y; inputHandler->cursorPos.y = GetMousePosition().y;
// bissl Kamera Zoom
float maxZoom = 5.0f;
float minZoom = 0.2f;
if(IsKeyPressed(KEY_I)){
if(camera->zoom < maxZoom){
camera->zoom += 0.2f;
}
}
if(IsKeyPressed(KEY_K)){
if(camera->zoom > minZoom){
camera->zoom -= 0.2f;
}
}
// resetting last selected Tile to grass texture // resetting last selected Tile to grass texture
if(inputHandler->selectedLayer != -1){ if(inputHandler->selectedLayer != -1){
IsometricMapChangeTextureIdOfTile(layers, (int) inputHandler->cursorWorldTile.x, (int) inputHandler->cursorWorldTile.y, inputHandler->selectedLayer, 0); IsometricMapChangeTextureIdOfTile(layers, (int) inputHandler->cursorWorldTile.x, (int) inputHandler->cursorWorldTile.y, inputHandler->selectedLayer, 0);
@ -64,7 +78,11 @@ void mouseInput(Game *game){
int mouseAdjustmentX = -tileWidthHalf; int mouseAdjustmentX = -tileWidthHalf;
int mouseAdjustmentY = -tileHeightQuarter + (tileHeightQuarter * layers[n]->layer); int mouseAdjustmentY = -tileHeightQuarter + (tileHeightQuarter * layers[n]->layer);
IsometricMapProject(layers[n], camera, inputHandler->cursorPos.x + mouseAdjustmentX, inputHandler->cursorPos.y + mouseAdjustmentY, &inputHandler->cursorWorldPos); // Updating inputHandler->cursorWorldPos Vector2D
IsometricMapProject(layers[n], camera,
(inputHandler->cursorPos.x / camera->zoom) + mouseAdjustmentX,
(inputHandler->cursorPos.y / camera->zoom) + mouseAdjustmentY,
&inputHandler->cursorWorldPos);
/*N I C E*/ Tile *selectedTile = IsometricMapGetTileFromWorldCoordinates(layers, inputHandler->cursorWorldPos.x, inputHandler->cursorWorldPos.y, n); /*N I C E*/ Tile *selectedTile = IsometricMapGetTileFromWorldCoordinates(layers, inputHandler->cursorWorldPos.x, inputHandler->cursorWorldPos.y, n);

@ -22,7 +22,7 @@ Fantasy Welt oder Realistisch?
+ LinkedList erweitern + LinkedList erweitern
+ Sprites Animationen etc improven + Sprites Animationen etc improven
+ Die Inputs sollten den Kamera Zoom beachten, aktuell geht noch alles kaputt wenn man den zoom umstellt + Das Map Rendering sollte den Zoom auch noch beachten, wenn man rauszoomt wird nicht die ganzen map gedrawed, sondern nur die mit den default values
+ Maps in eigenen Dateien speichern + Maps in eigenen Dateien speichern
+ Parser für Map-Dateien + Parser für Map-Dateien
+ MapEditor + MapEditor

@ -20,6 +20,7 @@ void DebugDraw(Game *game, UiContainer *uiContainer){
sprintf(strings[lineamount++], "MouseWorldY: %d", (int)game->inputHandler->cursorWorldPos.y); sprintf(strings[lineamount++], "MouseWorldY: %d", (int)game->inputHandler->cursorWorldPos.y);
sprintf(strings[lineamount++], "Selected Layer: %d", game->inputHandler->selectedLayer); sprintf(strings[lineamount++], "Selected Layer: %d", game->inputHandler->selectedLayer);
sprintf(strings[lineamount++], "DEPTH: %d", (int)(game->inputHandler->cursorWorldPos.x + game->inputHandler->cursorWorldPos.y + game->inputHandler->selectedLayer)); sprintf(strings[lineamount++], "DEPTH: %d", (int)(game->inputHandler->cursorWorldPos.x + game->inputHandler->cursorWorldPos.y + game->inputHandler->selectedLayer));
sprintf(strings[lineamount++], "Camera Zoom: %f", game->camera->zoom);
// Drawed eine Box für die Debug Info // Drawed eine Box für die Debug Info
DrawRectangleLines(0, 0, neededWidth, lineamount * DEBUG_FONT_SIZE + 5, (Color){0, 0, 0, 255}); DrawRectangleLines(0, 0, neededWidth, lineamount * DEBUG_FONT_SIZE + 5, (Color){0, 0, 0, 255});

@ -22,8 +22,8 @@ int main(){
Game *game = GameInit(); Game *game = GameInit();
// TODO: Screen structs, die zum Beispiel die UiContainer enthalten? // TODO: Screen structs, die zum Beispiel die UiContainer enthalten?
UiContainer *pauseScreenUiContainer = UiContainerInitPauseUiContainer();
UiContainer *pauseScreenUiContainer = UiContainerInitPauseUiContainer();
UiContainer *mainMenuScreenUiContainer = UiContainerInitMainMenuUiContainer(); UiContainer *mainMenuScreenUiContainer = UiContainerInitMainMenuUiContainer();
// Hides the operating systems own cursor // Hides the operating systems own cursor

Loading…
Cancel
Save