#include "raylib.h" #include #include #include "sprite.h" #include "Input/inputHandler.h" #include "raymath.h" #include "List/list.h" #include "IsometricMap/isometricRenderer.h" #include "IsometricMap/isometricMap.h" #include "game.h" int main(){ InitWindow(800, 450, "basic window"); Game *game = GameInit(); // Hides the operating systems own cursor HideCursor(); SetTargetFPS(60); while(!WindowShouldClose()){ BeginDrawing(); ClearBackground(RAYWHITE); BeginMode2D(*(game->camera)); IsometricRendererRenderIsometricMap(game->layers, game->inputHandler); ListDrawAllSprites(game->sprites, game->layers[0], game->camera); EndMode2D(); // Moving cursor Sprite to Mouse Pos and drawing it game->cursorSprite->x = game->inputHandler->cursorPos.x; game->cursorSprite->y = game->inputHandler->cursorPos.y; DrawSpriteToScreen(game->cursorSprite); // User Input Handling mouseInput(game); keyboardInput(game->inputHandler, game->camera); //cursor Positions test //printf("Cursor Pos: %f %f\n", game->inputHandler->cursorPos.x, game->inputHandler.cursorPos.y)-> //printf("Cursor World Pos: %f %f\n", game->inputHandler->cursorWorldPos.x, game->inputHandler->cursorWorldPos.y); // Sprites move towards their destination float movementSpeed = 10.0f; Node *current = game->sprites->head; while (current != 0){ if(current->data.hasDestination == 1){ Vector2 movement = { current->data.destX - current->data.x, current->data.destY - current->data.y }; if(Vector2Length(movement) < movementSpeed){ current->data.hasDestination = 0; current->data.x = current->data.destX; current->data.y = current->data.destY; } else{ movement = Vector2Normalize(movement); movement = Vector2Scale(movement, movementSpeed); current->data.x += movement.x; current->data.y += movement.y; // Change sprite according to direction Vector2 nullvektor = {0,0}; float f = Vector2Angle(movement, nullvektor); printf("Angle: %f\n", f); f /= 3.14; f *= 3.5; f += 3.5; int index = (int) f; current->data.texture = game->worker + index; } } current = current->next; } DrawFPS(GetScreenWidth() - 95, 10); EndDrawing(); } CloseWindow(); return 0; }