diff options
Diffstat (limited to 'globals.h')
-rw-r--r-- | globals.h | 154 |
1 files changed, 88 insertions, 66 deletions
@@ -1,66 +1,88 @@ -#ifndef GLOBALS_H
-#define GLOBALS_H
-
-#define FRAMERATE 14
-#define BUF_SZ 1024
-/* The amount to offset the rainbow off the center of the cat */
-#define OFFSET 25
-#define PI 3.14159265
-
-/* Type definitions */
-typedef struct {
- int x, y;
-} coords;
-
-typedef struct cat_instance cat_instance;
-struct cat_instance
- {
- coords loc;
- struct list_head list;
- };
-
-typedef struct rainbow_instance rainbow_instance;
-struct rainbow_instance
- {
- coords loc;
- unsigned sprite;
- struct list_head list;
- };
-
-typedef struct sparkle_instance sparkle_instance;
-struct sparkle_instance
- {
- unsigned int frame, speed;
- int frame_mov;
- unsigned int layer;
- coords loc;
- struct list_head list;
- };
-
-SDL_Event event;
-bool running = true, sound = true, fullscreen = true, cursor = false, sine = false;
-int sound_volume = 128, catsize = 0, sparkle_spawn_counter = 0;
-Mix_Music *music;
-
-#define BASE_PATH "res"
-char *cat_dir;
-LIST_HEAD(sparkle_list);
-LIST_HEAD(cat_list);
-LIST_HEAD(rainbow_list);
-
-int cat_width, cat_height, rainbow_width, rainbow_height, sparkle_width, sparkle_height;
-SDL_Renderer *renderer;
-SDL_Texture *cat_texture, *rainbow_texture, *sparkle_texture;
-uint32_t cat_sprite, rainbow_sprite, sparkle_sprite;
-int cat_count, sparkle_count, rainbow_count;
-int sparkle_pos;
-/* For sine */
-unsigned t;
-
-unsigned cat_num = 1;
-double cat_size = 1;
-
-unsigned SCREEN_WIDTH = 1200;
-unsigned SCREEN_HEIGHT = 800;
-
-#endif
+ /* nyancat in GNU C + Copyright © 2023-2024 DiffieHellman + + 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 <https://www.gnu.org/licenses/>. + */ + +#ifndef GLOBALS_H +#define GLOBALS_H + +#include <stdint.h> +#include <stdbool.h> +#include <SDL2/SDL.h> +#include <SDL2/SDL_mixer.h> +#include <bsd/sys/queue.h> // linked list implementation + +#define FRAMERATE 14 +#define BUF_SZ 1024 +/* the amount to offset the rainbow off the center of the cat */ +#define OFFSET 25 +#define PI 3.14159265 +#define BASE_PATH "res" + +/* type definitions */ +typedef struct { + int x, y; +} coords; + +typedef struct cat cat_instance; +struct cat + { + coords loc; + /* direction cat in bouncing in - only used if bounce is set */ + coords bounce_direction; + /* magic to handle the linked list */ + LIST_ENTRY(cat) entries; + }; +extern struct head_cat cat_list; + +typedef struct rainbow rainbow_instance; +struct rainbow + { + coords loc; + unsigned sprite; + /* magic to handle the linked list */ + LIST_ENTRY(rainbow) entries; + }; +extern struct head_rainbow rainbow_list; + +typedef struct sparkle sparkle_instance; +struct sparkle + { + unsigned short frame, speed; + short frame_mov; + unsigned short layer; + coords loc; + /* magic to handle the linked list */ + LIST_ENTRY(sparkle) entries; + }; +extern struct head_sparkle sparkle_list; + +LIST_HEAD(head_cat, cat); +LIST_HEAD(head_rainbow, rainbow); +LIST_HEAD(head_sparkle, sparkle); + +extern unsigned screen_width, screen_height, t, cat_num; +extern int sound_volume, sparkle_spawn_counter, cat_width, cat_height, rainbow_width, rainbow_height, sparkle_width, sparkle_height, cat_count, sparkle_count, rainbow_count, sparkle_pos; +extern uint32_t cat_sprite, rainbow_sprite, sparkle_sprite; +extern double cat_size; +extern bool running, sound, fullscreen, cursor, sine, bounce; +extern char *cat_dir; + +extern SDL_Event event; +extern Mix_Music *music; +extern SDL_Renderer *renderer; +extern SDL_Texture *cat_texture, *rainbow_texture, *sparkle_texture; + +#endif |