From b6628cddfaaccc4bae4de077f8e8e80a0af86d02 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Wed, 20 Mar 2019 00:57:32 -0400 Subject: Remove demo --- demo.c | 113 ----------------------------------------------------------------- 1 file changed, 113 deletions(-) delete mode 100644 demo.c (limited to 'demo.c') diff --git a/demo.c b/demo.c deleted file mode 100644 index 812e5f4..0000000 --- a/demo.c +++ /dev/null @@ -1,113 +0,0 @@ -/* Copyright (C) 2019 C. McEnroe - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#include -#include - -#include - -#include "cards.h" - -enum { - Width = 585, - Height = 402, -}; - -static void fail(const char *prefix) { - fprintf(stderr, "%s: %s\n", prefix, SDL_GetError()); - exit(EXIT_FAILURE); -} - -int main(void) { - if (SDL_Init(SDL_INIT_VIDEO) < 0) fail("SDL_Init"); - atexit(SDL_Quit); - - SDL_Window *window; - SDL_Renderer *render; - int error = SDL_CreateWindowAndRenderer( - Width, Height, SDL_WINDOW_ALLOW_HIGHDPI, - &window, &render - ); - if (error) fail("SDL_CreateWindowAndRenderer"); - - int width, height; - SDL_GetRendererOutputSize(render, &width, &height); - if (width > Width || height > Height) { - SDL_RenderSetIntegerScale(render, SDL_TRUE); - SDL_RenderSetScale( - render, - (float)width / Width, - (float)height / Height - ); - } - - // TODO: Path search/option. - SDL_RWops *rw = SDL_RWFromFile("CARDS.DLL", "rb"); - if (!rw) fail("CARDS.DLL"); - - struct Cards *cards = Cards_Load( - rw, Cards_ColorKey | Cards_AlphaCorners | Cards_BlackBorders - ); - if (!cards) fail("Cards_Load"); - SDL_RWclose(rw); - - SDL_Texture *textures[Cards_Count]; - for (int i = 0; i < Cards_Count; ++i) { - textures[i] = NULL; - if (!cards->surfaces[i]) continue; - textures[i] = SDL_CreateTextureFromSurface(render, cards->surfaces[i]); - if (!textures[i]) fail("SDL_CreateTextureFromSurface"); - } - Cards_Free(cards); - - int card = Cards_Club + Cards_A; - SDL_Rect rect = { 11, 5, Cards_Width, Cards_Height }; - - for (;;) { - SDL_Event event; - SDL_WaitEvent(&event); - if (event.type == SDL_QUIT) break; - - if (event.type == SDL_KEYDOWN) { - if (event.key.keysym.sym == SDLK_LEFT) { - do { - card--; - if (!card) card = Cards_Count - 1; - } while (!textures[card]); - } else if (event.key.keysym.sym == SDLK_RIGHT) { - do { - card++; - if (card == Cards_Count) card = 0; - } while (!textures[card]); - } - } - - if (event.type == SDL_MOUSEMOTION) { - if (event.motion.state & SDL_BUTTON_LMASK) { - rect.x += event.motion.xrel; - rect.y += event.motion.yrel; - } - } - - SDL_SetRenderDrawColor(render, 0x00, 0xAA, 0x55, 0xFF); - SDL_RenderClear(render); - SDL_RenderCopy(render, textures[card], NULL, &rect); - - SDL_RenderPresent(render); - } - - return EXIT_SUCCESS; -} -- cgit 1.4.1