ui
This commit is contained in:
parent
c690a9e083
commit
08621ab489
5 changed files with 31 additions and 2 deletions
|
@ -134,6 +134,9 @@ typedef struct GameData {
|
||||||
Map currentMap;
|
Map currentMap;
|
||||||
Mission missions[MAX_MISSIONS];
|
Mission missions[MAX_MISSIONS];
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
>>>>>>> 4b87dcb (ui)
|
||||||
int mapx, mapy;
|
int mapx, mapy;
|
||||||
} GameData;
|
} GameData;
|
||||||
|
|
||||||
|
@ -162,7 +165,11 @@ typedef struct {
|
||||||
GameData data;
|
GameData data;
|
||||||
BuildingData buildings[100];
|
BuildingData buildings[100];
|
||||||
UnitData units[100];
|
UnitData units[100];
|
||||||
|
<<<<<<< HEAD
|
||||||
} Game;
|
} Game;
|
||||||
=======
|
=======
|
||||||
} GameData;
|
} GameData;
|
||||||
>>>>>>> 8e3d2ca (add game structure)
|
>>>>>>> 8e3d2ca (add game structure)
|
||||||
|
=======
|
||||||
|
} Game;
|
||||||
|
>>>>>>> 4b87dcb (ui)
|
||||||
|
|
|
@ -47,6 +47,9 @@ void drawGameData(SDL_Renderer *renderer, const GameData *gameData, SDL_Texture
|
||||||
// Present the rendered frame
|
// Present the rendered frame
|
||||||
SDL_RenderPresent(renderer);
|
SDL_RenderPresent(renderer);
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
>>>>>>> 4b87dcb (ui)
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawMinimap(SDL_Renderer *renderer, const Map *map, int minimapX, int minimapY, int minimapSize) {
|
void drawMinimap(SDL_Renderer *renderer, const Map *map, int minimapX, int minimapY, int minimapSize) {
|
||||||
|
@ -71,6 +74,9 @@ void drawMinimap(SDL_Renderer *renderer, const Map *map, int minimapX, int minim
|
||||||
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
|
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
|
||||||
SDL_Rect minimapBorderRect = {minimapX, minimapY, minimapSize, minimapSize};
|
SDL_Rect minimapBorderRect = {minimapX, minimapY, minimapSize, minimapSize};
|
||||||
SDL_RenderDrawRect(renderer, &minimapBorderRect);
|
SDL_RenderDrawRect(renderer, &minimapBorderRect);
|
||||||
|
<<<<<<< HEAD
|
||||||
=======
|
=======
|
||||||
>>>>>>> 6abc1cd (draw function)
|
>>>>>>> 6abc1cd (draw function)
|
||||||
|
=======
|
||||||
|
>>>>>>> 4b87dcb (ui)
|
||||||
}
|
}
|
|
@ -1,11 +1,13 @@
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "data.h"
|
#include "data.h"
|
||||||
|
#include "draw.h"
|
||||||
|
#include "input.h"
|
||||||
|
#include "ui.h"
|
||||||
|
|
||||||
const int SCREEN_WIDTH = 800;
|
const int SCREEN_WIDTH = 800;
|
||||||
const int SCREEN_HEIGHT = 600;
|
const int SCREEN_HEIGHT = 600;
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
SDL_Init(SDL_INIT_VIDEO);
|
SDL_Init(SDL_INIT_VIDEO);
|
||||||
SDL_Window* window = SDL_CreateWindow("RTS Game", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
SDL_Window* window = SDL_CreateWindow("RTS Game", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
||||||
|
@ -55,4 +57,4 @@ int main(int argc, char* argv[]) {
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
6
src/ui.c
6
src/ui.c
|
@ -30,6 +30,9 @@ void handleButtonEvents(SDL_Event *event, Button buttons[], int numButtons) {
|
||||||
handleButtonClick(event, &buttons[i]);
|
handleButtonClick(event, &buttons[i]);
|
||||||
}
|
}
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
>>>>>>> 4b87dcb (ui)
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawButtons(SDL_Renderer *renderer, Button buttons[], int numButtons, TTF_Font *font) {
|
void drawButtons(SDL_Renderer *renderer, Button buttons[], int numButtons, TTF_Font *font) {
|
||||||
|
@ -66,6 +69,9 @@ void drawButtons(SDL_Renderer *renderer, Button buttons[], int numButtons, TTF_F
|
||||||
// Present renderer
|
// Present renderer
|
||||||
SDL_RenderPresent(renderer);
|
SDL_RenderPresent(renderer);
|
||||||
}
|
}
|
||||||
|
<<<<<<< HEAD
|
||||||
=======
|
=======
|
||||||
}
|
}
|
||||||
>>>>>>> 206ed0e (basic ui controls)
|
>>>>>>> 206ed0e (basic ui controls)
|
||||||
|
=======
|
||||||
|
>>>>>>> 4b87dcb (ui)
|
||||||
|
|
8
src/ui.h
8
src/ui.h
|
@ -9,10 +9,14 @@ typedef struct {
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
bool clicked;
|
bool clicked;
|
||||||
void (*onClick)();
|
void (*onClick)();
|
||||||
|
<<<<<<< HEAD
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
char text[50];
|
char text[50];
|
||||||
=======
|
=======
|
||||||
>>>>>>> 206ed0e (basic ui controls)
|
>>>>>>> 206ed0e (basic ui controls)
|
||||||
|
=======
|
||||||
|
char text[50];
|
||||||
|
>>>>>>> 4b87dcb (ui)
|
||||||
} Button;
|
} Button;
|
||||||
|
|
||||||
// Function prototypes
|
// Function prototypes
|
||||||
|
@ -20,8 +24,12 @@ bool isPointInsideRect(int x, int y, SDL_Rect rect);
|
||||||
void handleButtonClick(SDL_Event *event, Button *button);
|
void handleButtonClick(SDL_Event *event, Button *button);
|
||||||
void handleButtonEvents(SDL_Event *event, Button buttons[], int numButtons);
|
void handleButtonEvents(SDL_Event *event, Button buttons[], int numButtons);
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
void drawButtons(SDL_Renderer *renderer, Button buttons[], int numButtons, TTF_Font *font);
|
void drawButtons(SDL_Renderer *renderer, Button buttons[], int numButtons, TTF_Font *font);
|
||||||
=======
|
=======
|
||||||
>>>>>>> 206ed0e (basic ui controls)
|
>>>>>>> 206ed0e (basic ui controls)
|
||||||
|
=======
|
||||||
|
void drawButtons(SDL_Renderer *renderer, Button buttons[], int numButtons, TTF_Font *font);
|
||||||
|
>>>>>>> 4b87dcb (ui)
|
||||||
|
|
||||||
#endif /* UI_H */
|
#endif /* UI_H */
|
||||||
|
|
Loading…
Reference in a new issue