-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprojectile.h
executable file
·93 lines (67 loc) · 2.19 KB
/
projectile.h
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
89
90
91
92
93
/*
* Hostile Takeover:
* CS248 Final Project, Fall 2004
*
* Written by Jonathan Reeves
*
* A simple 3D video game demonstrating the use of OpenGL for graphics
* rendering with a number of advanced techniques and optimizations to make
* it interesting. See the README file which came with this package for more
* details. It also includes a list of sources which were consulted while
* building this software package.
*
*/
#ifndef __PROJECTILE_H__
#define __PROJECTILE_H__
#include "vector.h"
#include "aiflock.h"
#define MAX_PROJECTILES 20 /* not actually using this yet */
#define PROJ_SPEED 0.9
#define PROJECTILE_RANGE 80
enum proj_id { /* in case we want to branch out at any time */
P_LASER,
P_BULLET,
P_ROCKET
};
typedef struct {
vector_t position;
vector_t velocity;
float speed;
float traveled;
float radius;
int pid;
} projectile_t;
/* doubly linked list of all projectiles */
typedef struct PROJ_NODE{
projectile_t *proj;
struct PROJ_NODE *next;
struct PROJ_NODE *prev;
} proj_node_t;
/* forward must be a unit vector, pid is who sent the projectile */
/* forward is direction, position is starting position */
projectile_t *ProjectileNew(vector_t *forward, vector_t *position,
float speed, int pid);
void ProjectileDestroy(projectile_t *proj);
void ProjectileInit(projectile_t *proj);
void ProjectileDraw(projectile_t *proj);
void ProjectileUpdate(projectile_t *proj);
/* linked list-related stuff */
#define PLISTFIRST(N) ((N)->next)
#define PLISTNEXT(N) ((N)->next)
#define PLISTLAST(N) ((N)->prev)
#define PLISTPREV(N) ((N)->prev)
#define PLISTNIL(N) (N)
proj_node_t *PListNew(void);
void PListDraw(proj_node_t *node);
void PListUpdate(proj_node_t *node, player_t *me, aiflock_t *enemies[],
int nFlocks);
void PListInsertBefore(proj_node_t *node, projectile_t *proj);
void PListInsertAfter(proj_node_t *node, projectile_t *proj);
void PListAppend(proj_node_t *node, projectile_t *proj);
void PListPrepend(proj_node_t *node, projectile_t *proj);
void PListDeleteNode(proj_node_t *node);
int PListEmpty(proj_node_t *node);
void PListFree(proj_node_t *node);
projectile_t *PListGetProjectile(proj_node_t *node);
#endif