Repository navigation
Expand file tree
/
Copy pathxpet.h
More file actions
82 lines (67 loc) · 1.47 KB
/
Copy pathxpet.h
File metadata and controls
82 lines (67 loc) · 1.47 KB
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
#pragma once
#include <X11/Xlib.h>
#define VERSION "v0.2"
#define N_KEYBINDS 3
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define CLAMP(v, l, h) ((v) < (l) ? (l) : ((v) > (h) ? (h) : (v)))
enum state {
SLEEPING, IDLE,
N, S, E, W,
NW, NE, SW, SE,
DRAGGED,
HAPPY,
STATE_LAST
};
struct animation {
struct frame* frames;
const char* name;
int* frame_durations; /* NULL = use FRAME_DURATION */
int n_frames;
Bool loop;
};
struct bind {
KeySym sym;
unsigned long mask;
};
struct frame {
Pixmap pix;
Pixmap mask;
int duration;
};
struct mouse {
int x;
int y;
};
struct pet {
Window window;
Bool chasing;
Bool frozen;
enum state state;
int x;
int y;
double subpixel_x; /* subpixel x */
double subpixel_y; /* subpixel y */
struct animation* current_animation;
int current_frame;
long frame_time;
/* random wander state */
int target_x;
int target_y;
long wander_wait; /* time to wait at destination */
/* idle/sleep state */
long frozen_time; /* time spent frozen */
long unfreeze_delay; /* time after frozen where idle */
/* happy state */
enum state previous_state; /* state before becoming happy */
long happy_time; /* time spent happy */
/* dragging state */
Bool dragging;
int drag_offset_x;
int drag_offset_y;
Bool was_chasing; /* was chasing before drag */
Bool was_frozen; /* was frozen before drag */
/* speech bubble */
const char* speech;
long speech_time;
Window bubble_window;
};