1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
/* 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
|