summaryrefslogtreecommitdiff
path: root/parex/egg.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2007-02-17 16:31:55 +0000
committerMike Buland <eichlan@xagasoft.com>2007-02-17 16:31:55 +0000
commit89eeeff54f0b3ce30be5b046fc3899fdeb5ebb40 (patch)
treea4a8fc2e184df736f61c1dea1e8627dd3667b071 /parex/egg.h
parent27c626112a7114f9bdc4f7739f9ec05ae9fcbee1 (diff)
downloadlibbu++-89eeeff54f0b3ce30be5b046fc3899fdeb5ebb40.tar.gz
libbu++-89eeeff54f0b3ce30be5b046fc3899fdeb5ebb40.tar.bz2
libbu++-89eeeff54f0b3ce30be5b046fc3899fdeb5ebb40.tar.xz
libbu++-89eeeff54f0b3ce30be5b046fc3899fdeb5ebb40.zip
Tweaked the stream classes, added an example, and the begining of a formula
parser.
Diffstat (limited to 'parex/egg.h')
-rw-r--r--parex/egg.h127
1 files changed, 127 insertions, 0 deletions
diff --git a/parex/egg.h b/parex/egg.h
new file mode 100644
index 0000000..6830edd
--- /dev/null
+++ b/parex/egg.h
@@ -0,0 +1,127 @@
1/*
2 * EGG.H - part of the EGG system.
3 *
4 * Global definitions and function prototypes.
5 *
6 * By Shawn Hargreaves.
7 */
8
9
10#ifndef __EGG_H__
11#define __EGG_H__
12
13
14#ifndef TRUE
15#define TRUE -1
16#define FALSE 0
17#endif
18
19#ifndef MIN
20#define MIN(x,y) (((x) < (y)) ? (x) : (y))
21#define MAX(x,y) (((x) > (y)) ? (x) : (y))
22#define MID(x,y,z) MAX((x), MIN((y), (z)))
23#endif
24
25#ifndef ABS
26#define ABS(x) (((x) >= 0) ? (x) : (-(x)))
27#endif
28
29#ifndef ALLEGRO_H
30struct BITMAP;
31#endif
32
33
34
35/* possible particle commands (ie. language keywords) */
36#define EGG_COMMAND_INIT 1
37#define EGG_COMMAND_SET 2
38#define EGG_COMMAND_IF 3
39#define EGG_COMMAND_LAY 4
40#define EGG_COMMAND_DIE 5
41
42
43
44/* each particle is controlled by a command list */
45typedef struct EGG_COMMAND
46{
47 int type; /* command type */
48 int line; /* source line number */
49 char *var; /* variable to be set */
50 char *exp; /* arithmetic expression */
51 struct EGG_COMMAND *cmd; /* nested, child command list (if) */
52 struct EGG_COMMAND *cmd2; /* more child commands (else) */
53 struct EGG_COMMAND *next; /* linked list pointer */
54} EGG_COMMAND;
55
56
57
58/* each type of particle is defined by one of these structures */
59typedef struct EGG_TYPE
60{
61 char *name; /* type name */
62 EGG_COMMAND *cmd; /* command list */
63 struct EGG_TYPE *next; /* linked list pointer */
64} EGG_TYPE;
65
66
67
68/* particles store their state variables in these structures */
69typedef struct EGG_VARIABLE
70{
71 char *name; /* variable name */
72 double val; /* current value */
73 struct EGG_VARIABLE *next; /* linked list pointer */
74} EGG_VARIABLE;
75
76
77
78/* a specific particle instance */
79typedef struct EGG_PARTICLE
80{
81 int num; /* unique ID number */
82 EGG_TYPE *type; /* type information */
83 EGG_VARIABLE *var; /* list of variables */
84 struct EGG_PARTICLE *next; /* linked list pointer */
85} EGG_PARTICLE;
86
87
88
89/* everything you need to know about an EGG particle system */
90typedef struct EGG
91{
92 int frame; /* animation frame number */
93 int part_count; /* number of active particles */
94 int part_num; /* particle ID counter */
95 EGG_PARTICLE *part; /* list of particle instances */
96 EGG_TYPE *type; /* list of particle types */
97 EGG_VARIABLE *var; /* list of global variables */
98} EGG;
99
100
101
102/* script loading functions */
103EGG *load_egg(char *filename, char *error);
104EGG *use_egg(void *data, int length, char *error);
105
106/* script unloading function */
107void destroy_egg(EGG *egg);
108
109/* script interpreter */
110int update_egg(EGG *egg, char *error);
111
112/* renders the current animation state into an Allegro bitmap */
113void lay_egg(EGG *egg, struct BITMAP *bmp);
114
115/* internal utility functions */
116double evaluate(char *equation, int *error, double (*variable)(char *name));
117
118int process_egg_cmd(EGG *egg, EGG_PARTICLE *part, EGG_PARTICLE *other, EGG_COMMAND *cmd, int init, int set, char *error);
119void destroy_egg_cmd(EGG_COMMAND *cmd);
120
121double get_egg_variable(EGG_PARTICLE *part, EGG_PARTICLE *other, EGG *egg, char *name);
122void set_egg_variable(EGG_PARTICLE *part, EGG_PARTICLE *other, EGG *egg, char *name, double value);
123
124
125
126#endif /* __EGG_H__ */
127