diff --git a/gfx/cirnobg.png b/gfx/cirnobg.png index 77001dda..053113b8 100644 Binary files a/gfx/cirnobg.png and b/gfx/cirnobg.png differ diff --git a/gfx/items/bullet_point.png b/gfx/items/bullet_point.png new file mode 100644 index 00000000..5586c574 Binary files /dev/null and b/gfx/items/bullet_point.png differ diff --git a/gfx/items/bullet_point.svg b/gfx/items/bullet_point.svg new file mode 100644 index 00000000..8c009323 --- /dev/null +++ b/gfx/items/bullet_point.svg @@ -0,0 +1,157 @@ + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/gfx/items/power.svg b/gfx/items/power.svg index 57594a30..b6917818 100644 --- a/gfx/items/power.svg +++ b/gfx/items/power.svg @@ -16,7 +16,7 @@ version="1.1" inkscape:version="0.48.1 r9760" sodipodi:docname="power.svg" - inkscape:export-filename="/home/laochailan/src/taisei/gfx/items/point.png" + inkscape:export-filename="/home/laochailan/power.png" inkscape:export-xdpi="6.1964884" inkscape:export-ydpi="6.1964884"> @@ -73,8 +73,8 @@ inkscape:pageopacity="0" inkscape:pageshadow="2" inkscape:zoom="0.35" - inkscape:cx="19.603278" - inkscape:cy="107.92439" + inkscape:cx="-99.396394" + inkscape:cy="60.585693" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="false" @@ -112,7 +112,7 @@ height="232.38969" width="232.38969" id="rect3813" - style="fill:#001697;fill-opacity:1;stroke:none" /> + style="fill:#970d00;fill-opacity:1;stroke:none" /> - - - - + sodipodi:nodetypes="ssssssscss" /> diff --git a/gfx/laserline.png b/gfx/laserline.png deleted file mode 100644 index e81a7e16..00000000 Binary files a/gfx/laserline.png and /dev/null differ diff --git a/gfx/laserline.svg b/gfx/laserline.svg deleted file mode 100644 index 93554a3c..00000000 --- a/gfx/laserline.svg +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/src/boss.c b/src/boss.c index c3bdf4ed..8382df13 100644 --- a/src/boss.c +++ b/src/boss.c @@ -131,11 +131,18 @@ void process_boss(Boss *boss) { void boss_death(Boss **boss) { free_boss(*boss); *boss = NULL; - delete_projectiles(&global.projs); + + Projectile *p; + for(p = global.projs; p; p = p->next) + if(p->type == FairyProj) + p->type = DeadProj; + delete_lasers(&global.lasers); } void free_boss(Boss *boss) { + del_ref(boss); + free(boss->name); int i; for(i = 0; i < boss->acount; i++) diff --git a/src/boss.h b/src/boss.h index 345d9967..3bcda440 100644 --- a/src/boss.h +++ b/src/boss.h @@ -44,19 +44,20 @@ typedef struct Attack { } Attack; typedef struct Boss { - char *name; - Attack *attacks; Attack *current; - int acount; - - Animation *ani; - int anirow; complex pos; complex pos0; int time0; + char *name; + + int acount; + + Animation *ani; + int anirow; + int dmg; } Boss; diff --git a/src/enemy.c b/src/enemy.c index 4fd5b1a5..195537bf 100644 --- a/src/enemy.c +++ b/src/enemy.c @@ -43,6 +43,8 @@ void create_enemy(Enemy **enemies, EnemyDrawRule draw_rule, EnemyLogicRule logic void _delete_enemy(void **enemies, void* enemy) { ((Enemy* )enemy)->logic_rule(enemy, EVENT_DEATH); + del_ref(enemy); + delete_element((void **)enemies, enemy); } diff --git a/src/enemy.h b/src/enemy.h index 86fa0e04..32a29335 100644 --- a/src/enemy.h +++ b/src/enemy.h @@ -28,11 +28,11 @@ typedef struct Enemy { struct Enemy *next; struct Enemy *prev; - long birthtime; - complex pos; complex pos0; + long birthtime; + int dir; // TODO: deprecate those int moving; diff --git a/src/font.c b/src/font.c index 3758249f..34f20a6f 100644 --- a/src/font.c +++ b/src/font.c @@ -31,7 +31,7 @@ Texture *load_text(const char *text, TTF_Font *font) { void draw_text(const char *text, int x, int y, TTF_Font *font) { char *nl; - char *buf = malloc(strlen(text)); + char *buf = malloc(strlen(text)+1); strcpy(buf, text); if((nl = strchr(buf, '\n')) != NULL && strlen(nl) > 1) { diff --git a/src/global.h b/src/global.h index 420ef155..ebc39411 100644 --- a/src/global.h +++ b/src/global.h @@ -18,6 +18,7 @@ #include "laser.h" #include "shader.h" #include "dialog.h" +#include "list.h" enum { SCREEN_W = 800, @@ -33,6 +34,8 @@ enum { SNDSRC_COUNT = 30, + ACTION_DESTROY, + EVENT_DEATH = -8999, EVENT_BIRTH, @@ -48,6 +51,8 @@ typedef struct { Item *items; Laser *lasers; + Projectile *particles; + int frames; int lasttime; int timer; @@ -70,6 +75,8 @@ typedef struct { ALuint sndsrc[SNDSRC_COUNT]; + RefArray refs; // for super extra OOP-tardness: references. the cool way. + int game_over; int points; diff --git a/src/item.c b/src/item.c index 3c8039a9..9755dfed 100644 --- a/src/item.c +++ b/src/item.c @@ -10,7 +10,7 @@ #include "global.h" #include "list.h" -void create_item(complex pos, complex v, Type type) { +Item *create_item(complex pos, complex v, Type type) { Item *i = create_element((void **)&global.items, sizeof(Item)); i->pos = pos; i->pos0 = pos; @@ -18,6 +18,8 @@ void create_item(complex pos, complex v, Type type) { i->birthtime = global.frames; i->auto_collect = 0; i->type = type; + + return i; } @@ -28,23 +30,26 @@ void delete_item(Item *item) { void draw_items() { Item *p; Texture *tex = NULL; - for(p = global.items; p; p = p->next){ - switch(p->type){ - case Power: - tex = get_tex("items/power"); - break; - case Point: - tex = get_tex("items/point"); - break; - case Life: - tex = get_tex("items/life"); - break; - case Bomb: - tex = get_tex("items/bomb"); - break; - default: - break; - } + for(p = global.items; p; p = p->next) { + switch(p->type){ + case Power: + tex = get_tex("items/power"); + break; + case Point: + tex = get_tex("items/point"); + break; + case Life: + tex = get_tex("items/life"); + break; + case Bomb: + tex = get_tex("items/bomb"); + break; + case BPoint: + tex = get_tex("items/bullet_point"); + break; + default: + break; + } draw_texture_p(creal(p->pos), cimag(p->pos), tex); } } @@ -58,7 +63,7 @@ void move_item(Item *i) { complex lim = 0 + 2I; if(i->auto_collect) - i->pos -= 7*cexp(I*carg(i->pos - global.plr.pos)); + i->pos -= (7+i->auto_collect)*cexp(I*carg(i->pos - global.plr.pos)); else i->pos = i->pos0 + log(t/5.0 + 1)*5*(i->v + lim) + lim*t; } @@ -82,6 +87,9 @@ void process_items() { case Point: global.points += 100; break; + case BPoint: + global.points += 1; + break; case Life: global.plr.lifes++; break; diff --git a/src/item.h b/src/item.h index 179a60e0..493c777b 100644 --- a/src/item.h +++ b/src/item.h @@ -17,6 +17,7 @@ struct Item; typedef enum { Power, Point, + BPoint, Life, Bomb } Type; @@ -35,7 +36,7 @@ typedef struct Item{ complex v; } Item; -void create_item(complex pos, complex v, Type type); +Item *create_item(complex pos, complex v, Type type); void delete_item(Item *item); void draw_items(); void delete_items(); diff --git a/src/list.c b/src/list.c index c9ec32c7..eb1a7e1d 100644 --- a/src/list.c +++ b/src/list.c @@ -9,12 +9,15 @@ #include #include +#include "global.h" typedef struct { void *next; void *prev; } List; +void *_FREEREF; + void *create_element(void **dest, int size) { void *last = *dest; void *e = malloc(size); @@ -33,7 +36,7 @@ void *create_element(void **dest, int size) { return e; } -void delete_element(void **dest, void *e) { +void delete_element(void **dest, void *e) { if(((List *)e)->prev != NULL) ((List *)((List *)e)->prev)->next = ((List *)e)->next; if(((List *)e)->next != NULL) @@ -52,7 +55,36 @@ void delete_all_elements(void **dest, void (callback)(void **, void *)) { tmp = e; e = ((List *)e)->next; callback(dest, tmp); - } + } *dest = NULL; } + +int add_ref(void *ptr) { + int i; + + for(i = 0; i < global.refs.count; i++) { + if(global.refs.ptrs[i] == FREEREF) { + global.refs.ptrs[i] = ptr; + return i; + } + } + + global.refs.ptrs = realloc(global.refs.ptrs, (++global.refs.count)*sizeof(void *)); + global.refs.ptrs[global.refs.count - 1] = ptr; + + return global.refs.count - 1; +} + +void del_ref(void *ptr) { + int i; + + for(i = 0; i < global.refs.count; i++) + if(global.refs.ptrs[i] == ptr) + global.refs.ptrs[i] = NULL; +} + +void free_ref(int i) { + if(i >= 0) + REF(i) = FREEREF; +} \ No newline at end of file diff --git a/src/list.h b/src/list.h index bc93ca60..e116db0d 100644 --- a/src/list.h +++ b/src/list.h @@ -16,4 +16,15 @@ void *create_element(void **dest, int size); void delete_element(void **dest, void *e); void delete_all_elements(void **dest, void (callback)(void **, void *)); +typedef struct { + void **ptrs; + int count; +} RefArray; + +extern void *_FREEREF; +#define FREEREF &_FREEREF +#define REF(p) (global.refs.ptrs[(int)p]) +int add_ref(void *ptr); +void del_ref(void *ptr); +void free_ref(int i); #endif \ No newline at end of file diff --git a/src/player.c b/src/player.c index 2ff47313..e817fb16 100644 --- a/src/player.c +++ b/src/player.c @@ -106,8 +106,16 @@ void player_logic(Player* plr) { float a = 1; if(plr->focus > 0) a = 0.2; - if(plr->shot == YoumuHoming && !(global.frames % 7)) - create_projectile("hghost", plr->pos, NULL, youmu_homing, a*cexp(I*rand()))->type = PlrProj; + if(plr->shot == YoumuHoming && !(global.frames % 7)) { + complex ref = -1; + if(global.boss != NULL) + ref = add_ref(global.boss); + else if(global.enemies != NULL) + ref = add_ref(global.enemies); + + if(ref != -1) + create_projectile("hghost", plr->pos, NULL, youmu_homing, a*cexp(I*rand()), ref)->type = PlrProj; + } } if(plr->focus < 0 || (plr->focus > 0 && plr->focus < 30)) diff --git a/src/plrmodes.c b/src/plrmodes.c index 0bbf45a0..d9961514 100644 --- a/src/plrmodes.c +++ b/src/plrmodes.c @@ -34,20 +34,21 @@ void youmu_opposite_logic(Enemy *e, int t) { e->pos0 = e->pos + plr->pos; } -void youmu_homing(Projectile *p, int t) { // a[0]: velocity - p->angle = t/30.0; +int youmu_homing(Projectile *p, int t) { // a[0]: velocity, a[1]: target, a[2]: old velocity +// p->angle = t/30.0; + if(t == EVENT_DEATH) { + free_ref(p->args[1]); + } - complex tv = 0; + complex tv = p->args[2]; + if(REF(p->args[1]) != NULL) + tv = cexp(I*carg(((Enemy *)REF(p->args[1]))->pos - p->pos)); - if(global.enemies != NULL) - tv = cexp(I*carg(global.enemies[0].pos - p->pos));; - if(global.boss != NULL) - tv = cexp(I*carg(global.boss->pos - p->pos));; - - if(t > 150 || tv == 0) - tv = - ((rand()%3)-1)/2.0 - 0.5I; + + p->args[2] = tv; - p->pos += p->args[0]*log(t + 1) + tv*t/15.0; + p->pos += p->args[0]*log(t + 1) + tv*t*t/300.0; p->pos0 = p->pos; + return 1; } \ No newline at end of file diff --git a/src/plrmodes.h b/src/plrmodes.h index 73f90c2b..b8d2f3cc 100644 --- a/src/plrmodes.h +++ b/src/plrmodes.h @@ -14,6 +14,6 @@ void youmu_opposite_draw(Enemy *e, int t); void youmu_opposite_logic(Enemy *e, int t); -void youmu_homing(Projectile *p, int t); +int youmu_homing(Projectile *p, int t); #endif \ No newline at end of file diff --git a/src/projectile.c b/src/projectile.c index 747fed36..76b05880 100644 --- a/src/projectile.c +++ b/src/projectile.c @@ -26,39 +26,82 @@ inline Color *rgb(float r, float g, float b) { return rgba(r, g, b, 1.0); } -Projectile *create_projectile_d(Projectile **dest, char *name, complex pos, Color *clr, - ProjRule rule, complex args, ...) { +Projectile *create_particle(char *name, complex pos, Color *clr, ProjDRule draw, ProjRule rule, complex arg1, ...) { + va_list ap; + complex a[4]; + int i; + + memset(a, 0, sizeof(a)); + + va_start(ap, arg1); + + a[0] = arg1; + for(i = 1; i < 4; i++) { + a[i] = va_arg(ap, complex); + } + va_end(ap); + + return create_projectile_dv(&global.particles, name, pos, clr, draw, rule, a); +} + +Projectile *create_projectile(char *name, complex pos, Color *clr, ProjRule rule, complex arg1, ...) { + va_list ap; + complex a[4], ar; + int i; + + memset(a, 0, sizeof(a)); + + va_start(ap, arg1); + + a[0] = arg1; + for(i = 1; i < 4; i++) { + a[i] = va_arg(ap, complex); + } + va_end(ap); + + return create_projectile_dv(&global.projs, name, pos, clr, ProjDraw, rule, a); +} + +Projectile *create_projectile_dv(Projectile **dest, char *name, complex pos, Color *clr, + ProjDRule draw, ProjRule rule, complex *args) { Projectile *p = create_element((void **)dest, sizeof(Projectile)); char buf[128]; - strcpy(buf, "proj/"); - strcat(buf, name); + if(name[0] == '!') + strncpy(buf, name+1, sizeof(buf)); + else { + strcpy(buf, "proj/"); + strcat(buf, name); + } p->birthtime = global.frames; p->pos = pos; p->pos0 = pos; p->angle = 0; p->rule = rule; + p->draw = draw; p->tex = get_tex(buf); p->type = FairyProj; p->clr = clr; p->parent = NULL; + + memcpy(p->args, args, sizeof(p->args)); - va_list ap; - int i; - va_start(ap, args); - for(i = 0; i < 4 && args; i++) { - p->args[i++] = args; - args = va_arg(ap, complex); + if(dest != &global.particles && clr != NULL) { + Color *color = rgba(clr->r, clr->g, clr->b, clr->a); + + create_particle(name, pos, color, Shrink, bullet_flare_move, add_ref(p)); } - va_end(ap); - return p; } void _delete_projectile(void **projs, void *proj) { - free(((Projectile*)proj)->clr); + ((Projectile *)proj)->rule(proj, EVENT_DEATH); + + if(((Projectile*)proj)->clr) + free(((Projectile*)proj)->clr); + del_ref(proj); delete_element(projs, proj); } @@ -99,42 +142,35 @@ int collision_projectile(Projectile *p) { void draw_projectiles(Projectile *projs) { Projectile *proj; - GLuint shader = get_shader("bullet_color"); - glUseProgramObjectARB(shader); - - for(proj = projs; proj; proj = proj->next) { - if(proj->clr == NULL) - glUseProgramObjectARB(0); - - glUniform4fv(glGetUniformLocation(shader, "color"), 1, (GLfloat *)proj->clr); - - glPushMatrix(); - glTranslatef(creal(proj->pos), cimag(proj->pos), 0); - glRotatef(proj->angle*180/M_PI+90, 0, 0, 1); - - draw_texture_p(0,0, proj->tex); - glPopMatrix(); - - if(proj->clr == NULL) - glUseProgramObjectARB(shader); - } - glUseProgramObjectARB(0); + for(proj = projs; proj; proj = proj->next) + proj->draw(proj, global.frames - proj->birthtime); } -void process_projectiles(Projectile **projs, short collision) { +void process_projectiles(Projectile **projs, char collision) { Projectile *proj = *projs, *del = NULL; + + char killed = 0; + char col = 0; + int action; while(proj != NULL) { - proj->rule(proj, global.frames - proj->birthtime); + action = proj->rule(proj, global.frames - proj->birthtime); - int v = 0; + if(proj->type == DeadProj && killed < 2) { + killed++; + action = ACTION_DESTROY; + create_particle("!lasercurve", proj->pos, NULL, Fade, timeout, 20); + create_item(proj->pos, 0, BPoint)->auto_collect = 10; + } + if(collision) - v = collision_projectile(proj); + col = collision_projectile(proj); - if(v == 1 && (global.frames - abs(global.plr.recovery)) >= 0) + if(col == 1 && (global.frames - abs(global.plr.recovery)) >= 0) plr_death(&global.plr); - if(v || creal(proj->pos) + proj->tex->w/2 < 0 || creal(proj->pos) - proj->tex->w/2 > VIEWPORT_W - || cimag(proj->pos) + proj->tex->h/2 < 0 || cimag(proj->pos) - proj->tex->h/2 > VIEWPORT_H) { + if(action == ACTION_DESTROY || col + || creal(proj->pos) + proj->tex->w/2 < 0 || creal(proj->pos) - proj->tex->w/2 > VIEWPORT_W + || cimag(proj->pos) + proj->tex->h/2 < 0 || cimag(proj->pos) - proj->tex->h/2 > VIEWPORT_H) { del = proj; proj = proj->next; delete_projectile(projs, del); @@ -145,7 +181,73 @@ void process_projectiles(Projectile **projs, short collision) { } } -void linear(Projectile *p, int t) { // sure is physics in here; a[0]: velocity +int linear(Projectile *p, int t) { // sure is physics in here; a[0]: velocity p->angle = carg(p->args[0]); p->pos = p->pos0 + p->args[0]*t; + + return 1; } + +void ProjDraw(Projectile *proj, int t) { + if(proj->clr != NULL) { + GLuint shader = get_shader("bullet_color"); + glUseProgramObjectARB(shader); + + glUniform4fv(glGetUniformLocation(shader, "color"), 1, (GLfloat *)proj->clr); + } + + glPushMatrix(); + glTranslatef(creal(proj->pos), cimag(proj->pos), 0); + glRotatef(proj->angle*180/M_PI+90, 0, 0, 1); + + draw_texture_p(0,0, proj->tex); + glPopMatrix(); + + glUseProgramObjectARB(0); +} + +void Shrink(Projectile *p, int t) { + if(p->clr != NULL) { + GLuint shader = get_shader("bullet_color"); + glUseProgramObjectARB(shader); + glUniform4fv(glGetUniformLocation(shader, "color"), 1, (GLfloat *)p->clr); + } + + glPushMatrix(); + float s = 2.0-t/8.0; + glTranslatef(creal(p->pos), cimag(p->pos), 0); + glRotatef(p->angle, 0, 0, 1); + glScalef(s, s, 1); + draw_texture_p(0, 0, p->tex); + glPopMatrix(); + + glUseProgramObjectARB(0); +} + +int bullet_flare_move(Projectile *p, int t) { + int i; + + if(t > 16 || REF(p->args[0]) == NULL) { + free_ref(p->args[0]); + return ACTION_DESTROY; + } + + + p->pos = ((Projectile *) REF(p->args[0]))->pos; + p->angle = ((Projectile *) REF(p->args[0]))->angle; + + return 1; +} + +void Fade(Projectile *p, int t) { + glColor4f(1,1,1,(float)t/p->args[0]); + draw_texture_p(creal(p->pos), cimag(p->pos), p->tex); + glColor4f(1,1,1,1); +} + +int timeout(Projectile *p, int t) { + if(t >= creal(p->args[0])) + return ACTION_DESTROY; + + return 1; +} \ No newline at end of file diff --git a/src/projectile.h b/src/projectile.h index dc1dffdb..5862e07c 100644 --- a/src/projectile.h +++ b/src/projectile.h @@ -21,24 +21,26 @@ typedef struct { } Color; struct Projectile; -typedef void (*ProjRule)(struct Projectile *p, int t); +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; - long birthtime; - complex pos; complex pos0; + long birthtime; + float angle; void *parent; ProjRule rule; + ProjDRule draw; Texture *tex; - enum { PlrProj, FairyProj } type; + enum { PlrProj, FairyProj, DeadProj } type; Color *clr; @@ -51,14 +53,23 @@ Color *rgba(float r, float g, float b, float a); inline Color *rgb(float r, float g, float b); -#define create_particle(name, pos, clr, rule, args) (create_projectile_d(&global.particles, name, pos, clr, rule, args)) -#define create_projectile(name, pos, clr, rule, args) (create_projectile_d(&global.projs, name, pos, clr, rule, args)) -Projectile *create_projectile_d(Projectile **dest, char *name, complex pos, Color *clr, ProjRule rule, complex args, ...); +Projectile *create_particle(char *name, complex pos, Color *clr, ProjDRule draw, ProjRule rule, complex arg1, ...); +Projectile *create_projectile(char *name, complex pos, Color *clr, ProjRule rule, complex arg1, ...); +Projectile *create_projectile_dv(Projectile **dest, char *name, complex pos, Color *clr, ProjDRule draw, ProjRule rule, complex *args); void delete_projectile(Projectile **dest, Projectile *proj); void delete_projectiles(Projectile **dest); void draw_projectiles(Projectile *projs); int collision_projectile(Projectile *p); -void process_projectiles(Projectile **projs, short collision); +void process_projectiles(Projectile **projs, char collision); -void linear(Projectile *p, int t); +Projectile *get_proj(Projectile *hay, int birthtime); + +int linear(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); #endif \ No newline at end of file diff --git a/src/shader.c b/src/shader.c index daff44f7..628370d0 100644 --- a/src/shader.c +++ b/src/shader.c @@ -12,7 +12,7 @@ #include void print_info_log(GLuint shader) { - int len, alen; + int len = 0, alen = 0; glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &len); if(len > 1) { diff --git a/src/stage.c b/src/stage.c index 73d2f251..bae01199 100644 --- a/src/stage.c +++ b/src/stage.c @@ -11,14 +11,15 @@ #include "global.h" #include "font.h" -SDL_Event event; void stage_start() { init_player(&global.plr, Youmu, YoumuHoming); global.timer = 0; } -void stage_input() { +void stage_input() { + SDL_Event event; + memset(&event, 0, sizeof(event)); while(SDL_PollEvent(&event)) { if(event.type == SDL_KEYDOWN) { switch(event.key.keysym.sym) { @@ -127,11 +128,13 @@ void stage_draw() { draw_projectiles(global.projs); draw_enemies(global.enemies); draw_items(); - draw_lasers(); + draw_lasers(); if(global.boss) draw_boss(global.boss); + draw_projectiles(global.particles); + if(global.dialog) draw_dialog(global.dialog); @@ -170,7 +173,7 @@ void apply_bg_shaders() { glPushMatrix(); glTranslatef(-global.rtt.nw+VIEWPORT_W,-global.rtt.nh+VIEWPORT_H,0); - + glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, global.rtt.tex); glBegin(GL_QUADS); @@ -192,6 +195,7 @@ void stage_logic() { process_projectiles(&global.projs, True); process_items(); process_lasers(); + process_projectiles(&global.particles, False); if(global.boss) { process_boss(global.boss); diff --git a/src/stages/stage0.c b/src/stages/stage0.c index 16b3e440..754d1907 100644 --- a/src/stages/stage0.c +++ b/src/stages/stage0.c @@ -34,6 +34,7 @@ Dialog *test_dialog() { dadd_msg(d, Left, "Hello"); dadd_msg(d, Right, "Hello you"); dadd_msg(d, Right, "Uhm ... who are you?\nNew line.\nAnother longer line."); + dadd_msg(d, Left, "idk"); return d; } @@ -130,8 +131,11 @@ complex lolsin(Laser *l, float t) { return pos; } -void cirno_pfreeze_frogs(Projectile *p, int t) { - int boss_t = (global.frames - *((int *)p->parent)) % 320; +int cirno_pfreeze_frogs(Projectile *p, int t) { + if(*((Boss**)p->parent) == NULL || (*(Boss**)p->parent)->current == NULL) + return 1; + + int boss_t = (global.frames - (*(Boss**)p->parent)->current->starttime) % 320; if(boss_t < 110) linear(p, t); @@ -147,7 +151,8 @@ void cirno_pfreeze_frogs(Projectile *p, int t) { if(t > 240) linear(p, t-240); - + + return 1; } void cirno_perfect_freeze(Boss *c, int time) { @@ -160,7 +165,7 @@ void cirno_perfect_freeze(Boss *c, int time) { } if(time > 10 && time < 80) - create_projectile("ball", c->pos, rgb(rand()/(float)RAND_MAX, rand()/(float)RAND_MAX, rand()/(float)RAND_MAX), cirno_pfreeze_frogs, 4*cexp(I*rand()))->parent=&c->current->starttime; + create_projectile("ball", c->pos, rgb(rand()/(float)RAND_MAX, rand()/(float)RAND_MAX, rand()/(float)RAND_MAX), cirno_pfreeze_frogs, 4*cexp(I*rand()))->parent=&global.boss; if(time > 160 && time < 220 && !(time % 7)) { create_projectile("rice", c->pos + 60, rgb(0.3, 0.4, 0.9), linear, 5*cexp(I*carg(global.plr.pos - c->pos))); create_projectile("rice", c->pos - 60, rgb(0.3, 0.4, 0.9), linear, 5*cexp(I*carg(global.plr.pos - c->pos))); @@ -169,13 +174,12 @@ void cirno_perfect_freeze(Boss *c, int time) { } void cirno_pfreeze_bg(Boss *c, int time) { - glColor4f(1,1,1,1); - fill_screen(time/700.0, time/700.0, 2, "cirnobg"); - glColor4f(1,1,1,0.5); - fill_screen(time/700.0, time/700.0+0.5, 2, "cirnobg"); + glColor4f(0.5,0.5,0.5,1); + fill_screen(time/700.0, time/700.0, 1, "cirnobg"); + glColor4f(0.7,0.7,0.7,0.5); + fill_screen(-time/700.0 + 0.5, time/700.0+0.5, 0.4, "cirnobg"); fill_screen(0, -time/100.0, 0, "snowlayer"); -// draw_texture(VIEWPORT_W/2,VIEWPORT_H/2, "snowlayer"); glColor4f(1,1,1,1); } diff --git a/src/texture.c b/src/texture.c index ea2fce0b..395d80ce 100644 --- a/src/texture.c +++ b/src/texture.c @@ -49,7 +49,7 @@ void recurse_dir(char *path) { void load_resources() { printf("load_resources():\n"); - char *path = malloc(sizeof(FILE_PREFIX)+4); + char *path = malloc(sizeof(FILE_PREFIX)+7); printf("- textures:\n"); strcpy(path, FILE_PREFIX);