taisei/src/projectile.h

86 lines
2.4 KiB
C
Raw Normal View History

/*
* This software is licensed under the terms of the MIT-License
* See COPYING for further information.
* ---
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
*/
#ifndef PROJECTILE
#define PROJECTILE
#include <complex.h>
#include "resource/texture.h"
typedef struct {
float r;
float g;
float b;
float a;
2011-04-26 16:55:18 +02:00
} Color;
enum {
RULE_ARGC = 4
};
struct Projectile;
typedef int (*ProjRule)(struct Projectile *p, int t);
typedef void (*ProjDRule)(struct Projectile *p, int t);
typedef struct Projectile {
struct Projectile *next;
struct Projectile *prev;
complex pos;
complex pos0;
long birthtime;
float angle;
ProjRule rule;
ProjDRule draw;
Texture *tex;
enum { PlrProj, FairyProj, DeadProj, Particle } type;
2011-04-26 16:55:18 +02:00
Color *clr;
complex args[RULE_ARGC];
} 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);
#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);
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);
void process_projectiles(Projectile **projs, char collision);
Projectile *get_proj(Projectile *hay, int birthtime);
int linear(Projectile *p, int t);
int accelerated(Projectile *p, int t);
void ProjDraw(Projectile *p, int t);
void Shrink(Projectile *p, int t);
int bullet_flare_move(Projectile *p, int t);
void Fade(Projectile *p, int t);
int timeout(Projectile *p, int t);
void DeathShrink(Projectile *p, int t);
int timeout_linear(Projectile *p, int t);
#endif