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.
126 lines
3.7 KiB
126 lines
3.7 KiB
#include "game.h"
|
|
#include "stdlib.h"
|
|
#include "raylib.h"
|
|
#include "sprite.h"
|
|
#include "List/list.h"
|
|
#include "Input/inputHandler.h"
|
|
#include "IsometricMap/isometricMap.h"
|
|
#include "Textures/textureatlas.h"
|
|
#include "stdio.h"
|
|
#include "Ui/screenIDs.h"
|
|
|
|
// returns pointer to new Game instance
|
|
Game *GameInit()
|
|
{
|
|
Game *game = malloc(sizeof(Game));
|
|
|
|
game->textures = TextureAtlasInit();
|
|
|
|
game->cursorSprite = SpriteCreate(game->textures, 0, 450, 225);
|
|
game->inputHandler = malloc(sizeof(InputHandler));
|
|
game->inputHandler->pressed = 0;
|
|
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->selectedLayer = -1;
|
|
game->inputHandler->cursorTextures = game->textures->cursorTextures;
|
|
game->inputHandler->cursorSprite = game->cursorSprite;
|
|
|
|
game->screen = SCREEN_MAINMENU;
|
|
|
|
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 = ListInit();
|
|
|
|
game->layers = malloc(10 * sizeof(IsometricMap *));
|
|
//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
|
|
|
|
// Test Layers ---
|
|
int n = 0;
|
|
int i = 0;
|
|
int j = 0;
|
|
|
|
for (n = 0; n < 10; n++)
|
|
{
|
|
((game->layers))[n] = IsometricMapInit(n);
|
|
}
|
|
|
|
for (n = 0; n < 10; n++)
|
|
{
|
|
for (i = 0; i < game->layers[n]->width; i++)
|
|
{
|
|
for (j = 0; j < game->layers[n]->height; j++)
|
|
{
|
|
if(i > 50 && i < 70 && j == 50){
|
|
IsometricMapChangeTextureIdOfTile(game->layers, i, j, n, 0);
|
|
}
|
|
|
|
switch (n)
|
|
{
|
|
case 0:
|
|
IsometricMapChangeTextureIdOfTile(game->layers, i, j, n, 0);
|
|
break;
|
|
case 1:
|
|
if (i > 35 && i < 50 && j > 45 && j < 60)
|
|
{
|
|
IsometricMapChangeTextureIdOfTile(game->layers, i, j, n, 0);
|
|
}
|
|
break;
|
|
case 2:
|
|
if (i > 40 && i < 44 && j > 50 && j < 54)
|
|
{
|
|
IsometricMapChangeTextureIdOfTile(game->layers, i, j, n, 2);
|
|
}
|
|
break;
|
|
}
|
|
if(i == j && n == 1){
|
|
IsometricMapChangeTextureIdOfTile(game->layers, i, j, n, 0);
|
|
}
|
|
if(i == j && n == 2){
|
|
IsometricMapChangeTextureIdOfTile(game->layers, i, j, n, 0);
|
|
}
|
|
if(i == j-1 && n == 1){
|
|
IsometricMapChangeTextureIdOfTile(game->layers, i, j, n, 0);
|
|
}
|
|
if(i-1 == j && n == 1){
|
|
IsometricMapChangeTextureIdOfTile(game->layers, i, j, n, 0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
for (n = 0; n < 10; n++)
|
|
{
|
|
for (i = 0; i < 20 - n * 2; i++)
|
|
{
|
|
for (j = 0; j < 20 - n * 2; j++)
|
|
{
|
|
IsometricMapChangeTextureIdOfTile(game->layers, i, j, n, 0);
|
|
}
|
|
}
|
|
}
|
|
|
|
n = 0;
|
|
for (i = 0; i < game->layers[0]->width; i++)
|
|
{
|
|
for (j = 0; j < game->layers[0]->height; j++)
|
|
{
|
|
IsometricMapChangeTextureIdOfTile(game->layers, i, j, n, 0);
|
|
}
|
|
}
|
|
// -------
|
|
|
|
return game;
|
|
}
|