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 "global.h"
|
2010-10-18 14:40:15 +02:00
|
|
|
#include <SDL/SDL.h>
|
2010-11-14 13:24:56 +01:00
|
|
|
#include "font.h"
|
2010-10-12 10:55:23 +02:00
|
|
|
|
|
|
|
Global global;
|
|
|
|
|
|
|
|
void init_textures() {
|
|
|
|
load_texture(FILE_PREFIX "gfx/wasser.png", &global.textures.water);
|
|
|
|
load_texture(FILE_PREFIX "gfx/hud.png", &global.textures.hud);
|
2010-11-28 07:31:26 +01:00
|
|
|
load_texture(FILE_PREFIX "gfx/fairy_circle.png", &global.textures.fairy_circle);
|
2010-11-28 12:54:13 +01:00
|
|
|
load_texture(FILE_PREFIX "gfx/focus.png", &global.textures.focus);
|
2010-11-28 07:31:26 +01:00
|
|
|
|
|
|
|
init_animation(&global.textures.fairy, 2, 2, 15, FILE_PREFIX "gfx/fairy.png");
|
2010-10-12 10:55:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void init_global() {
|
|
|
|
init_player(&global.plr, Youmu);
|
|
|
|
|
|
|
|
init_textures();
|
|
|
|
|
2010-10-13 12:38:38 +02:00
|
|
|
load_projectiles();
|
2010-11-14 13:24:56 +01:00
|
|
|
init_fonts();
|
|
|
|
|
2010-10-12 10:55:23 +02:00
|
|
|
global.projs = NULL;
|
|
|
|
global.fairies = NULL;
|
|
|
|
|
|
|
|
global.frames = 0;
|
2010-10-17 09:27:44 +02:00
|
|
|
global.game_over = 0;
|
2010-10-18 14:40:15 +02:00
|
|
|
|
|
|
|
global.time = 0;
|
|
|
|
global.fps = 0;
|
|
|
|
|
|
|
|
global.lasttime = 0;
|
2010-10-17 09:27:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void game_over() {
|
|
|
|
global.game_over = 1;
|
|
|
|
printf("Game Over!");
|
2010-10-12 18:17:15 +02:00
|
|
|
}
|
2010-10-18 14:40:15 +02:00
|
|
|
|
|
|
|
void frame_rate() {
|
|
|
|
int t = global.lasttime + 1000/FPS - SDL_GetTicks();
|
|
|
|
if(t > 0)
|
|
|
|
SDL_Delay(t);
|
|
|
|
global.lasttime = SDL_GetTicks();
|
|
|
|
}
|