summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c66
1 files changed, 19 insertions, 47 deletions
diff --git a/src/main.c b/src/main.c
index b0c87e2..2bdf6e3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,60 +1,32 @@
#include <SDL2/SDL.h>
-#include "utils.h"
-
-
-enum { shape_size = 16 };
+#include "room.h"
+#include "texture.h"
int main(int argc, char **argv)
{
- SDL_Window* window;
- SDL_Renderer* renderer;
- SDL_Texture* background;
- SDL_Texture* shape;
-
- SDL_Rect src;
- SDL_Rect dst;
-
- src.x = 0;
- src.y = 0;
- src.w = shape_size;
- src.h = shape_size;
-
- dst.x = 640 / 2 - shape_size;
- dst.y = 480 / 2 - shape_size;
- dst.w = shape_size * 2;
- dst.h = shape_size * 2;
-
- window = SDL_CreateWindow("T A K E T H I S",
- SDL_WINDOWPOS_UNDEFINED,
- SDL_WINDOWPOS_UNDEFINED,
- 640, 480, 0);
- renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
+ SDL_Window *wdw = SDL_CreateWindow("T A K E T H I S",
+ SDL_WINDOWPOS_UNDEFINED,
+ SDL_WINDOWPOS_UNDEFINED,
+ 950, 540, 0);
+ SDL_Renderer *rdr = SDL_CreateRenderer(wdw, -1,
+ SDL_RENDERER_ACCELERATED);
+ SDL_Texture *txr = tt_texture_load(rdr);
+ tt_room *room = tt_room_load(1);
- background = load_texture(renderer, "data/background.bmp");
- shape = load_texture(renderer, "data/shape.bmp");
+ SDL_SetRenderDrawColor(rdr, 215, 174, 0, 255);
- int i;
int n;
- for (i = 0; i < 2; ++i) {
- for(n = 0; n < 4; ++n) {
- src.x = shape_size * (n % 2);
- if (n > 1) {
- src.y = shape_size;
- } else {
- src.y = 0;
- }
- SDL_RenderCopy(renderer, background, NULL, NULL);
- SDL_RenderCopy(renderer, shape, &src, &dst);
- SDL_RenderPresent(renderer);
- SDL_Delay(500);
- }
+ for (n = 0; n != 200; ++n) {
+ SDL_RenderClear(rdr);
+ tt_room_draw(rdr, txr, room);
+ SDL_RenderPresent(rdr);
+ SDL_Delay(25);
}
- SDL_DestroyTexture(shape);
- SDL_DestroyTexture(background);
- SDL_DestroyRenderer(renderer);
- SDL_DestroyWindow(window);
+ SDL_DestroyTexture(txr);
+ SDL_DestroyRenderer(rdr);
+ SDL_DestroyWindow(wdw);
SDL_Quit();
return 0;
}