2010-10-12 10:55:23 +02:00
|
|
|
/*
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
---
|
|
|
|
Copyright (C) 2010, Lukas Weber <laochailan@web.de>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "player.h"
|
|
|
|
|
|
|
|
#include <SDL/SDL.h>
|
|
|
|
#include "projectile.h"
|
|
|
|
#include "global.h"
|
|
|
|
|
|
|
|
void init_player(Player* plr, Character cha) {
|
2010-10-17 22:25:10 +02:00
|
|
|
plr->x = VIEWPORT_W/2;
|
|
|
|
plr->y = VIEWPORT_H-20;
|
2010-10-12 10:55:23 +02:00
|
|
|
|
|
|
|
plr->focus = False;
|
|
|
|
plr->fire = False;
|
|
|
|
plr->moving = False;
|
|
|
|
plr->dir = 0;
|
|
|
|
|
|
|
|
plr->cha = cha;
|
|
|
|
|
|
|
|
init_animation(&plr->ani, 2, 4, 5, FILE_PREFIX "gfx/youmu.png");
|
|
|
|
}
|
|
|
|
|
|
|
|
void player_draw(Player* plr) {
|
|
|
|
glPushMatrix();
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
|
|
|
|
if(plr->dir) {
|
|
|
|
glTranslatef(plr->x,plr->y,0);
|
|
|
|
glScalef(-1,1,1);
|
|
|
|
glTranslatef(-plr->x,-plr->y,0);
|
|
|
|
}
|
|
|
|
draw_animation(plr->x, plr->y, !plr->moving, &plr->ani);
|
|
|
|
|
|
|
|
glEnable(GL_CULL_FACE);
|
|
|
|
glPopMatrix();
|
|
|
|
}
|
|
|
|
|
|
|
|
void player_logic(Player* plr) {
|
|
|
|
if(plr->fire && !(global.frames % 4)) {
|
2010-10-24 14:44:48 +02:00
|
|
|
create_projectile(&_projs.youmu, plr->x-10, plr->y-20, 0, ((Color){1,1,1}), simple, 20, 0)->type = PlrProj;
|
|
|
|
create_projectile(&_projs.youmu, plr->x+10, plr->y-20, 0, ((Color){1,1,1}), simple, 20, 0)->type = PlrProj;
|
2010-10-12 10:55:23 +02:00
|
|
|
}
|
|
|
|
}
|