2012-02-28 13:09:12 +01:00
|
|
|
/*! \file level.c
|
|
|
|
* \brief Playable Level code.
|
|
|
|
*/
|
2012-03-04 13:32:42 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) Sebastian Krzyszkowiak <dos@dosowisko.net>
|
|
|
|
*
|
|
|
|
* 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 St, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
2012-02-22 12:43:14 +01:00
|
|
|
#include <stdio.h>
|
2012-04-06 17:28:38 +02:00
|
|
|
#include "moonwalk.h"
|
2012-04-06 18:25:04 +02:00
|
|
|
#include "config.h"
|
|
|
|
#include "pause.h"
|
2012-02-22 12:43:14 +01:00
|
|
|
#include "level.h"
|
2012-04-06 23:32:15 +02:00
|
|
|
#include "timeline.h"
|
|
|
|
|
|
|
|
int x = 0, x2 = 0;
|
2012-02-22 12:43:14 +01:00
|
|
|
|
2012-04-06 18:25:04 +02:00
|
|
|
void Level_Passed(struct Game *game) {
|
|
|
|
if (game->level.current_level<6) {
|
|
|
|
int available = atoi(GetConfigOptionDefault("MuffinAttack", "level", "1"));
|
|
|
|
available++;
|
|
|
|
if ((available<2) || (available>7)) available=1;
|
|
|
|
if (available==(game->level.current_level+1)) {
|
|
|
|
char* text = malloc(2*sizeof(char));
|
|
|
|
sprintf(text, "%d", available);
|
|
|
|
SetConfigOption("MuffinAttack", "level", text);
|
|
|
|
free(text);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
SetConfigOption("MuffinAttack", "completed", "1");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-22 12:43:14 +01:00
|
|
|
void Level_Draw(struct Game *game) {
|
2012-04-06 18:25:04 +02:00
|
|
|
if (game->level.current_level!=1) Moonwalk_Draw(game);
|
|
|
|
else {
|
|
|
|
al_clear_to_color(al_map_rgb(0,0,0));
|
2012-04-06 23:32:15 +02:00
|
|
|
TM_Process();
|
2012-04-06 18:25:04 +02:00
|
|
|
}
|
2012-02-22 12:43:14 +01:00
|
|
|
}
|
|
|
|
|
2012-04-06 23:32:15 +02:00
|
|
|
bool napis(struct Game *game, struct TM_Action *lol) {
|
|
|
|
al_draw_text_with_shadow(game->font, al_map_rgb(255,255,255), x, 20, 0, "wat");
|
|
|
|
x+=10;
|
|
|
|
if (x>1000) { x=0; return true; }
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool napis2(struct Game *game, struct TM_Action *lol) {
|
|
|
|
al_draw_text_with_shadow(game->font, al_map_rgb(255,255,255), x2, 100, 0, "lol");
|
|
|
|
x2+=5;
|
|
|
|
if (x2>1000) { x2=0; return true; }
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool wyjscie(struct Game *game, struct TM_Action *lol) {
|
|
|
|
Level_Passed(game);
|
|
|
|
game->gamestate = GAMESTATE_LOADING;
|
|
|
|
game->loadstate = GAMESTATE_MAP;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-02-22 12:43:14 +01:00
|
|
|
void Level_Load(struct Game *game) {
|
2012-04-06 23:32:15 +02:00
|
|
|
al_clear_to_color(al_map_rgb(0,0,0));
|
2012-04-06 18:25:04 +02:00
|
|
|
if (game->level.current_level!=1) Moonwalk_Load(game);
|
2012-04-06 23:32:15 +02:00
|
|
|
else {
|
|
|
|
TM_Init(game);
|
|
|
|
TM_AddAction(&napis, NULL);
|
|
|
|
TM_AddAction(&napis, NULL);
|
|
|
|
TM_AddAction(&napis, NULL);
|
|
|
|
TM_AddBackgroundAction(&napis2, NULL, 0);
|
|
|
|
TM_AddAction(&wyjscie, NULL);
|
|
|
|
}
|
2012-02-22 12:43:14 +01:00
|
|
|
}
|
2012-02-25 22:26:31 +01:00
|
|
|
|
2012-02-22 12:43:14 +01:00
|
|
|
int Level_Keydown(struct Game *game, ALLEGRO_EVENT *ev) {
|
2012-04-06 18:25:04 +02:00
|
|
|
if (game->level.current_level!=1) Moonwalk_Keydown(game, ev);
|
|
|
|
if (ev->keyboard.keycode==ALLEGRO_KEY_ESCAPE) {
|
|
|
|
game->gamestate = GAMESTATE_PAUSE;
|
|
|
|
game->loadstate = GAMESTATE_LEVEL;
|
|
|
|
Pause_Load(game);
|
|
|
|
}
|
|
|
|
return 0;
|
2012-03-08 22:21:02 +01:00
|
|
|
}
|
|
|
|
|
2012-04-06 23:32:15 +02:00
|
|
|
void Level_ProcessLogic(struct Game *game, ALLEGRO_EVENT *ev) {
|
|
|
|
if (game->level.current_level==1) TM_HandleEvent(ev);
|
|
|
|
}
|
|
|
|
|
2012-03-08 22:21:02 +01:00
|
|
|
void Level_Preload(struct Game *game) {
|
2012-04-06 18:25:04 +02:00
|
|
|
Pause_Preload(game);
|
|
|
|
if (game->level.current_level!=1) Moonwalk_Preload(game);
|
2012-04-06 17:28:38 +02:00
|
|
|
}
|
2012-03-08 22:21:02 +01:00
|
|
|
|
2012-04-06 17:28:38 +02:00
|
|
|
void Level_Unload(struct Game *game) {
|
2012-04-06 18:25:04 +02:00
|
|
|
Pause_Unload_Real(game);
|
|
|
|
if (game->level.current_level!=1) Moonwalk_Unload(game);
|
2012-04-06 23:32:15 +02:00
|
|
|
else {
|
|
|
|
TM_Destroy();
|
|
|
|
}
|
2012-02-22 12:43:14 +01:00
|
|
|
}
|
2012-02-25 22:26:31 +01:00
|
|
|
|
2012-03-08 22:21:02 +01:00
|
|
|
void Level_UnloadBitmaps(struct Game *game) {
|
2012-04-06 18:25:04 +02:00
|
|
|
if (game->level.current_level!=1) Moonwalk_UnloadBitmaps(game);
|
2012-03-08 22:21:02 +01:00
|
|
|
}
|
|
|
|
|
2012-04-06 17:28:38 +02:00
|
|
|
void Level_PreloadBitmaps(struct Game *game) {
|
2012-04-06 18:25:04 +02:00
|
|
|
if (game->level.current_level!=1) Moonwalk_PreloadBitmaps(game);
|
2012-02-22 12:43:14 +01:00
|
|
|
}
|