You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.9 KiB

#include "game.h"
#include "stdlib.h"
#include "raylib.h"
#include "Sprite/sprite.h"
#include "Input/inputHandler.h"
#include "IsometricMap/isometricMap.h"
#include "Textures/textureatlas.h"
#include "stdio.h"
#include "Entity/entity.h"
#include "MapObject/building.h"
#include "Ui/uiContainer.h"
#include "MapObject/staticobjects.h"
#include "Screen/screen.h"
Game *GameInit()
{
Game *game = malloc(sizeof(Game));
game->textures = TextureAtlasInit();
game->cursorSprite = SpriteCreate(game->textures, TE_CURSOR, 450, 225);
game->inputHandler = malloc(sizeof(InputHandler));
game->inputHandler->rectStart.x = 0;
game->inputHandler->rectStart.y = 0;
game->inputHandler->cursorPos.x = 0;
game->inputHandler->cursorPos.y = 0;
game->inputHandler->cursorWorldPos.x = 0;
game->inputHandler->cursorWorldPos.y = 0;
game->inputHandler->cursorWorldTile.x = 0;
game->inputHandler->cursorWorldTile.y = 0;
game->inputHandler->drawTileId = 0;
game->mouseOnUI = 0;
game->camera = malloc(sizeof(Camera2D));
game->camera->target.x = 0;
game->camera->target.y = 0;
game->camera->rotation = 0.0f;
game->camera->zoom = 1.0f;
game->camera->offset.x = 0;
game->camera->offset.y = 0;
game->sprites = SpriteListInit();
game->entities = EntityListInit();
game->buildings = BuildingListInit();
game->objects = StaticObjectListInit();
game->map = IsometricMapInit(game);
//das du es weißt man kann wenn du nicht auf hört was machen und dann bist du leise es gibt was das nett sich rufmord
int i,j;
for (i = 0; i < game->map->width; i++)
{
for (j = 0; j < game->map->height; j++)
{
IsometricMapChangeTextureIdOfTile(game->map, i, j, 0);
}
}
for(i = 0; i < SCREEN_AMOUNT; i++){
game->screens[i] = InitScreen(game, i);
}
game->currentScreen = SCREEN_MAINMENU;
return game;
}