2010-10-12 10:55:23 +02:00
|
|
|
/*
|
2011-03-05 13:44:21 +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
|
|
|
*/
|
|
|
|
|
|
|
|
#include "player.h"
|
|
|
|
|
|
|
|
#include <SDL/SDL.h>
|
|
|
|
#include "projectile.h"
|
|
|
|
#include "global.h"
|
|
|
|
|
|
|
|
void init_player(Player* plr, Character cha) {
|
2011-03-18 19:03:06 +01:00
|
|
|
plr->pos = VIEWPORT_W/2 + I*(VIEWPORT_H-20);
|
2010-10-12 10:55:23 +02:00
|
|
|
|
|
|
|
plr->focus = False;
|
|
|
|
plr->fire = False;
|
|
|
|
plr->moving = False;
|
|
|
|
plr->dir = 0;
|
2010-11-14 13:24:56 +01:00
|
|
|
plr->power = 0;
|
2010-10-12 10:55:23 +02:00
|
|
|
|
|
|
|
plr->cha = cha;
|
|
|
|
|
2011-03-19 16:21:48 +01:00
|
|
|
plr->ani = get_ani("youmu");
|
2010-10-12 10:55:23 +02:00
|
|
|
}
|
|
|
|
|
2010-11-28 12:54:13 +01:00
|
|
|
void player_draw(Player* plr) {
|
2010-10-12 10:55:23 +02:00
|
|
|
glPushMatrix();
|
2011-03-18 19:03:06 +01:00
|
|
|
glTranslatef(creal(plr->pos), cimag(plr->pos), 0);
|
2010-11-28 12:54:13 +01:00
|
|
|
|
|
|
|
if(plr->focus != 0) {
|
|
|
|
glPushMatrix();
|
|
|
|
glRotatef(global.frames*10, 0, 0, 1);
|
2011-03-19 09:11:05 +01:00
|
|
|
glScalef(1, 1, 1);
|
2010-11-28 12:54:13 +01:00
|
|
|
glColor4f(1,1,1,0.2);
|
2011-03-19 16:21:48 +01:00
|
|
|
draw_texture(0, 0, "fairy_circle");
|
2010-11-28 12:54:13 +01:00
|
|
|
glColor4f(1,1,1,1);
|
|
|
|
glPopMatrix();
|
|
|
|
}
|
|
|
|
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
if(plr->dir) {
|
|
|
|
glPushMatrix();
|
|
|
|
glScalef(-1,1,1);
|
|
|
|
}
|
|
|
|
|
2011-03-19 16:21:48 +01:00
|
|
|
draw_animation_p(0, 0, !plr->moving, plr->ani);
|
2010-11-28 12:54:13 +01:00
|
|
|
|
|
|
|
if(plr->dir)
|
|
|
|
glPopMatrix();
|
|
|
|
|
|
|
|
glEnable(GL_CULL_FACE);
|
|
|
|
|
|
|
|
if(plr->focus != 0) {
|
|
|
|
glPushMatrix();
|
|
|
|
glColor4f(1,1,1,fabs((float)plr->focus/30.0f));
|
|
|
|
glRotatef(global.frames, 0, 0, -1);
|
2011-03-19 16:21:48 +01:00
|
|
|
draw_texture(0, 0, "focus");
|
2010-11-28 12:54:13 +01:00
|
|
|
glColor4f(1,1,1,1);
|
|
|
|
glPopMatrix();
|
|
|
|
}
|
|
|
|
|
2010-10-12 10:55:23 +02:00
|
|
|
glPopMatrix();
|
|
|
|
}
|
|
|
|
|
|
|
|
void player_logic(Player* plr) {
|
|
|
|
if(plr->fire && !(global.frames % 4)) {
|
2011-03-19 16:21:48 +01:00
|
|
|
create_projectile("youmu", plr->pos + 10 - I*20, ((Color){1,1,1}), linear, -20I)->type = PlrProj;
|
|
|
|
create_projectile("youmu", plr->pos - 10 - I*20, ((Color){1,1,1}), linear, -20I)->type = PlrProj;
|
2010-11-14 13:24:56 +01:00
|
|
|
|
|
|
|
if(plr->power >= 2) {
|
2011-03-18 19:03:06 +01:00
|
|
|
float a = 0.20;
|
|
|
|
if(plr->focus > 0) a = 0.06;
|
2011-03-19 16:21:48 +01:00
|
|
|
create_projectile("youmu", plr->pos + 10 - I*20, ((Color){1,1,1}), linear, I*-20*cexp(-I*a))->type = PlrProj;
|
|
|
|
create_projectile("youmu", plr->pos - 10 - I*20, ((Color){1,1,1}), linear, I*-20*cexp(I*a))->type = PlrProj;
|
2010-11-14 13:24:56 +01:00
|
|
|
}
|
2010-10-12 10:55:23 +02:00
|
|
|
}
|
2010-11-14 13:24:56 +01:00
|
|
|
|
2010-11-28 12:54:13 +01:00
|
|
|
if(plr->focus < 0 || (plr->focus > 0 && plr->focus < 30))
|
|
|
|
plr->focus++;
|
2010-10-12 10:55:23 +02:00
|
|
|
}
|