2010-10-12 10:55:23 +02:00
|
|
|
/*
|
2011-03-05 19:03:32 +01:00
|
|
|
* This software is licensed under the terms of the MIT-License
|
|
|
|
* See COPYING for further information.
|
|
|
|
* ---
|
|
|
|
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
|
2010-10-12 10:55:23 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PROJECTILE
|
|
|
|
#define PROJECTILE
|
|
|
|
|
2011-03-18 19:03:06 +01:00
|
|
|
#include <complex.h>
|
2011-06-24 19:16:05 +02:00
|
|
|
#include "resource/texture.h"
|
2011-06-13 18:48:36 +02:00
|
|
|
|
2011-04-24 15:39:17 +02:00
|
|
|
typedef struct {
|
|
|
|
float r;
|
|
|
|
float g;
|
|
|
|
float b;
|
|
|
|
float a;
|
2011-04-26 16:55:18 +02:00
|
|
|
} Color;
|
2011-04-24 15:39:17 +02:00
|
|
|
|
2011-05-21 15:02:19 +02:00
|
|
|
enum {
|
|
|
|
RULE_ARGC = 4
|
|
|
|
};
|
|
|
|
|
2011-06-26 13:45:27 +02:00
|
|
|
struct Projectile;
|
|
|
|
typedef int (*ProjRule)(struct Projectile *p, int t);
|
|
|
|
typedef void (*ProjDRule)(struct Projectile *p, int t);
|
|
|
|
|
2010-10-12 10:55:23 +02:00
|
|
|
typedef struct Projectile {
|
2010-10-27 19:51:49 +02:00
|
|
|
struct Projectile *next;
|
|
|
|
struct Projectile *prev;
|
|
|
|
|
2011-03-18 19:03:06 +01:00
|
|
|
complex pos;
|
|
|
|
complex pos0;
|
2010-10-12 10:55:23 +02:00
|
|
|
|
2011-05-13 19:03:02 +02:00
|
|
|
long birthtime;
|
|
|
|
|
2011-03-18 19:03:06 +01:00
|
|
|
float angle;
|
2010-10-12 10:55:23 +02:00
|
|
|
|
|
|
|
ProjRule rule;
|
2011-05-13 19:03:02 +02:00
|
|
|
ProjDRule draw;
|
2010-10-13 12:38:38 +02:00
|
|
|
Texture *tex;
|
2010-10-12 10:55:23 +02:00
|
|
|
|
2011-05-21 15:02:19 +02:00
|
|
|
enum { PlrProj, FairyProj, DeadProj, Particle } type;
|
2010-10-17 10:39:07 +02:00
|
|
|
|
2011-04-26 16:55:18 +02:00
|
|
|
Color *clr;
|
2010-10-24 14:44:48 +02:00
|
|
|
|
2011-05-21 15:02:19 +02:00
|
|
|
complex args[RULE_ARGC];
|
2010-10-12 10:55:23 +02:00
|
|
|
} Projectile;
|
|
|
|
|
2011-04-26 16:55:18 +02:00
|
|
|
Color *rgba(float r, float g, float b, float a);
|
|
|
|
inline Color *rgb(float r, float g, float b);
|
|
|
|
|
2011-06-26 13:45:27 +02:00
|
|
|
#define create_particle3c(n,p,c,d,r,a1,a2,a3) create_particle4c(n,p,c,d,r,a1,a2,a3,0)
|
|
|
|
#define create_particle2c(n,p,c,d,r,a1,a2) create_particle4c(n,p,c,d,r,a1,a2,0,0)
|
|
|
|
#define create_particle1c(n,p,c,d,r,a1) create_particle4c(n,p,c,d,r,a1,0,0,0)
|
|
|
|
|
|
|
|
#define create_projectile3c(n,p,c,r,a1,a2,a3) create_projectile4c(n,p,c,r,a1,a2,a3,0)
|
|
|
|
#define create_projectile2c(n,p,c,r,a1,a2) create_projectile4c(n,p,c,r,a1,a2,0,0)
|
|
|
|
#define create_projectile1c(n,p,c,r,a1) create_projectile4c(n,p,c,r,a1,0,0,0)
|
|
|
|
|
|
|
|
Projectile *create_particle4c(char *name, complex pos, Color *clr, ProjDRule draw, ProjRule rule, complex a1, complex a2, complex a3, complex a4);
|
|
|
|
Projectile *create_projectile4c(char *name, complex pos, Color *clr, ProjRule rule, complex a1, complex a2, complex a3, complex a4);
|
|
|
|
Projectile *create_projectile_p(Projectile **dest, Texture *tex, complex pos, Color *clr, ProjDRule draw, ProjRule rule, complex a1, complex a2, complex a3, complex a4);
|
2011-05-06 17:09:43 +02:00
|
|
|
void delete_projectile(Projectile **dest, Projectile *proj);
|
|
|
|
void delete_projectiles(Projectile **dest);
|
|
|
|
void draw_projectiles(Projectile *projs);
|
2011-04-26 16:55:18 +02:00
|
|
|
int collision_projectile(Projectile *p);
|
2011-05-13 19:03:02 +02:00
|
|
|
void process_projectiles(Projectile **projs, char collision);
|
|
|
|
|
|
|
|
Projectile *get_proj(Projectile *hay, int birthtime);
|
|
|
|
|
|
|
|
int linear(Projectile *p, int t);
|
2011-06-27 13:36:35 +02:00
|
|
|
int accelerated(Projectile *p, int t);
|
2011-05-13 19:03:02 +02:00
|
|
|
void ProjDraw(Projectile *p, int t);
|
|
|
|
|
|
|
|
void Shrink(Projectile *p, int t);
|
|
|
|
int bullet_flare_move(Projectile *p, int t);
|
2010-10-12 10:55:23 +02:00
|
|
|
|
2011-05-13 19:03:02 +02:00
|
|
|
void Fade(Projectile *p, int t);
|
|
|
|
int timeout(Projectile *p, int t);
|
2011-05-21 15:02:19 +02:00
|
|
|
|
|
|
|
void DeathShrink(Projectile *p, int t);
|
|
|
|
int timeout_linear(Projectile *p, int t);
|
|
|
|
|
2010-10-12 10:55:23 +02:00
|
|
|
#endif
|