using git now lol

This commit is contained in:
2026-01-21 13:51:24 -06:00
parent 3117428afe
commit f3c0aafe2f
20 changed files with 529 additions and 0 deletions

22
include/deck.h Normal file
View File

@@ -0,0 +1,22 @@
//Troy Rosin
#ifndef __deck_h__
#define __deck_h__
#include <SDL2/SDL.h>
#define MAX_HANDSIZE 8
#define CARD_SIZE (128 * 2)
#define CARD_W (96 * 2)
typedef struct hand
{
int handsize;
SDL_Texture *cards[MAX_HANDSIZE];
SDL_Rect card_rects[MAX_HANDSIZE];
} HAND;
#endif

37
include/game.h Normal file
View File

@@ -0,0 +1,37 @@
//Troy Rosin
#ifndef __game_h__
#define __game_h__
#include <SDL2/SDL.h>
#define DEF_WINDOW_WIDTH 1920
#define DEF_WINDOW_HEIGHT 1080
extern int running;
extern int state;
#define TITLE 0
#define BATTLE 1
extern int state;
#define START_GAME 0
#define EXIT_GAME 1
#define MAIN_SELECTIONS 2
extern int selected_index;
void start_battle();
extern SDL_Window* window;
extern SDL_Renderer* renderer;
extern SDL_Event event;
#define GRAB_NEW 2
#define GRAB_OLD 1
#define LETGO 3
#define NOT_DRAG 0
extern int dragging;
#endif

12
include/input.h Normal file
View File

@@ -0,0 +1,12 @@
/*Troy Rosin*/
#ifndef __input_h__
#define __input_h__
#include <SDL2/SDL.h>
void handle_input(SDL_Event *e);
void handle_event(SDL_Event *e);
#endif

89
include/mydebug.h Normal file
View File

@@ -0,0 +1,89 @@
#ifndef __mydebug_h__
#define __mydebug_h__
/*for debugging print statments and timers
* Troy Rosin TJR760 11200680
* compile with -Ddebug and the prints will be there
* otherwise nothing wil appear
*
* to use with makefile add the following
*
* debug ?=off
* ifeq ($(debug),on)
* CPPFLAGS += -Ddebug
* endif
*
* then use "make debug=on" to make if you want the debug messages
* just use make to build normally
*
*/
#include <stdio.h>
#include <time.h>
#ifdef debug
/*prints the name of the function that was called passed as an arg */
#define PRINT_C(FUNC)\
puts(#FUNC" was called");
/*prints the message wanted followed by a \n no "" needed*/
#define PRINT_M(MSG)\
puts(#MSG);
/*prints the name of a variable holding a pointer and its value*/
#define PRINT_P(PTR)\
printf(#PTR" has value %p\n", (void*)PTR);
/*prints the varilble name holding the int and the value
* Type is how you want it to print ie l, d, ld, u, f...
* just pass the field type printf expects without the '%'
*/
#define PRINT_INT(VAR, TYPE)\
printf(#VAR" has value %"#TYPE"\n", VAR);
/*starts a timer so you can see how long fuctions can run for
* you must end the timer within the same scope as the start
* the id can be anything its only used to differentiate between
* timers
* T_START must be placed at the end of variable definitions to comply with C90
* standards. if not using C90 go nuts
*/
#define T_START(ID)\
struct timespec ID ## __d_timer_s__;\
struct timespec ID ## __d_timer_e__;\
clock_gettime(CLOCK_MONOTONIC_RAW, &ID ## __d_timer_s__);
/*checks how long since the timer began and prints the seconds and nanoseconds
* since. Can be called multiple times if needed
*/
#define T_END(ID)\
clock_gettime(CLOCK_MONOTONIC_RAW, &ID ## __d_timer_e__);\
printf("timer "#ID" took:\n%ld second(s) total\n%ld nanoseconds total\n",\
((ID ## __d_timer_e__.tv_sec * 1000000000 + ID ## __d_timer_e__.tv_nsec - \
ID ## __d_timer_s__.tv_sec * 1000000000 + ID ## __d_timer_s__.tv_nsec) - \
((ID ## __d_timer_e__.tv_sec * 1000000000 + ID ## __d_timer_e__.tv_nsec-\
ID ## __d_timer_s__.tv_sec * 1000000000 + ID ## __d_timer_s__.tv_nsec) \
% 1000000000)) / 1000000000 , \
ID ## __d_timer_e__.tv_sec * 1000000000 + ID ## __d_timer_e__.tv_nsec -\
ID ## __d_timer_s__.tv_sec * 1000000000 + ID ## __d_timer_s__.tv_nsec );
#else
/*if debug was not defined we insert nothing there*/
#define PRINT_C(X) {}
#define PRINT_M(X) {}
#define PRINT_P(X) {}
#define PRINT_INT(X,Y) {}
#define T_START(X) {}
#define T_END(X) {}
#endif
#endif