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
|
2017-02-11 05:52:08 +02:00
|
|
|
* See COPYING for further information.
|
2011-03-05 19:03:32 +01:00
|
|
|
* ---
|
2017-09-12 04:28:15 +03:00
|
|
|
* Copyright (c) 2011-2017, Lukas Weber <laochailan@web.de>.
|
|
|
|
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
|
2010-10-12 10:55:23 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PROJECTILE
|
|
|
|
#define PROJECTILE
|
|
|
|
|
2017-03-06 02:25:59 +02:00
|
|
|
#include "util.h"
|
2011-06-24 19:16:05 +02:00
|
|
|
#include "resource/texture.h"
|
2017-02-26 22:59:51 +02:00
|
|
|
#include "color.h"
|
2011-06-13 18:48:36 +02:00
|
|
|
|
2017-02-11 05:52:08 +02:00
|
|
|
#include <stdbool.h>
|
2017-02-07 20:34:55 +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);
|
|
|
|
|
2011-07-06 14:33:53 +02:00
|
|
|
typedef enum {
|
|
|
|
FairyProj,
|
|
|
|
DeadProj,
|
|
|
|
Particle,
|
|
|
|
PlrProj
|
|
|
|
} ProjType;
|
|
|
|
|
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;
|
2017-02-11 05:52:08 +02:00
|
|
|
|
2011-03-18 19:03:06 +01:00
|
|
|
complex pos;
|
|
|
|
complex pos0;
|
2017-02-11 05:52:08 +02:00
|
|
|
|
2011-05-13 19:03:02 +02:00
|
|
|
long birthtime;
|
2017-02-11 05:52:08 +02:00
|
|
|
|
2011-03-18 19:03:06 +01:00
|
|
|
float angle;
|
2017-02-11 05:52:08 +02:00
|
|
|
|
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;
|
2017-02-11 05:52:08 +02:00
|
|
|
|
2011-07-06 14:33:53 +02:00
|
|
|
ProjType type;
|
2017-02-11 05:52:08 +02:00
|
|
|
|
2017-02-26 22:59:51 +02:00
|
|
|
Color clr;
|
2017-02-11 05:52:08 +02:00
|
|
|
|
2011-05-21 15:02:19 +02:00
|
|
|
complex args[RULE_ARGC];
|
2012-08-12 22:29:10 +03:00
|
|
|
int grazed;
|
2017-09-06 00:02:40 +03:00
|
|
|
|
|
|
|
int maxviewportdist;
|
2010-10-12 10:55:23 +02:00
|
|
|
} Projectile;
|
|
|
|
|
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)
|
|
|
|
|
2017-02-26 22:59:51 +02:00
|
|
|
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);
|
2017-02-11 05:52:08 +02:00
|
|
|
void process_projectiles(Projectile **projs, bool collision);
|
2011-05-13 19:03:02 +02:00
|
|
|
|
|
|
|
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-06-28 19:23:02 +02:00
|
|
|
int asymptotic(Projectile *p, int t);
|
2011-05-13 19:03:02 +02:00
|
|
|
void ProjDraw(Projectile *p, int t);
|
2017-03-31 14:09:57 +02:00
|
|
|
void _ProjDraw(Projectile *p, int t);
|
2011-06-29 17:01:03 +02:00
|
|
|
void PartDraw(Projectile *p, int t);
|
2011-05-13 19:03:02 +02:00
|
|
|
|
2017-04-20 18:37:46 +02:00
|
|
|
void ProjDrawNoFlareAdd(Projectile *p, int t);
|
2012-07-18 23:12:31 +02:00
|
|
|
void ProjDrawAdd(Projectile *p, int t);
|
2012-07-25 15:32:37 +02:00
|
|
|
void ProjDrawSub(Projectile *p, int t);
|
2012-07-18 23:12:31 +02:00
|
|
|
|
2011-06-28 19:23:02 +02:00
|
|
|
void Blast(Projectile *p, int t);
|
|
|
|
|
2011-05-13 19:03:02 +02:00
|
|
|
void Shrink(Projectile *p, int t);
|
2012-08-01 17:32:11 +02:00
|
|
|
void ShrinkAdd(Projectile *p, int t);
|
2011-06-28 19:23:02 +02:00
|
|
|
void GrowFade(Projectile *p, int t);
|
2012-07-30 17:57:38 +02:00
|
|
|
void GrowFadeAdd(Projectile *p, int t);
|
2011-05-13 19:03:02 +02:00
|
|
|
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);
|
2012-08-01 17:32:11 +02:00
|
|
|
void FadeAdd(Projectile *p, int t);
|
2011-05-13 19:03:02 +02:00
|
|
|
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);
|
|
|
|
|
2011-08-28 10:57:45 +02:00
|
|
|
void Petal(Projectile *p, int t);
|
|
|
|
void petal_explosion(int n, complex pos);
|
|
|
|
|
2017-03-11 05:41:57 +02:00
|
|
|
void projectiles_preload(void);
|
|
|
|
|
2012-07-24 21:44:58 +03:00
|
|
|
#endif
|