mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2024-12-05 00:38:00 +01:00
clean up and generalize
This commit is contained in:
parent
2544d94156
commit
0a6b70f72e
70 changed files with 61 additions and 7066 deletions
|
@ -1,8 +1,8 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
project(SuperDerpy C)
|
||||
project(libsuperderpy C)
|
||||
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -g")
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -g -std=c11")
|
||||
if(APPLE)
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fnested-functions")
|
||||
if(CMAKE_INSTALL_PREFIX MATCHES "/usr/local")
|
||||
|
@ -29,13 +29,6 @@ if(MINGW)
|
|||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mwindows")
|
||||
|
||||
# resource compilation for MinGW
|
||||
add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/icon.o
|
||||
COMMAND ${CMAKE_WINDRES} -I${CMAKE_SOURCE_DIR} -i${CMAKE_SOURCE_DIR}/data/icons/icon.rc
|
||||
-o ${CMAKE_CURRENT_BINARY_DIR}/icon.o )
|
||||
set(VLMC_SRCS ${VLMC_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/icon.o)
|
||||
#set(LINK_FLAGS -Wl,-subsystem,windows)
|
||||
|
||||
endif(MINGW)
|
||||
|
||||
add_subdirectory(src)
|
||||
|
@ -48,36 +41,3 @@ add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_D
|
|||
|
||||
INCLUDE(InstallRequiredSystemLibraries)
|
||||
|
||||
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Become Derpy Hooves and fight with muffinzombies in order to rescue Ponyville ponies so they can defeat Discord once again!")
|
||||
SET(CPACK_PACKAGE_VENDOR "Sebastian Krzyszkowiak")
|
||||
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
|
||||
SET(CPACK_PACKAGE_VERSION_MAJOR "0")
|
||||
SET(CPACK_PACKAGE_VERSION_MINOR "2")
|
||||
SET(CPACK_PACKAGE_VERSION_PATCH "pre")
|
||||
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "Super Derpy")
|
||||
IF(WIN32 AND NOT UNIX)
|
||||
# There is a bug in NSI that does not handle full unix paths properly. Make
|
||||
# sure there is at least one set of four (4) backlasshes.
|
||||
SET(CPACK_GENERATOR "NSIS")
|
||||
#SET(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/Utilities/Release/InstallIcon.bmp")
|
||||
SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\superderpy.exe")
|
||||
SET(CPACK_NSIS_DISPLAY_NAME "Super Derpy: Muffin Attack")
|
||||
SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.superderpy.com")
|
||||
SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\dosowisko.net")
|
||||
SET(CPACK_NSIS_CONTACT "dos@dosowisko.net")
|
||||
SET(CPACK_NSIS_CREATE_ICONS "CreateShortCut '\$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\${CPACK_NSIS_DISPLAY_NAME}.lnk' '\$INSTDIR\\\\bin\\\\superderpy.exe'")
|
||||
ELSE(WIN32 AND NOT UNIX)
|
||||
SET(CPACK_GENERATOR "DEB" "RPM")
|
||||
SET(CPACK_STRIP_FILES "bin/superderpy")
|
||||
SET(CPACK_SOURCE_STRIP_FILES "")
|
||||
IF(APPLE)
|
||||
SET(CPACK_GENERATOR "DragNDrop")
|
||||
ENDIF(APPLE)
|
||||
ENDIF(WIN32 AND NOT UNIX)
|
||||
IF(UNIX)
|
||||
SET(CPACK_SET_DESTDIR "ON")
|
||||
ENDIF(UNIX)
|
||||
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Sebastian Krzyszkowiak <dos@dosowisko.net>")
|
||||
#SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.3.1-6), libgcc1 (>= 1:3.4.2-12)")
|
||||
|
||||
include(CPack)
|
||||
|
|
6
data/CMakeLists.txt
Normal file
6
data/CMakeLists.txt
Normal file
|
@ -0,0 +1,6 @@
|
|||
SET(DATADIR "${SHARE_INSTALL_PREFIX}/${LIBSUPERDERPY_GAMENAME}/data")
|
||||
|
||||
if(APPLE)
|
||||
SET(DATADIR "${BIN_INSTALL_DIR}/${LIBSUPERDERPY_GAMENAME_PRETTY}.app/Contents/Resources/data") #OMG NASTY
|
||||
endif(APPLE)
|
||||
|
BIN
data/dosowisko.flac
Normal file
BIN
data/dosowisko.flac
Normal file
Binary file not shown.
BIN
data/fonts/DejaVuSansMono.ttf
Normal file
BIN
data/fonts/DejaVuSansMono.ttf
Normal file
Binary file not shown.
BIN
data/fonts/MonkeyIsland.ttf
Normal file
BIN
data/fonts/MonkeyIsland.ttf
Normal file
Binary file not shown.
BIN
data/fonts/PerfectDOSVGA437.ttf
Normal file
BIN
data/fonts/PerfectDOSVGA437.ttf
Normal file
Binary file not shown.
BIN
data/kbd.flac
Normal file
BIN
data/kbd.flac
Normal file
Binary file not shown.
BIN
data/key.flac
Normal file
BIN
data/key.flac
Normal file
Binary file not shown.
|
@ -9,6 +9,10 @@ SET(EXECUTABLE_SRC_LIST
|
|||
main.c
|
||||
)
|
||||
|
||||
add_definitions(-DLIBSUPERDERPY_GAMENAME_PRETTY="${LIBSUPERDERPY_GAMENAME_PRETTY}")
|
||||
add_definitions(-DLIBSUPERDERPY_GAMENAME="${LIBSUPERDERPY_GAMENAME}")
|
||||
add_definitions(-DLIBSUPERDERPY_INITIAL_GAMESTATE="${LIBSUPERDERPY_INITIAL_GAMESTATE}")
|
||||
|
||||
find_package(Allegro5 REQUIRED)
|
||||
find_package(Allegro5Font REQUIRED)
|
||||
find_package(Allegro5TTF REQUIRED)
|
||||
|
@ -28,24 +32,20 @@ if(MINGW)
|
|||
set(LINK_FLAGS -Wl,-subsystem,windows)
|
||||
endif(MINGW)
|
||||
|
||||
SET(CMAKE_INSTALL_RPATH "\$ORIGIN/../lib/mediator:\$ORIGIN/gamestates:\$ORIGIN:\$ORIGIN/../lib:\$ORIGIN/lib:\$ORIGIN/bin")
|
||||
SET(CMAKE_INSTALL_RPATH "\$ORIGIN/../lib/${LIBSUPERDERPY_GAMENAME}:\$ORIGIN/gamestates:\$ORIGIN:\$ORIGIN/../lib:\$ORIGIN/lib:\$ORIGIN/bin")
|
||||
|
||||
if(APPLE)
|
||||
set(EXECUTABLE "mediator")
|
||||
else(APPLE)
|
||||
set(EXECUTABLE "mediator")
|
||||
endif(APPLE)
|
||||
set(EXECUTABLE ${LIBSUPERDERPY_GAMENAME})
|
||||
|
||||
add_library("libsuperderpy-mediator" SHARED ${SRC_LIST})
|
||||
add_library("libsuperderpy-${LIBSUPERDERPY_GAMENAME}" SHARED ${SRC_LIST})
|
||||
add_executable(${EXECUTABLE} WIN32 MACOSX_BUNDLE ${EXECUTABLE_SRC_LIST})
|
||||
|
||||
SET_TARGET_PROPERTIES("libsuperderpy-mediator" PROPERTIES PREFIX "")
|
||||
SET_TARGET_PROPERTIES("libsuperderpy-${LIBSUPERDERPY_GAMENAME}" PROPERTIES PREFIX "")
|
||||
|
||||
include_directories(${ALLEGRO5_INCLUDE_DIR} ${ALLEGRO5_FONT_INCLUDE_DIR} ${ALLEGRO5_TTF_INCLUDE_DIR} ${ALLEGRO5_PRIMITIVES_INCLUDE_DIR} ${ALLEGRO5_AUDIO_INCLUDE_DIR} ${ALLEGRO5_ACODEC_INCLUDE_DIR} ${ALLEGRO5_IMAGE_INCLUDE_DIR})
|
||||
|
||||
target_link_libraries(${EXECUTABLE} ${ALLEGRO5_LIBRARIES} ${ALLEGRO5_FONT_LIBRARIES} ${ALLEGRO5_TTF_LIBRARIES} ${ALLEGRO5_PRIMITIVES_LIBRARIES} ${ALLEGRO5_AUDIO_LIBRARIES} ${ALLEGRO5_ACODEC_LIBRARIES} ${ALLEGRO5_IMAGE_LIBRARIES} ${ALLEGRO5_MAIN_LIBRARIES} m dl libsuperderpy-mediator)
|
||||
target_link_libraries(${EXECUTABLE} ${ALLEGRO5_LIBRARIES} ${ALLEGRO5_FONT_LIBRARIES} ${ALLEGRO5_TTF_LIBRARIES} ${ALLEGRO5_PRIMITIVES_LIBRARIES} ${ALLEGRO5_AUDIO_LIBRARIES} ${ALLEGRO5_ACODEC_LIBRARIES} ${ALLEGRO5_IMAGE_LIBRARIES} ${ALLEGRO5_MAIN_LIBRARIES} m dl libsuperderpy-${LIBSUPERDERPY_GAMENAME})
|
||||
|
||||
target_link_libraries("libsuperderpy-mediator" ${ALLEGRO5_LIBRARIES} ${ALLEGRO5_FONT_LIBRARIES} ${ALLEGRO5_TTF_LIBRARIES} ${ALLEGRO5_PRIMITIVES_LIBRARIES} ${ALLEGRO5_AUDIO_LIBRARIES} ${ALLEGRO5_ACODEC_LIBRARIES} ${ALLEGRO5_IMAGE_LIBRARIES} ${ALLEGRO5_MAIN_LIBRARIES} m)
|
||||
target_link_libraries("libsuperderpy-${LIBSUPERDERPY_GAMENAME}" ${ALLEGRO5_LIBRARIES} ${ALLEGRO5_FONT_LIBRARIES} ${ALLEGRO5_TTF_LIBRARIES} ${ALLEGRO5_PRIMITIVES_LIBRARIES} ${ALLEGRO5_AUDIO_LIBRARIES} ${ALLEGRO5_ACODEC_LIBRARIES} ${ALLEGRO5_IMAGE_LIBRARIES} ${ALLEGRO5_MAIN_LIBRARIES} m)
|
||||
|
||||
if(ALLEGRO5_MAIN_FOUND)
|
||||
target_link_libraries(${EXECUTABLE} ${ALLEGRO5_MAIN_LIBRARIES})
|
||||
|
@ -54,4 +54,4 @@ endif(ALLEGRO5_MAIN_FOUND)
|
|||
add_subdirectory(gamestates)
|
||||
|
||||
install(TARGETS ${EXECUTABLE} DESTINATION ${BIN_INSTALL_DIR})
|
||||
install(TARGETS "libsuperderpy-mediator" DESTINATION ${LIB_INSTALL_DIR})
|
||||
install(TARGETS "libsuperderpy-${LIBSUPERDERPY_GAMENAME}" DESTINATION ${LIB_INSTALL_DIR})
|
||||
|
|
|
@ -1,26 +1,15 @@
|
|||
MACRO(GAMESTATE name)
|
||||
|
||||
add_library("libsuperderpy-mediator-${name}" SHARED "${name}.c")
|
||||
add_library("libsuperderpy-${LIBSUPERDERPY_GAMENAME}-${name}" SHARED "${name}.c")
|
||||
|
||||
SET_TARGET_PROPERTIES("libsuperderpy-mediator-${name}" PROPERTIES PREFIX "")
|
||||
SET_TARGET_PROPERTIES("libsuperderpy-${LIBSUPERDERPY_GAMENAME}-${name}" PROPERTIES PREFIX "")
|
||||
|
||||
target_link_libraries("libsuperderpy-mediator-${name}" ${ALLEGRO5_LIBRARIES} ${ALLEGRO5_FONT_LIBRARIES} ${ALLEGRO5_TTF_LIBRARIES} ${ALLEGRO5_PRIMITIVES_LIBRARIES} ${ALLEGRO5_AUDIO_LIBRARIES} ${ALLEGRO5_ACODEC_LIBRARIES} ${ALLEGRO5_IMAGE_LIBRARIES} ${ALLEGRO5_COLOR_LIBRARIES} m libsuperderpy-mediator)
|
||||
target_link_libraries("libsuperderpy-${LIBSUPERDERPY_GAMENAME}-${name}" ${ALLEGRO5_LIBRARIES} ${ALLEGRO5_FONT_LIBRARIES} ${ALLEGRO5_TTF_LIBRARIES} ${ALLEGRO5_PRIMITIVES_LIBRARIES} ${ALLEGRO5_AUDIO_LIBRARIES} ${ALLEGRO5_ACODEC_LIBRARIES} ${ALLEGRO5_IMAGE_LIBRARIES} ${ALLEGRO5_COLOR_LIBRARIES} m libsuperderpy-${LIBSUPERDERPY_GAMENAME})
|
||||
|
||||
install(TARGETS "libsuperderpy-mediator-${name}" DESTINATION ${LIB_INSTALL_DIR})
|
||||
install(TARGETS "libsuperderpy-${LIBSUPERDERPY_GAMENAME}-${name}" DESTINATION ${LIB_INSTALL_DIR})
|
||||
|
||||
ENDMACRO()
|
||||
|
||||
GAMESTATE("dosowisko")
|
||||
GAMESTATE("burndt")
|
||||
|
||||
GAMESTATE("menu")
|
||||
|
||||
GAMESTATE("info")
|
||||
GAMESTATE("theend")
|
||||
|
||||
GAMESTATE("rockets")
|
||||
GAMESTATE("lollipop")
|
||||
GAMESTATE("riots")
|
||||
GAMESTATE("bonus")
|
||||
#GAMESTATE("dosowisko")
|
||||
|
||||
GAMESTATE("loading")
|
||||
|
|
|
@ -1,218 +0,0 @@
|
|||
/*! \file about.c
|
||||
* \brief About screen.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <allegro5/allegro_ttf.h>
|
||||
#include "../utils.h"
|
||||
#include "about.h"
|
||||
|
||||
int Gamestate_ProgressCount = 7;
|
||||
|
||||
void Gamestate_Logic(struct Game *game, struct AboutResources* data) {
|
||||
if (al_get_sample_instance_position(data->music)<700000) { return; }
|
||||
if (data->fadeloop==0) {
|
||||
PrintConsole(game, "Fade in");
|
||||
data->fadeloop=1;
|
||||
FadeGamestate(game, true);
|
||||
}
|
||||
data->x+=0.00025;
|
||||
}
|
||||
|
||||
void Gamestate_Draw(struct Game *game, struct AboutResources* data) {
|
||||
/*PrintConsole(game, "%d", al_get_sample_instance_position(data->music));*/
|
||||
if ((al_get_sample_instance_position(data->music)<700000) || (data->fadeloop==0)) {
|
||||
al_clear_to_color(al_map_rgba(0,0,0,0));
|
||||
return;
|
||||
}
|
||||
|
||||
al_draw_scaled_bitmap(data->image,0,0,al_get_bitmap_width(data->image),al_get_bitmap_height(data->image),0,0,game->viewport.width, game->viewport.height,0);
|
||||
al_draw_bitmap(data->letter, game->viewport.width-al_get_bitmap_width(data->letter), -game->viewport.height*0.1, 0);
|
||||
float x = data->x;
|
||||
if (x<0) x=0;
|
||||
ALLEGRO_BITMAP* subbitmap;
|
||||
subbitmap = al_create_sub_bitmap(data->text_bitmap, 0, x*al_get_bitmap_height(data->text_bitmap), al_get_bitmap_width(data->text_bitmap), game->viewport.height);
|
||||
al_draw_rotated_bitmap(subbitmap, al_get_bitmap_width(subbitmap)/2.0, al_get_bitmap_height(subbitmap)/2.0, game->viewport.width-al_get_bitmap_width(data->letter)+al_get_bitmap_width(subbitmap), game->viewport.height*0.1+al_get_bitmap_height(subbitmap)/2.0, -0.11, 0);
|
||||
al_destroy_bitmap(subbitmap);
|
||||
if ((data->x>1) && (data->x<10)) {
|
||||
data->x=10;
|
||||
SwitchGamestate(game, "about", "menu");
|
||||
}
|
||||
}
|
||||
|
||||
void Gamestate_Start(struct Game *game, struct AboutResources* data) {
|
||||
al_play_sample_instance(data->music);
|
||||
data->fadeloop = 0;
|
||||
}
|
||||
|
||||
void Gamestate_ProcessEvent(struct Game *game, struct AboutResources *data, ALLEGRO_EVENT *ev) {
|
||||
if (ev->type == ALLEGRO_EVENT_KEY_DOWN) {
|
||||
if (ev->keyboard.keycode == ALLEGRO_KEY_ESCAPE) {
|
||||
SwitchGamestate(game, "about", "menu");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void* Gamestate_Load(struct Game *game, void (*progress)(struct Game *game)) {
|
||||
|
||||
struct AboutResources *data = malloc(sizeof(struct AboutResources));
|
||||
|
||||
data->image =LoadScaledBitmap(game, "table.png", game->viewport.width, game->viewport.height);
|
||||
(*progress)(game);
|
||||
data->letter = LoadScaledBitmap(game, "about/letter.png", game->viewport.height*1.3, game->viewport.height*1.3 );
|
||||
(*progress)(game);
|
||||
|
||||
data->sample = al_load_sample( GetDataFilePath(game, "about/about.flac") );
|
||||
(*progress)(game);
|
||||
|
||||
data->music = al_create_sample_instance(data->sample);
|
||||
al_attach_sample_instance_to_mixer(data->music, game->audio.music);
|
||||
al_set_sample_instance_playmode(data->music, ALLEGRO_PLAYMODE_LOOP);
|
||||
al_set_sample_instance_position(data->music, game->config.music ? 420000 : 700000);
|
||||
(*progress)(game);
|
||||
|
||||
data->font = al_load_ttf_font(GetDataFilePath(game, "fonts/ShadowsIntoLight.ttf"),game->viewport.height*0.035,0 );
|
||||
(*progress)(game);
|
||||
data->x = -0.1;
|
||||
if (!data->sample){
|
||||
fprintf(stderr, "Audio clip sample not loaded!\n" );
|
||||
exit(-1);
|
||||
}
|
||||
data->text_bitmap = al_create_bitmap(game->viewport.height*1.6*0.4, game->viewport.height*3.225);
|
||||
al_set_target_bitmap(data->text_bitmap);
|
||||
al_clear_to_color(al_map_rgba(0,0,0,0));
|
||||
al_draw_text(data->font, al_map_rgb(0,0,0), (int)(0.5*al_get_bitmap_width(data->text_bitmap)), (int)(0.015*al_get_bitmap_height(data->text_bitmap)), ALLEGRO_ALIGN_CENTRE, "Super Derpy: Muffin Attack");
|
||||
al_draw_text(data->font, al_map_rgb(0,0,0), (int)(0.5*al_get_bitmap_width(data->text_bitmap)), (int)(0.035*al_get_bitmap_height(data->text_bitmap)), ALLEGRO_ALIGN_CENTRE, "Version 0.1a (Development Preview)");
|
||||
(*progress)(game);
|
||||
|
||||
al_set_target_bitmap(data->text_bitmap);
|
||||
float y=0.07;
|
||||
void draw_text(char* text) {
|
||||
al_draw_text(data->font, al_map_rgb(0,0,0), 0, (int)(y*al_get_bitmap_height(data->text_bitmap)), ALLEGRO_ALIGN_LEFT, text);
|
||||
y+=0.0131;
|
||||
}
|
||||
|
||||
draw_text("Written by:");
|
||||
draw_text(" - Sebastian Krzyszkowiak");
|
||||
draw_text(" http://dosowisko.net/");
|
||||
draw_text("");
|
||||
draw_text("Animations:");
|
||||
draw_text(" - Yudhaikeledai");
|
||||
draw_text(" http://yudhaikeledai.deviantart.com/");
|
||||
draw_text("");
|
||||
draw_text("Voices:");
|
||||
/*draw_text(" - BaldDumboRat");
|
||||
draw_text(" Derpy Hooves");*/
|
||||
draw_text(" - MEMJ0123");
|
||||
draw_text(" http://www.youtube.com/user/MEMJ0123");
|
||||
draw_text(" Princess Celestia");
|
||||
draw_text(" - Meredith Sims (Emichwan88)");
|
||||
draw_text(" http://www.youtube.com/Emichwan88");
|
||||
draw_text(" Fluttershy");
|
||||
draw_text(" Twilight Sparkle");
|
||||
/*draw_text(" - Hnilmik");
|
||||
draw_text(" Rarity");
|
||||
draw_text(" - Karen VO");
|
||||
draw_text(" Applejack");*/
|
||||
/* draw_text(" - Erica Mendez");
|
||||
draw_text(" Rainbow Dash");
|
||||
draw_text(" - Emily Fajardo");
|
||||
draw_text(" Pinkie Pie");*/
|
||||
draw_text("");
|
||||
draw_text("Original graphics:");
|
||||
draw_text(" - Ania Karlik");
|
||||
draw_text(" (Eris)");
|
||||
draw_text(" - Agata Kurczewska");
|
||||
draw_text(" http://kiciazkrainyczarow.deviantart.com/");
|
||||
draw_text(" - Wiktor Grześkowiak");
|
||||
draw_text(" http://gl0w.pl/");
|
||||
draw_text("");
|
||||
draw_text("Music:");
|
||||
draw_text(" - Claire Anne Carr");
|
||||
draw_text(" http://claireannecarr.bandcamp.com/");
|
||||
draw_text(" - Dr Dissonance");
|
||||
draw_text(" http://dr-dissonance.tumblr.com/");
|
||||
draw_text(" - Dan O'Connor");
|
||||
draw_text(" http://www.danosongs.com/");
|
||||
draw_text(" - Kevin MacLeod");
|
||||
draw_text(" http://incompetech.com/");
|
||||
draw_text("");
|
||||
draw_text("Sounds:");
|
||||
draw_text(" - Sound Jay");
|
||||
draw_text(" http://www.soundjay.com/");
|
||||
draw_text("");
|
||||
draw_text("Other graphics:");
|
||||
draw_text(" - CptOfTheFriendship");
|
||||
draw_text(" http://cptofthefriendship.deviantart.com/");
|
||||
draw_text(" - hombre0");
|
||||
draw_text(" http://hombre0.deviantart.com/");
|
||||
draw_text(" - Siobhan Brewer");
|
||||
draw_text(" http://boxdrink.deviantart.com/");
|
||||
draw_text("");
|
||||
draw_text("Super Derpy: Muffin Attack comes");
|
||||
draw_text("with ABSOLUTELY NO WARRANTY.");
|
||||
draw_text("You may redistribute copies of this");
|
||||
draw_text("game under the terms of");
|
||||
draw_text("GNU General Public License.");
|
||||
draw_text("For more information, see the file");
|
||||
draw_text("named COPYING.");
|
||||
draw_text("");
|
||||
draw_text("Super Derpy: Muffin Attack is");
|
||||
draw_text("a fan-made game with no profit");
|
||||
draw_text("intended. Its author is unpaid");
|
||||
draw_text("volunteer and doesn't receive");
|
||||
draw_text("any economical profit from it.");
|
||||
draw_text("");
|
||||
draw_text("My Little Pony: Friendship is Magic");
|
||||
draw_text("is copyrighted trademark owned");
|
||||
draw_text("by Hasbro.");
|
||||
draw_text("");
|
||||
draw_text("Author of Super Derpy is not");
|
||||
draw_text("affiliated to Hasbro, The Hub");
|
||||
draw_text("or its associates.");
|
||||
draw_text("");
|
||||
draw_text("http://www.superderpy.com/");
|
||||
(*progress)(game);
|
||||
|
||||
al_set_target_backbuffer(game->display);
|
||||
return data;
|
||||
}
|
||||
|
||||
void Gamestate_Unload(struct Game *game, struct AboutResources* data) {
|
||||
al_destroy_bitmap(data->image);
|
||||
al_destroy_bitmap(data->letter);
|
||||
al_destroy_bitmap(data->text_bitmap);
|
||||
al_destroy_sample_instance(data->music);
|
||||
al_destroy_sample(data->sample);
|
||||
al_destroy_font(data->font);
|
||||
free(data);
|
||||
}
|
||||
|
||||
void Gamestate_Stop(struct Game *game, struct AboutResources* data) {
|
||||
if (data->fadeloop!=0) {
|
||||
FadeGamestate(game, false);
|
||||
}
|
||||
al_stop_sample_instance(data->music);
|
||||
}
|
||||
|
||||
void Gamestate_Reload(struct Game *game, struct AboutResources* data) {}
|
||||
|
||||
void Gamestate_Resume(struct Game *game, struct AboutResources* data) {}
|
||||
void Gamestate_Pause(struct Game *game, struct AboutResources* data) {}
|
|
@ -1,31 +0,0 @@
|
|||
/*! \file about.h
|
||||
* \brief About screen headers.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
struct AboutResources {
|
||||
ALLEGRO_BITMAP *image; /*!< Background bitmap. */
|
||||
ALLEGRO_BITMAP *text_bitmap; /*!< Bitmap with scrolled text. */
|
||||
ALLEGRO_BITMAP *letter; /*!< Paper bitmap. */
|
||||
ALLEGRO_SAMPLE *sample; /*!< Sample with background music. */
|
||||
ALLEGRO_SAMPLE_INSTANCE *music; /*!< Sample instance with background music. */
|
||||
ALLEGRO_FONT *font; /*!< Font used in the text on letter. */
|
||||
float x; /*!< Horizontal position of the text. */
|
||||
int fadeloop; /*!< Loop counter used in fades. */
|
||||
};
|
|
@ -1,452 +0,0 @@
|
|||
/*! \file dosowisko.c
|
||||
* \brief Init animation with dosowisko.net logo.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <allegro5/allegro_ttf.h>
|
||||
#include <allegro5/allegro_color.h>
|
||||
#include <allegro5/allegro_primitives.h>
|
||||
#include <math.h>
|
||||
#include "../utils.h"
|
||||
#include "../timeline.h"
|
||||
#include "bonus.h"
|
||||
|
||||
int Gamestate_ProgressCount = 11;
|
||||
|
||||
struct Rocket* CreateRocket(struct Game *game, struct RocketsResources* data, struct Rocket* rockets, bool right) {
|
||||
struct Rocket *n = malloc(sizeof(struct Rocket));
|
||||
n->next = NULL;
|
||||
n->prev = NULL;
|
||||
n->dx = (right ? -1.5 : 1.5) + (rand() / (float)RAND_MAX) * 0.6 - 0.3;
|
||||
n->dy = -2.1 + (rand() / (float)RAND_MAX) * 0.5 - 0.25;
|
||||
n->modifier = 0.025;
|
||||
n->blown = false;
|
||||
n->character = CreateCharacter(game, "rocket");
|
||||
n->character->spritesheets = data->rocket_template->spritesheets;
|
||||
n->character->shared = true;
|
||||
SelectSpritesheet(game, n->character, rand() % 2 ? "usa" : "ru");
|
||||
SetCharacterPosition(game, n->character, (data->ru_flag->x + 40) + rand() % 100 - 50, 100, right ? -0.33 : 0.33);
|
||||
al_play_sample_instance(data->jump_sound);
|
||||
data->currentspawn = data->spawnspeed + (data->spawnspeed * 0.1) * (float)(rand() / (float)RAND_MAX * 2) - (data->spawnspeed * 0.05);
|
||||
|
||||
if (rockets) {
|
||||
struct Rocket *tmp = rockets;
|
||||
while (tmp->next) {
|
||||
tmp=tmp->next;
|
||||
}
|
||||
tmp->next = n;
|
||||
n->prev = tmp;
|
||||
return rockets;
|
||||
} else {
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DrawRockets(struct Game *game, struct RocketsResources* data, struct Rocket* rockets) {
|
||||
struct Rocket *tmp = rockets;
|
||||
while (tmp) {
|
||||
DrawCharacter(game, tmp->character, al_map_rgb(255,255,255), 0);
|
||||
|
||||
tmp=tmp->next;
|
||||
}
|
||||
}
|
||||
|
||||
bool switchMinigame(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||
if (state == TM_ACTIONSTATE_START) {
|
||||
StopGamestate(game, "bonus");
|
||||
StartGamestate(game, game->mediator.next);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool theEnd(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||
if (state == TM_ACTIONSTATE_START) {
|
||||
StopGamestate(game, "bonus");
|
||||
StartGamestate(game, "theend");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void UpdateRockets(struct Game *game, struct RocketsResources *data, struct Rocket* rockets) {
|
||||
struct Rocket *tmp = rockets;
|
||||
while (tmp) {
|
||||
tmp->dy+= tmp->modifier;
|
||||
if (!tmp->blown) {
|
||||
tmp->dx+= (tmp->dx > 0) ? (-tmp->modifier / 5 + 0.001) : (tmp->modifier / 5 - 0.001);
|
||||
}
|
||||
MoveCharacter(game, tmp->character, tmp->dx, tmp->dy, tmp->blown ? 0 : ((tmp->dx > 0) ? 0.0166 : -0.0166));
|
||||
AnimateCharacter(game, tmp->character, 1);
|
||||
|
||||
if (!tmp->blown) {
|
||||
|
||||
//if (((((tmp->character->y > 90) && (rand() % 4 == 0) && (tmp->dy > 0)))) && (tmp->character->x > -20 && tmp->character->x < 320)) {
|
||||
if ((tmp->character->x > 200) && (tmp->character->y < 50) && (tmp->character->x < 260) && (rand() % 4 == 0)) {
|
||||
tmp->blown = true;
|
||||
tmp->modifier = 0;
|
||||
tmp->character->angle = 0;
|
||||
tmp->dx = 0;
|
||||
tmp->dy = 0;
|
||||
SelectSpritesheet(game, tmp->character, "boom");
|
||||
MoveCharacter(game, tmp->character, 5, 5, 0);
|
||||
|
||||
data->lizakpowa--;
|
||||
|
||||
}
|
||||
}
|
||||
tmp=tmp->next;
|
||||
}
|
||||
}
|
||||
|
||||
void Gamestate_Logic(struct Game *game, struct RocketsResources* data) {
|
||||
|
||||
if (!data->flash) {
|
||||
if ((!data->lost) && (!data->won)) {
|
||||
|
||||
UpdateRockets(game, data, data->rockets_left);
|
||||
UpdateRockets(game, data, data->rockets_right);
|
||||
}
|
||||
} else {
|
||||
data->flash--;
|
||||
}
|
||||
|
||||
if (data->lost) {
|
||||
data->zadyma++;
|
||||
if (data->zadyma >= 255) {
|
||||
data->zadyma = 255;
|
||||
}
|
||||
}
|
||||
|
||||
AnimateCharacter(game, data->usa_flag, 1);
|
||||
AnimateCharacter(game, data->ru_flag, 1);
|
||||
AnimateCharacter(game, data->riot, 1);
|
||||
if ((data->lost) && (data->hearts > 80)) {
|
||||
AnimateCharacter(game, game->mediator.heart, 1);
|
||||
if (game->mediator.heart->pos == 6) {
|
||||
al_play_sample_instance(data->boom_sound);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ((data->lizakpowa <= 0) && (!data->won) && (!data->lost)) {
|
||||
data->won = true;
|
||||
al_play_sample_instance(data->rainbow_sound);
|
||||
al_play_sample_instance(data->boom_sound);
|
||||
data->flash = 4;
|
||||
game->mediator.lives++;
|
||||
AdvanceLevel(game, true);
|
||||
MoveCharacter(game, data->ru_flag, 0, -24, 0);
|
||||
SelectSpritesheet(game, data->ru_flag, "lollipop");
|
||||
TM_AddDelay(data->timeline, 2500);
|
||||
TM_AddAction(data->timeline, switchMinigame, NULL, "switchMinigame");
|
||||
}
|
||||
|
||||
if ((data->counter >= data->timelimit) && (!data->lost) && (!data->won)) {
|
||||
|
||||
data->lost = true;
|
||||
game->mediator.lives++;
|
||||
AdvanceLevel(game, false);
|
||||
|
||||
SelectSpritesheet(game, data->ru_flag, "cry");
|
||||
al_play_sample_instance(data->wuwu_sound);
|
||||
|
||||
TM_AddDelay(data->timeline, 1500);
|
||||
TM_AddAction(data->timeline, switchMinigame, NULL, "switchMinigame");
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (!data->won) {
|
||||
data->counter++;
|
||||
}
|
||||
data->spawncounter++;
|
||||
data->cloud_rotation += 0.002;
|
||||
data->tick ++;
|
||||
|
||||
data->color += 2;
|
||||
if (data->color >= 360) {
|
||||
data->color = 0;
|
||||
}
|
||||
|
||||
TM_Process(data->timeline);
|
||||
}
|
||||
|
||||
void Gamestate_Draw(struct Game *game, struct RocketsResources* data) {
|
||||
|
||||
al_set_target_bitmap(data->pixelator);
|
||||
|
||||
al_draw_tinted_bitmap(data->bg, al_color_hsv(abs(data->color), 0.498, 1.0), 0, 0, 0);
|
||||
|
||||
|
||||
if (data->won) {
|
||||
// DrawCharacter(game, data->euro, al_map_rgb(255,255,255), 0);
|
||||
}
|
||||
|
||||
if (data->lizakpowa > 30) {
|
||||
al_draw_rotated_bitmap(data->loli, 200, 200, 370, 65, -1, 0);
|
||||
} else if (data->lizakpowa > 15) {
|
||||
al_draw_rotated_bitmap(data->loli2, 200, 200, 370, 65, -1, 0);
|
||||
} else if (data->lizakpowa > 0) {
|
||||
al_draw_rotated_bitmap(data->loli3, 200, 200, 370, 65, -1, 0);
|
||||
}
|
||||
|
||||
if ((!data->lost) && (!data->won)) {
|
||||
|
||||
|
||||
DrawRockets(game, data, data->rockets_left);
|
||||
DrawRockets(game, data, data->rockets_right);
|
||||
|
||||
}
|
||||
|
||||
|
||||
DrawCharacter(game, data->ru_flag, al_map_rgb(255,255,255), 0);
|
||||
|
||||
if ((!data->lost) && (!data->won)) {
|
||||
al_draw_filled_rectangle(78, 5, 78+164, 5+5, al_map_rgb(155, 142, 142));
|
||||
al_draw_filled_rectangle(80, 6, 80+160, 6+3, al_map_rgb(66, 55, 30));
|
||||
al_draw_filled_rectangle(80, 6, (data->counter < data->timelimit) ? (80+ 160 * (1 - (data->counter / (float)data->timelimit))) : 80, 6+3, al_map_rgb(225,182, 80));
|
||||
}
|
||||
|
||||
if (data->flash) {
|
||||
al_draw_filled_rectangle(0, 0, 320, 180, al_map_rgb(255, 255, 255));
|
||||
}
|
||||
|
||||
al_set_target_backbuffer(game->display);
|
||||
al_draw_bitmap(data->pixelator, 0, 0, 0);
|
||||
|
||||
if ((data->lost) && (data->hearts > 80)) {
|
||||
ShowLevelStatistics(game);
|
||||
}
|
||||
|
||||
if (data->tick < 86) {
|
||||
|
||||
if ((data->tick / 11) % 2 == 0) {
|
||||
DrawTextWithShadow(game->_priv.font, al_map_rgb(255,255,255), 320 /2 , 45 , ALLEGRO_ALIGN_CENTER, "BONUS LEVEL");
|
||||
}
|
||||
}
|
||||
|
||||
//Gamestate_Logic(game, data);
|
||||
|
||||
}
|
||||
|
||||
void Gamestate_Start(struct Game *game, struct RocketsResources* data) {
|
||||
data->rockets_left = NULL;
|
||||
data->rockets_right = NULL;
|
||||
|
||||
data->tick = 0;
|
||||
|
||||
data->timelimit = 420 / game->mediator.modificator;
|
||||
data->spawnspeed = 80 / game->mediator.modificator;
|
||||
data->currentspawn = data->spawnspeed;
|
||||
data->spawncounter = data->spawnspeed - 20;
|
||||
|
||||
data->lost = false;
|
||||
data->won = false;
|
||||
data->hearts = 0;
|
||||
|
||||
data->flash = 0;
|
||||
data->zadyma = 16;
|
||||
data->lizakpowa = 60;
|
||||
|
||||
SetCharacterPosition(game, data->usa_flag, 185, 80, 0);
|
||||
SetCharacterPosition(game, data->ru_flag, 25, 80, 0);
|
||||
|
||||
SetCharacterPosition(game, data->cursor, -320, 50, 0);
|
||||
|
||||
SetCharacterPosition(game, data->riot, 0, 0, 0);
|
||||
SelectSpritesheet(game, data->riot, "riot");
|
||||
|
||||
SelectSpritesheet(game, data->usa_flag, "legia");
|
||||
SelectSpritesheet(game, data->ru_flag, "lech");
|
||||
|
||||
SelectSpritesheet(game, data->cursor, "hand");
|
||||
|
||||
data->counter = 0;
|
||||
data->cloud_rotation = 0;
|
||||
|
||||
data->mousemove.bottom = false;
|
||||
data->mousemove.top = false;
|
||||
data->mousemove.left = false;
|
||||
data->mousemove.right = false;
|
||||
|
||||
al_set_mouse_xy(game->display, al_get_display_width(game->display) / 2, al_get_display_height(game->display) / 2);
|
||||
|
||||
al_set_sample_instance_gain(game->muzyczka.instance.bg, 0.0);
|
||||
al_set_sample_instance_gain(game->muzyczka.instance.fg, 0.0);
|
||||
al_set_sample_instance_gain(data->riot_sound, 1.5);
|
||||
al_set_sample_instance_gain(data->wuwu_sound, 1.25);
|
||||
al_play_sample_instance(data->riot_sound);
|
||||
al_play_sample_instance(data->wuwu_sound);
|
||||
}
|
||||
|
||||
void Gamestate_ProcessEvent(struct Game *game, struct RocketsResources* data, ALLEGRO_EVENT *ev) {
|
||||
TM_HandleEvent(data->timeline, ev);
|
||||
if ((ev->type==ALLEGRO_EVENT_KEY_DOWN) && (ev->keyboard.keycode == ALLEGRO_KEY_ESCAPE)) {
|
||||
SwitchGamestate(game, "bonus", "theend");
|
||||
} else if (ev->type == ALLEGRO_EVENT_MOUSE_AXES) {
|
||||
int mousex = ev->mouse.x / (al_get_display_width(game->display) / 320);
|
||||
int mousey = 80;
|
||||
data->mousemove.right = mousex > data->cursor->x;
|
||||
data->mousemove.top = mousey < data->cursor->y;
|
||||
data->mousemove.left = mousex < data->cursor->x;
|
||||
data->mousemove.bottom = mousey > data->cursor->y;
|
||||
if ((!data->won)&& (!data->lost)) {
|
||||
SetCharacterPosition(game, data->ru_flag, mousex, mousey , 0); // FIXMEEEE!
|
||||
}
|
||||
} else if (ev->type == ALLEGRO_EVENT_MOUSE_BUTTON_DOWN) {
|
||||
if ((!data->won)&& (!data->lost)) {
|
||||
data->rockets_left = CreateRocket(game, data, data->rockets_left, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void* Gamestate_Load(struct Game *game, void (*progress)(struct Game*)) {
|
||||
struct RocketsResources *data = malloc(sizeof(struct RocketsResources));
|
||||
|
||||
data->timeline = TM_Init(game, "bonus");
|
||||
|
||||
data->bg = al_load_bitmap( GetDataFilePath(game, "bg.png"));
|
||||
|
||||
data->earth = al_load_bitmap( GetDataFilePath(game, "riots/separator.png"));
|
||||
|
||||
data->loli = al_load_bitmap( GetDataFilePath(game, "lollipop/lollipop.png"));
|
||||
data->loli2 = al_load_bitmap( GetDataFilePath(game, "lollipop/lollipop2.png"));
|
||||
data->loli3 = al_load_bitmap( GetDataFilePath(game, "lollipop/lollipop3.png"));
|
||||
|
||||
(*progress)(game);
|
||||
|
||||
data->rocket_sample = al_load_sample( GetDataFilePath(game, "bump.flac") );
|
||||
(*progress)(game);
|
||||
data->boom_sample = al_load_sample( GetDataFilePath(game, "boom.flac") );
|
||||
(*progress)(game);
|
||||
data->jump_sample = al_load_sample( GetDataFilePath(game, "launch.flac") );
|
||||
(*progress)(game);
|
||||
data->rainbow_sample = al_load_sample( GetDataFilePath(game, "win.flac") );
|
||||
(*progress)(game);
|
||||
data->wuwu_sample = al_load_sample( GetDataFilePath(game, "warning.flac") );
|
||||
(*progress)(game);
|
||||
data->riot_sample = al_load_sample( GetDataFilePath(game, "bonus.flac") );
|
||||
(*progress)(game);
|
||||
|
||||
data->rocket_sound = al_create_sample_instance(data->rocket_sample);
|
||||
al_attach_sample_instance_to_mixer(data->rocket_sound, game->audio.fx);
|
||||
al_set_sample_instance_playmode(data->rocket_sound, ALLEGRO_PLAYMODE_ONCE);
|
||||
|
||||
data->boom_sound = al_create_sample_instance(data->boom_sample);
|
||||
al_attach_sample_instance_to_mixer(data->boom_sound, game->audio.fx);
|
||||
al_set_sample_instance_playmode(data->boom_sound, ALLEGRO_PLAYMODE_ONCE);
|
||||
|
||||
data->rainbow_sound = al_create_sample_instance(data->rainbow_sample);
|
||||
al_attach_sample_instance_to_mixer(data->rainbow_sound, game->audio.fx);
|
||||
al_set_sample_instance_playmode(data->rainbow_sound, ALLEGRO_PLAYMODE_ONCE);
|
||||
al_set_sample_instance_gain(data->rainbow_sound, 1.25);
|
||||
|
||||
data->jump_sound = al_create_sample_instance(data->jump_sample);
|
||||
al_attach_sample_instance_to_mixer(data->jump_sound, game->audio.fx);
|
||||
al_set_sample_instance_playmode(data->jump_sound, ALLEGRO_PLAYMODE_ONCE);
|
||||
|
||||
data->riot_sound = al_create_sample_instance(data->riot_sample);
|
||||
al_attach_sample_instance_to_mixer(data->riot_sound, game->audio.music);
|
||||
al_set_sample_instance_playmode(data->riot_sound, ALLEGRO_PLAYMODE_LOOP);
|
||||
|
||||
data->wuwu_sound = al_create_sample_instance(data->wuwu_sample);
|
||||
al_attach_sample_instance_to_mixer(data->wuwu_sound, game->audio.fx);
|
||||
al_set_sample_instance_playmode(data->wuwu_sound, ALLEGRO_PLAYMODE_ONCE);
|
||||
|
||||
|
||||
data->cursor = CreateCharacter(game, "cursor");
|
||||
RegisterSpritesheet(game, data->cursor, "hand");
|
||||
LoadSpritesheets(game, data->cursor);
|
||||
(*progress)(game);
|
||||
|
||||
data->pixelator = al_create_bitmap(320, 180);
|
||||
al_set_target_bitmap(data->pixelator);
|
||||
al_clear_to_color(al_map_rgb(0, 0, 0));
|
||||
|
||||
al_set_target_backbuffer(game->display);
|
||||
|
||||
data->rocket_template = CreateCharacter(game, "rocket");
|
||||
RegisterSpritesheet(game, data->rocket_template, "usa");
|
||||
RegisterSpritesheet(game, data->rocket_template, "ru");
|
||||
RegisterSpritesheet(game, data->rocket_template, "atom");
|
||||
RegisterSpritesheet(game, data->rocket_template, "boom");
|
||||
RegisterSpritesheet(game, data->rocket_template, "blank");
|
||||
LoadSpritesheets(game, data->rocket_template);
|
||||
(*progress)(game);
|
||||
|
||||
data->usa_flag = CreateCharacter(game, "kibols");
|
||||
RegisterSpritesheet(game, data->usa_flag, "legia");
|
||||
RegisterSpritesheet(game, data->usa_flag, "lollipop");
|
||||
RegisterSpritesheet(game, data->usa_flag, "cry");
|
||||
LoadSpritesheets(game, data->usa_flag);
|
||||
|
||||
data->ru_flag = CreateCharacter(game, "kibols");
|
||||
RegisterSpritesheet(game, data->ru_flag, "lech");
|
||||
RegisterSpritesheet(game, data->ru_flag, "lollipop");
|
||||
RegisterSpritesheet(game, data->ru_flag, "cry");
|
||||
LoadSpritesheets(game, data->ru_flag);
|
||||
(*progress)(game);
|
||||
|
||||
data->rainbow = CreateCharacter(game, "rainbow");
|
||||
RegisterSpritesheet(game, data->rainbow, "shine");
|
||||
RegisterSpritesheet(game, data->rainbow, "be");
|
||||
LoadSpritesheets(game, data->rainbow);
|
||||
|
||||
data->riot = CreateCharacter(game, "riot");
|
||||
RegisterSpritesheet(game, data->riot, "riot");
|
||||
LoadSpritesheets(game, data->riot);
|
||||
(*progress)(game);
|
||||
|
||||
data->euro = CreateCharacter(game, "euro");
|
||||
RegisterSpritesheet(game, data->euro, "euro");
|
||||
LoadSpritesheets(game, data->euro);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void Gamestate_Stop(struct Game *game, struct RocketsResources* data) {
|
||||
TM_CleanQueue(data->timeline);
|
||||
al_set_sample_instance_gain(game->muzyczka.instance.bg, 1.5);
|
||||
al_set_sample_instance_gain(game->muzyczka.instance.fg, 1.5);
|
||||
al_stop_sample_instance(data->riot_sound);
|
||||
}
|
||||
|
||||
void Gamestate_Unload(struct Game *game, struct RocketsResources* data) {
|
||||
al_destroy_bitmap(data->bg);
|
||||
al_destroy_bitmap(data->earth);
|
||||
al_destroy_bitmap(data->pixelator);
|
||||
al_destroy_bitmap(data->loli);
|
||||
al_destroy_bitmap(data->loli2);
|
||||
al_destroy_bitmap(data->loli3);
|
||||
al_destroy_sample_instance(data->rocket_sound);
|
||||
al_destroy_sample_instance(data->boom_sound);
|
||||
al_destroy_sample(data->rocket_sample);
|
||||
al_destroy_sample(data->boom_sample);
|
||||
// TODO: DestroyCharacters
|
||||
free(data);
|
||||
}
|
||||
|
||||
void Gamestate_Reload(struct Game *game, struct RocketsResources* data) {}
|
||||
|
||||
void Gamestate_Resume(struct Game *game, struct RocketsResources* data) {
|
||||
TM_Resume(data->timeline);
|
||||
}
|
||||
void Gamestate_Pause(struct Game *game, struct RocketsResources* data) {
|
||||
TM_Pause(data->timeline);
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
/*! \file dosowisko.h
|
||||
* \brief Init animation with dosowisko.net logo.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
struct RocketsResources {
|
||||
ALLEGRO_FONT *font;
|
||||
ALLEGRO_BITMAP *bg, *earth, *earth2, *pixelator, *loli, *loli2, *loli3;
|
||||
struct Character *rocket_template, *usa_flag, *ru_flag, *cursor, *rainbow, *riot, *euro;
|
||||
|
||||
struct Rocket {
|
||||
struct Character *character;
|
||||
float dx, dy, modifier;
|
||||
bool blown, bumped;
|
||||
struct Rocket *next, *prev;
|
||||
} *rockets_left, *rockets_right;
|
||||
|
||||
int counter, hearts, tick;
|
||||
float cloud_rotation;
|
||||
|
||||
struct {
|
||||
bool top, right, left, bottom;
|
||||
} mousemove;
|
||||
|
||||
ALLEGRO_SAMPLE *rocket_sample, *boom_sample, *rainbow_sample, *jump_sample, *wuwu_sample, *riot_sample;
|
||||
ALLEGRO_SAMPLE_INSTANCE *rocket_sound, *boom_sound, *rainbow_sound, *jump_sound, *wuwu_sound, *riot_sound;
|
||||
|
||||
bool lost, won;
|
||||
|
||||
int flash, zadyma;
|
||||
|
||||
int timelimit, spawnspeed, currentspawn, spawncounter;
|
||||
|
||||
struct Timeline *timeline;
|
||||
|
||||
int color;
|
||||
int lizakpowa;
|
||||
};
|
|
@ -1,101 +0,0 @@
|
|||
/*! \file dosowisko.c
|
||||
* \brief Init animation with dosowisko.net logo.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <allegro5/allegro_ttf.h>
|
||||
#include <allegro5/allegro_primitives.h>
|
||||
#include <math.h>
|
||||
#include "../utils.h"
|
||||
#include "../timeline.h"
|
||||
#include "burndt.h"
|
||||
|
||||
int Gamestate_ProgressCount = 1;
|
||||
|
||||
void Gamestate_Logic(struct Game *game, struct burndtResources* data) {
|
||||
data->tick++;
|
||||
if (data->tick > 260) {
|
||||
SwitchGamestate(game, "burndt", "menu");
|
||||
}
|
||||
}
|
||||
|
||||
void Gamestate_Draw(struct Game *game, struct burndtResources* data) {
|
||||
|
||||
float light = 1 - data->tick / 20.0;
|
||||
|
||||
if (data->tick >= 190) {
|
||||
light = 1 - (data->tick-190) / 20.0;
|
||||
}
|
||||
|
||||
if (light > 1) {
|
||||
light = 1;
|
||||
}
|
||||
if (light < 0) {
|
||||
light = 0;
|
||||
}
|
||||
|
||||
if (data->tick < 190) {
|
||||
al_clear_to_color(al_map_rgb(82 + (255-82) * light, 82 + (255-82) * light, 186 + (255-186) * light));
|
||||
al_draw_bitmap(data->bitmap, 0, 0, 0);
|
||||
} else {
|
||||
al_clear_to_color(al_map_rgb(255 * light, 255 * light, 255 * light));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Gamestate_Start(struct Game *game, struct burndtResources* data) {
|
||||
data->tick = 0;
|
||||
al_play_sample_instance(data->sound);
|
||||
}
|
||||
|
||||
void Gamestate_ProcessEvent(struct Game *game, struct burndtResources* data, ALLEGRO_EVENT *ev) {
|
||||
if ((ev->type==ALLEGRO_EVENT_KEY_DOWN) && (ev->keyboard.keycode == ALLEGRO_KEY_ESCAPE)) {
|
||||
SwitchGamestate(game, "burndt", "menu");
|
||||
}
|
||||
}
|
||||
|
||||
void* Gamestate_Load(struct Game *game, void (*progress)(struct Game*)) {
|
||||
struct burndtResources *data = malloc(sizeof(struct burndtResources));
|
||||
data->bitmap = al_load_bitmap( GetDataFilePath(game, "burndt.png") );
|
||||
(*progress)(game);
|
||||
|
||||
data->sample = al_load_sample( GetDataFilePath(game, "burndt.flac") );
|
||||
data->sound = al_create_sample_instance(data->sample);
|
||||
al_attach_sample_instance_to_mixer(data->sound, game->audio.music);
|
||||
al_set_sample_instance_playmode(data->sound, ALLEGRO_PLAYMODE_ONCE);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void Gamestate_Stop(struct Game *game, struct burndtResources* data) {
|
||||
al_stop_sample_instance(data->sound);
|
||||
}
|
||||
|
||||
void Gamestate_Unload(struct Game *game, struct burndtResources* data) {
|
||||
al_destroy_sample_instance(data->sound);
|
||||
al_destroy_sample(data->sample);
|
||||
al_destroy_bitmap(data->bitmap);
|
||||
free(data);
|
||||
}
|
||||
|
||||
void Gamestate_Reload(struct Game *game, struct burndtResources* data) {}
|
||||
|
||||
void Gamestate_Resume(struct Game *game, struct burndtResources* data) {}
|
||||
void Gamestate_Pause(struct Game *game, struct burndtResources* data) {}
|
|
@ -1,27 +0,0 @@
|
|||
/*! \file dosowisko.h
|
||||
* \brief Init animation with dosowisko.net logo.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
struct burndtResources {
|
||||
ALLEGRO_SAMPLE *sample;
|
||||
ALLEGRO_SAMPLE_INSTANCE *sound;
|
||||
ALLEGRO_BITMAP *bitmap;
|
||||
int tick;
|
||||
};
|
|
@ -1,71 +0,0 @@
|
|||
/*! \file disclaimer.c
|
||||
* \brief Disclaimer about early release preview.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <allegro5/allegro_ttf.h>
|
||||
#include "../utils.h"
|
||||
#include "disclaimer.h"
|
||||
|
||||
int Gamestate_ProgressCount = 2;
|
||||
|
||||
void Gamestate_Logic(struct Game *game, struct DisclaimerResources* data) {}
|
||||
|
||||
void Gamestate_Draw(struct Game *game, struct DisclaimerResources* data) {
|
||||
al_clear_to_color(al_map_rgb(0,0,0));
|
||||
DrawTextWithShadow(data->font, al_map_rgb(255,255,255), game->viewport.width/2, game->viewport.height*0.3, ALLEGRO_ALIGN_CENTRE, "This is an early development preview of the game.");
|
||||
DrawTextWithShadow(data->font, al_map_rgb(255,255,255), game->viewport.width/2, game->viewport.height*0.4, ALLEGRO_ALIGN_CENTRE, "It's not supposed to be complete!");
|
||||
DrawTextWithShadow(data->font, al_map_rgb(255,255,255), game->viewport.width/2, game->viewport.height*0.5, ALLEGRO_ALIGN_CENTRE, "Keep in mind that everything may be changed");
|
||||
DrawTextWithShadow(data->font, al_map_rgb(255,255,255), game->viewport.width/2, game->viewport.height*0.6, ALLEGRO_ALIGN_CENTRE, "and many things surely will change.");
|
||||
DrawTextWithShadow(data->font_small, al_map_rgb(255,255,255), game->viewport.width/2, game->viewport.height*0.9, ALLEGRO_ALIGN_CENTRE, "Press any key to continue...");
|
||||
}
|
||||
|
||||
void Gamestate_Start(struct Game *game, struct DisclaimerResources* data) {
|
||||
FadeGamestate(game, true);
|
||||
}
|
||||
|
||||
void Gamestate_ProcessEvent(struct Game *game, struct DisclaimerResources* data, ALLEGRO_EVENT *ev) {
|
||||
if (ev->type==ALLEGRO_EVENT_KEY_DOWN) {
|
||||
SwitchGamestate(game, "disclaimer", "intro");
|
||||
}
|
||||
}
|
||||
|
||||
void* Gamestate_Load(struct Game *game, void (*progress)(struct Game*)) {
|
||||
struct DisclaimerResources *data = malloc(sizeof(struct DisclaimerResources));
|
||||
data->font_small = al_load_ttf_font(GetDataFilePath(game, "fonts/ShadowsIntoLight.ttf"),game->viewport.height*0.05,0 );
|
||||
(*progress)(game);
|
||||
data->font = al_load_ttf_font(GetDataFilePath(game, "fonts/ShadowsIntoLight.ttf"),game->viewport.height*0.065,0 );
|
||||
(*progress)(game);
|
||||
return data;
|
||||
}
|
||||
|
||||
void Gamestate_Stop(struct Game *game, struct DisclaimerResources* data) {
|
||||
FadeGamestate(game, false);
|
||||
}
|
||||
|
||||
void Gamestate_Unload(struct Game *game, struct DisclaimerResources* data) {
|
||||
al_destroy_font(data->font);
|
||||
al_destroy_font(data->font_small);
|
||||
free(data);
|
||||
}
|
||||
|
||||
void Gamestate_Reload(struct Game *game, struct DisclaimerResources* data) {}
|
||||
|
||||
void Gamestate_Resume(struct Game *game, struct DisclaimerResources* data) {}
|
||||
void Gamestate_Pause(struct Game *game, struct DisclaimerResources* data) {}
|
|
@ -1,24 +0,0 @@
|
|||
/*! \file disclaimer.h
|
||||
* \brief Disclaimer about early release preview - headers.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
struct DisclaimerResources {
|
||||
ALLEGRO_FONT *font, *font_small;
|
||||
};
|
|
@ -1,231 +0,0 @@
|
|||
/*! \file dosowisko.c
|
||||
* \brief Init animation with dosowisko.net logo.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <allegro5/allegro_ttf.h>
|
||||
#include <allegro5/allegro_primitives.h>
|
||||
#include <math.h>
|
||||
#include "../utils.h"
|
||||
#include "../timeline.h"
|
||||
#include "dosowisko.h"
|
||||
|
||||
int Gamestate_ProgressCount = 5;
|
||||
|
||||
static char* text = "# dosowisko.net";
|
||||
|
||||
bool FadeIn(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||
struct dosowiskoResources *data = action->arguments->value;
|
||||
if (state == TM_ACTIONSTATE_START) {
|
||||
data->fade=0;
|
||||
}
|
||||
else if (state == TM_ACTIONSTATE_DESTROY) {
|
||||
data->fade=255;
|
||||
}
|
||||
else if (state == TM_ACTIONSTATE_RUNNING) {
|
||||
data->fade+=2;
|
||||
data->tan++;
|
||||
return data->fade >= 255;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FadeOut(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||
struct dosowiskoResources *data = action->arguments->value;
|
||||
if (state == TM_ACTIONSTATE_START) {
|
||||
data->fadeout = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool End(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||
if (state == TM_ACTIONSTATE_RUNNING) SwitchGamestate(game, "dosowisko", "burndt");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Play(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||
ALLEGRO_SAMPLE_INSTANCE *data = action->arguments->value;
|
||||
if (state == TM_ACTIONSTATE_RUNNING) al_play_sample_instance(data);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Type(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||
struct dosowiskoResources *data = action->arguments->value;
|
||||
if (state == TM_ACTIONSTATE_RUNNING) {
|
||||
strncpy(data->text, text, data->pos++);
|
||||
data->text[data->pos] = 0;
|
||||
if (strcmp(data->text, text) != 0) {
|
||||
TM_AddBackgroundAction(data->timeline, Type, TM_AddToArgs(NULL, 1, data), 60 + rand() % 60, "type");
|
||||
} else{
|
||||
al_stop_sample_instance(data->kbd);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void Gamestate_Logic(struct Game *game, struct dosowiskoResources* data) {
|
||||
TM_Process(data->timeline);
|
||||
data->tick++;
|
||||
if (data->tick == 30) {
|
||||
data->underscore = !data->underscore;
|
||||
data->tick = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Gamestate_Draw(struct Game *game, struct dosowiskoResources* data) {
|
||||
|
||||
if (!data->fadeout) {
|
||||
|
||||
char t[255] = "";
|
||||
strcpy(t, data->text);
|
||||
if (data->underscore) {
|
||||
strncat(t, "_", 1);
|
||||
} else {
|
||||
strncat(t, " ", 1);
|
||||
}
|
||||
|
||||
al_set_target_bitmap(data->bitmap);
|
||||
al_clear_to_color(al_map_rgba(0,0,0,0));
|
||||
|
||||
al_draw_text(data->font, al_map_rgba(255,255,255,10), game->viewport.width/2, game->viewport.height*0.4167, ALLEGRO_ALIGN_CENTRE, t);
|
||||
|
||||
double tg = tan(-data->tan/384.0 * ALLEGRO_PI - ALLEGRO_PI/2);
|
||||
|
||||
int fade = data->fadeout ? 255 : data->fade;
|
||||
|
||||
al_set_target_bitmap(data->pixelator);
|
||||
al_clear_to_color(al_map_rgb(35, 31, 32));
|
||||
|
||||
al_draw_tinted_scaled_bitmap(data->bitmap, al_map_rgba(fade, fade, fade, fade), 0, 0, al_get_bitmap_width(data->bitmap), al_get_bitmap_height(data->bitmap), -tg*al_get_bitmap_width(data->bitmap)*0.05, -tg*al_get_bitmap_height(data->bitmap)*0.05, al_get_bitmap_width(data->bitmap)+tg*0.1*al_get_bitmap_width(data->bitmap), al_get_bitmap_height(data->bitmap)+tg*0.1*al_get_bitmap_height(data->bitmap), 0);
|
||||
|
||||
al_draw_bitmap(data->checkerboard, 0, 0, 0);
|
||||
|
||||
al_set_target_backbuffer(game->display);
|
||||
|
||||
al_draw_bitmap(data->pixelator, 0, 0, 0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void Gamestate_Start(struct Game *game, struct dosowiskoResources* data) {
|
||||
data->pos = 1;
|
||||
data->fade = 0;
|
||||
data->tan = 64;
|
||||
data->tick = 0;
|
||||
data->fadeout = false;
|
||||
data->underscore=true;
|
||||
strcpy(data->text, "#");
|
||||
TM_AddDelay(data->timeline, 300);
|
||||
TM_AddQueuedBackgroundAction(data->timeline, FadeIn, TM_AddToArgs(NULL, 1, data), 0, "fadein");
|
||||
TM_AddDelay(data->timeline, 1500);
|
||||
TM_AddAction(data->timeline, Play, TM_AddToArgs(NULL, 1, data->kbd), "playkbd");
|
||||
TM_AddQueuedBackgroundAction(data->timeline, Type, TM_AddToArgs(NULL, 1, data), 0, "type");
|
||||
TM_AddDelay(data->timeline, 3200);
|
||||
TM_AddAction(data->timeline, Play, TM_AddToArgs(NULL, 1, data->key), "playkey");
|
||||
TM_AddDelay(data->timeline, 50);
|
||||
TM_AddAction(data->timeline, FadeOut, TM_AddToArgs(NULL, 1, data), "fadeout");
|
||||
TM_AddDelay(data->timeline, 1000);
|
||||
TM_AddAction(data->timeline, End, NULL, "end");
|
||||
al_play_sample_instance(data->sound);
|
||||
}
|
||||
|
||||
void Gamestate_ProcessEvent(struct Game *game, struct dosowiskoResources* data, ALLEGRO_EVENT *ev) {
|
||||
TM_HandleEvent(data->timeline, ev);
|
||||
if ((ev->type==ALLEGRO_EVENT_KEY_DOWN) && (ev->keyboard.keycode == ALLEGRO_KEY_ESCAPE)) {
|
||||
SwitchGamestate(game, "dosowisko", "menu");
|
||||
}
|
||||
}
|
||||
|
||||
void* Gamestate_Load(struct Game *game, void (*progress)(struct Game*)) {
|
||||
struct dosowiskoResources *data = malloc(sizeof(struct dosowiskoResources));
|
||||
data->timeline = TM_Init(game, "main");
|
||||
data->bitmap = al_create_bitmap(game->viewport.width, game->viewport.height);
|
||||
data->checkerboard = al_create_bitmap(game->viewport.width, game->viewport.height);
|
||||
data->pixelator = al_create_bitmap(game->viewport.width, game->viewport.height);
|
||||
|
||||
al_set_target_bitmap(data->checkerboard);
|
||||
al_lock_bitmap(data->checkerboard, ALLEGRO_PIXEL_FORMAT_ANY, ALLEGRO_LOCK_WRITEONLY);
|
||||
int x, y;
|
||||
for (x = 0; x < al_get_bitmap_width(data->checkerboard); x=x+2) {
|
||||
for (y = 0; y < al_get_bitmap_height(data->checkerboard); y=y+2) {
|
||||
al_put_pixel(x, y, al_map_rgba(0,0,0,64));
|
||||
al_put_pixel(x+1, y, al_map_rgba(0,0,0,0));
|
||||
al_put_pixel(x, y+1, al_map_rgba(0,0,0,0));
|
||||
al_put_pixel(x+1, y+1, al_map_rgba(0,0,0,0));
|
||||
}
|
||||
}
|
||||
al_unlock_bitmap(data->checkerboard);
|
||||
al_set_target_backbuffer(game->display);
|
||||
(*progress)(game);
|
||||
|
||||
data->font = al_load_ttf_font(GetDataFilePath(game, "fonts/DejaVuSansMono.ttf"),game->viewport.height*0.1666,0 );
|
||||
(*progress)(game);
|
||||
data->sample = al_load_sample( GetDataFilePath(game, "dosowisko.flac") );
|
||||
data->sound = al_create_sample_instance(data->sample);
|
||||
al_attach_sample_instance_to_mixer(data->sound, game->audio.music);
|
||||
al_set_sample_instance_playmode(data->sound, ALLEGRO_PLAYMODE_ONCE);
|
||||
(*progress)(game);
|
||||
|
||||
data->kbd_sample = al_load_sample( GetDataFilePath(game, "kbd.flac") );
|
||||
data->kbd = al_create_sample_instance(data->kbd_sample);
|
||||
al_attach_sample_instance_to_mixer(data->kbd, game->audio.fx);
|
||||
al_set_sample_instance_playmode(data->kbd, ALLEGRO_PLAYMODE_ONCE);
|
||||
(*progress)(game);
|
||||
|
||||
data->key_sample = al_load_sample( GetDataFilePath(game, "key.flac") );
|
||||
data->key = al_create_sample_instance(data->key_sample);
|
||||
al_attach_sample_instance_to_mixer(data->key, game->audio.fx);
|
||||
al_set_sample_instance_playmode(data->key, ALLEGRO_PLAYMODE_ONCE);
|
||||
(*progress)(game);
|
||||
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void Gamestate_Stop(struct Game *game, struct dosowiskoResources* data) {
|
||||
al_stop_sample_instance(data->sound);
|
||||
al_stop_sample_instance(data->kbd);
|
||||
al_stop_sample_instance(data->key);
|
||||
}
|
||||
|
||||
void Gamestate_Unload(struct Game *game, struct dosowiskoResources* data) {
|
||||
al_destroy_font(data->font);
|
||||
al_destroy_sample_instance(data->sound);
|
||||
al_destroy_sample(data->sample);
|
||||
al_destroy_sample_instance(data->kbd);
|
||||
al_destroy_sample(data->kbd_sample);
|
||||
al_destroy_sample_instance(data->key);
|
||||
al_destroy_sample(data->key_sample);
|
||||
al_destroy_bitmap(data->bitmap);
|
||||
al_destroy_bitmap(data->checkerboard);
|
||||
al_destroy_bitmap(data->pixelator);
|
||||
TM_Destroy(data->timeline);
|
||||
free(data);
|
||||
}
|
||||
|
||||
void Gamestate_Reload(struct Game *game, struct dosowiskoResources* data) {}
|
||||
|
||||
void Gamestate_Resume(struct Game *game, struct dosowiskoResources* data) {
|
||||
TM_Resume(data->timeline);
|
||||
}
|
||||
void Gamestate_Pause(struct Game *game, struct dosowiskoResources* data) {
|
||||
TM_Pause(data->timeline);
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
/*! \file dosowisko.h
|
||||
* \brief Init animation with dosowisko.net logo.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
struct dosowiskoResources {
|
||||
ALLEGRO_FONT *font;
|
||||
ALLEGRO_SAMPLE *sample, *kbd_sample, *key_sample;
|
||||
ALLEGRO_SAMPLE_INSTANCE *sound, *kbd, *key;
|
||||
ALLEGRO_BITMAP *bitmap, *checkerboard, *pixelator;
|
||||
int pos, fade, tick, tan;
|
||||
char text[255];
|
||||
bool underscore, fadeout;
|
||||
struct Timeline *timeline;
|
||||
};
|
|
@ -1,94 +0,0 @@
|
|||
/*! \file dosowisko.c
|
||||
* \brief Init animation with dosowisko.net logo.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <allegro5/allegro_ttf.h>
|
||||
#include <allegro5/allegro_primitives.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "../utils.h"
|
||||
#include "../timeline.h"
|
||||
#include "../config.h"
|
||||
#include "info.h"
|
||||
|
||||
int Gamestate_ProgressCount = 1;
|
||||
|
||||
void Gamestate_Logic(struct Game *game, struct dosowiskoResources* data) {
|
||||
data->tick++;
|
||||
if (data->tick > 86) {
|
||||
SwitchGamestate(game, "info", "lollipop");
|
||||
}
|
||||
}
|
||||
|
||||
void Gamestate_Draw(struct Game *game, struct dosowiskoResources* data) {
|
||||
al_draw_bitmap(data->bitmap, 0, 0, 0);
|
||||
if ((data->tick / 11) % 2 == 0) {
|
||||
al_draw_bitmap(data->icon, 320 / 2 - al_get_bitmap_width(data->icon) / 2, 180 / 2 - al_get_bitmap_height(data->icon) / 2 , 0);
|
||||
}
|
||||
}
|
||||
|
||||
void Gamestate_Start(struct Game *game, struct dosowiskoResources* data) {
|
||||
data->tick = 0;
|
||||
al_grab_mouse(game->display);
|
||||
al_hide_mouse_cursor(game->display);
|
||||
al_play_sample_instance(data->sound);
|
||||
}
|
||||
|
||||
void Gamestate_ProcessEvent(struct Game *game, struct dosowiskoResources* data, ALLEGRO_EVENT *ev) {
|
||||
//TM_HandleEvent(data->timeline, ev);
|
||||
if ((ev->type==ALLEGRO_EVENT_KEY_DOWN) && (ev->keyboard.keycode == ALLEGRO_KEY_ESCAPE)) {
|
||||
SwitchGamestate(game, "info", "lollipop");
|
||||
}
|
||||
if ((ev->type==ALLEGRO_EVENT_KEY_DOWN) && (ev->keyboard.keycode == ALLEGRO_KEY_ENTER)) {
|
||||
SwitchGamestate(game, "info", "lollipop");
|
||||
}
|
||||
}
|
||||
|
||||
void* Gamestate_Load(struct Game *game, void (*progress)(struct Game*)) {
|
||||
struct dosowiskoResources *data = malloc(sizeof(struct dosowiskoResources));
|
||||
data->bitmap = al_load_bitmap( GetDataFilePath(game, "bg.png"));
|
||||
data->icon = al_load_bitmap( GetDataFilePath(game, "mouse.png"));
|
||||
|
||||
data->font = al_load_ttf_font(GetDataFilePath(game, "fonts/MonkeyIsland.ttf"),100,0 );
|
||||
(*progress)(game);
|
||||
|
||||
data->sample = al_load_sample( GetDataFilePath(game, "warning.flac") );
|
||||
|
||||
data->sound = al_create_sample_instance(data->sample);
|
||||
al_attach_sample_instance_to_mixer(data->sound, game->audio.fx);
|
||||
al_set_sample_instance_playmode(data->sound, ALLEGRO_PLAYMODE_ONCE);
|
||||
al_set_sample_instance_gain(data->sound, 1.25);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void Gamestate_Stop(struct Game *game, struct dosowiskoResources* data) {
|
||||
al_stop_sample_instance(data->sound);
|
||||
}
|
||||
|
||||
void Gamestate_Unload(struct Game *game, struct dosowiskoResources* data) {
|
||||
free(data);
|
||||
}
|
||||
|
||||
void Gamestate_Reload(struct Game *game, struct dosowiskoResources* data) {}
|
||||
|
||||
void Gamestate_Resume(struct Game *game, struct dosowiskoResources* data) {}
|
||||
void Gamestate_Pause(struct Game *game, struct dosowiskoResources* data) {}
|
|
@ -1,28 +0,0 @@
|
|||
/*! \file dosowisko.h
|
||||
* \brief Init animation with dosowisko.net logo.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
struct dosowiskoResources {
|
||||
ALLEGRO_FONT *font;
|
||||
ALLEGRO_BITMAP *bitmap, *icon;
|
||||
ALLEGRO_SAMPLE *sample;
|
||||
ALLEGRO_SAMPLE_INSTANCE *sound;
|
||||
int tick;
|
||||
};
|
|
@ -1,280 +0,0 @@
|
|||
/*! \file intro.c
|
||||
* \brief Intro view with plot description.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <allegro5/allegro_ttf.h>
|
||||
#include "../utils.h"
|
||||
#include "intro.h"
|
||||
|
||||
int Gamestate_ProgressCount = 11;
|
||||
|
||||
void AnimPage(struct Game *game, struct IntroResources *data, int page, ALLEGRO_COLOR tint) {
|
||||
int offset = 0;
|
||||
if (data->in_animation) offset = -1*game->viewport.width + (cos(((-1*((data->position)%game->viewport.width))/(float)game->viewport.width)*(ALLEGRO_PI))/2.0)*game->viewport.width + game->viewport.width/2.0;
|
||||
|
||||
int amount1 = 2, amount2 = 2;
|
||||
float anim = data->anim;
|
||||
|
||||
if (page==2) { amount1=4; amount2=3; }
|
||||
if (page==3) { amount1=3; amount2=3; }
|
||||
if (page==5) { amount1=5; amount2=3; anim*=2; }
|
||||
|
||||
if (page<6) al_draw_tinted_bitmap_region(data->animsprites[page-1],tint,al_get_bitmap_width(data->animsprites[page-1])/amount1*(int)fmod(anim,amount1),al_get_bitmap_height(data->animsprites[page-1])/amount2*(((int)(anim/amount1))%amount2),al_get_bitmap_width(data->animsprites[page-1])/amount1, al_get_bitmap_height(data->animsprites[page-1])/amount2,offset+game->viewport.width*0.09, game->viewport.height*0.18,0);
|
||||
|
||||
amount1 = 2;
|
||||
amount2 = 2;
|
||||
if (page==1) { amount1=4; amount2=3; }
|
||||
if (page==2) { amount1=3; amount2=3; }
|
||||
if (page==4) { amount1=5; amount2=3; anim*=2; }
|
||||
|
||||
if (page<5) al_draw_tinted_bitmap_region(data->animsprites[page],tint,al_get_bitmap_width(data->animsprites[page])/amount1*(int)fmod(anim,amount1),al_get_bitmap_height(data->animsprites[page])/amount2*(((int)(anim/amount1))%amount2),al_get_bitmap_width(data->animsprites[page])/amount1, al_get_bitmap_height(data->animsprites[page])/amount2,offset+game->viewport.width*1.09, game->viewport.height*0.18,0);
|
||||
}
|
||||
|
||||
void FillPage(struct Game *game, struct IntroResources *data, int page) {
|
||||
char filename[30] = { };
|
||||
snprintf(filename, 30, "intro/%d.flac", page);
|
||||
|
||||
data->audiostream = al_load_audio_stream(GetDataFilePath(game, filename), 4, 1024);
|
||||
al_attach_audio_stream_to_mixer(data->audiostream, game->audio.voice);
|
||||
al_set_audio_stream_playing(data->audiostream, false);
|
||||
al_set_audio_stream_gain(data->audiostream, 1.75);
|
||||
|
||||
al_set_target_bitmap(data->table);
|
||||
float y = 0.2;
|
||||
float oldx = -1;
|
||||
void draw_text(int page, char* text) {
|
||||
float x = 0.45;
|
||||
if (page!=oldx) { y=0.2; oldx=page; }
|
||||
DrawTextWithShadow(data->font, al_map_rgb(255,255,255), game->viewport.width*x, game->viewport.height*y, ALLEGRO_ALIGN_LEFT, text);
|
||||
y+=0.07;
|
||||
}
|
||||
|
||||
void DrawPage(int p) {
|
||||
switch (p) {
|
||||
case 1:
|
||||
al_hold_bitmap_drawing(true);
|
||||
al_draw_bitmap(data->table_bitmap, 0, 0, 0);
|
||||
al_hold_bitmap_drawing(true);
|
||||
draw_text(1, "Ever since Twilight Sparkle and her");
|
||||
draw_text(1, "friends imprisoned Discord in stone,");
|
||||
draw_text(1, "Equestria had been peaceful for");
|
||||
draw_text(1, "a long time.");
|
||||
al_hold_bitmap_drawing(false);
|
||||
break;
|
||||
case 2:
|
||||
al_draw_bitmap_region(data->table_bitmap, al_get_bitmap_width(data->table_bitmap)/2, 0, al_get_bitmap_width(data->table_bitmap)/2, al_get_bitmap_height(data->table_bitmap), game->viewport.width*0, 0, 0);
|
||||
al_draw_bitmap_region(data->table_bitmap, al_get_bitmap_width(data->table_bitmap)/2, 0, al_get_bitmap_width(data->table_bitmap)/2, al_get_bitmap_height(data->table_bitmap), game->viewport.width*0.5, 0, 0);
|
||||
al_hold_bitmap_drawing(false);
|
||||
al_hold_bitmap_drawing(true);
|
||||
draw_text(2, "Until one day a reckless pony caused");
|
||||
draw_text(2, "a tiny bit of chaos near Discord’s");
|
||||
draw_text(2, "statue.");
|
||||
al_hold_bitmap_drawing(false);
|
||||
break;
|
||||
case 3:
|
||||
al_hold_bitmap_drawing(true);
|
||||
al_draw_bitmap_region(data->table_bitmap, al_get_bitmap_width(data->table_bitmap)/2, 0, al_get_bitmap_width(data->table_bitmap)/2, al_get_bitmap_height(data->table_bitmap), game->viewport.width*0, 0, 0);
|
||||
al_draw_bitmap_region(data->table_bitmap, al_get_bitmap_width(data->table_bitmap)/2, 0, al_get_bitmap_width(data->table_bitmap)/2, al_get_bitmap_height(data->table_bitmap), game->viewport.width*0.5, 0, 0);
|
||||
al_hold_bitmap_drawing(false);
|
||||
al_hold_bitmap_drawing(true);
|
||||
draw_text(3, "This small amount of chaos was not");
|
||||
draw_text(3, "enough to free Discord, but enough");
|
||||
draw_text(3, "to turn discarded muffins into");
|
||||
draw_text(3, "vicious muffinzombies, with aim to");
|
||||
draw_text(3, "destroy all harmony in Equestria.");
|
||||
al_hold_bitmap_drawing(false);
|
||||
break;
|
||||
case 4:
|
||||
al_hold_bitmap_drawing(true);
|
||||
al_draw_bitmap_region(data->table_bitmap, al_get_bitmap_width(data->table_bitmap)/2, 0, al_get_bitmap_width(data->table_bitmap)/2, al_get_bitmap_height(data->table_bitmap), game->viewport.width*0, 0, 0);
|
||||
al_draw_bitmap_region(data->table_bitmap, al_get_bitmap_width(data->table_bitmap)/2, 0, al_get_bitmap_width(data->table_bitmap)/2, al_get_bitmap_height(data->table_bitmap), game->viewport.width*0.5, 0, 0);
|
||||
al_hold_bitmap_drawing(false);
|
||||
al_hold_bitmap_drawing(true);
|
||||
draw_text(4, "Discord, learning from his last failure,");
|
||||
draw_text(4, "turned his muffinzombies against Twilight");
|
||||
draw_text(4, "and her friends, trapping them in their");
|
||||
draw_text(4, "own homes. With the bearers of the");
|
||||
draw_text(4, "Elements out of the way, he now waits");
|
||||
draw_text(4, "until chaos takes hold of the world,");
|
||||
draw_text(4, "so he can rule Equestria once again.");
|
||||
al_hold_bitmap_drawing(false);
|
||||
break;
|
||||
case 5:
|
||||
al_hold_bitmap_drawing(true);
|
||||
al_draw_bitmap_region(data->table_bitmap, al_get_bitmap_width(data->table_bitmap)/2, 0, al_get_bitmap_width(data->table_bitmap)/2, al_get_bitmap_height(data->table_bitmap), game->viewport.width*0, 0, 0);
|
||||
al_draw_bitmap_region(data->table_bitmap, al_get_bitmap_width(data->table_bitmap)/2, 0, al_get_bitmap_width(data->table_bitmap)/2, al_get_bitmap_height(data->table_bitmap), game->viewport.width*0.5, 0, 0);
|
||||
al_hold_bitmap_drawing(false);
|
||||
al_hold_bitmap_drawing(true);
|
||||
draw_text(5, "Who can defeat Discord without");
|
||||
draw_text(5, "the Elements of Harmony?");
|
||||
draw_text(5, "");
|
||||
draw_text(5, "Well... There is somepony who knows");
|
||||
draw_text(5, "all about muffins...");
|
||||
al_hold_bitmap_drawing(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
DrawPage(page);
|
||||
ALLEGRO_BITMAP* second = al_create_bitmap(game->viewport.width, game->viewport.height);
|
||||
al_set_target_bitmap(second);
|
||||
DrawPage(page+1);
|
||||
al_set_target_bitmap(data->table);
|
||||
al_draw_bitmap(second, game->viewport.width, 0, 0);
|
||||
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||
al_destroy_bitmap(second);
|
||||
}
|
||||
|
||||
void Gamestate_Logic(struct Game *game, struct IntroResources* data) {
|
||||
data->anim += 1.0/20.0;
|
||||
if (data->in_animation) {
|
||||
int old = data->position%game->viewport.width;
|
||||
data->position -= game->viewport.width*0.0078125 > 1 ? game->viewport.width*0.0078125 : 1;
|
||||
if (data->position%game->viewport.width>old) {
|
||||
data->in_animation = false;
|
||||
FillPage(game, data, data->page+1);
|
||||
PrintConsole(game, "Animation finished.");
|
||||
al_set_audio_stream_playing(data->audiostream, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Gamestate_Draw(struct Game *game, struct IntroResources* data) {
|
||||
al_clear_to_color(al_map_rgb(0,0,0));
|
||||
if (data->in_animation) {
|
||||
al_draw_bitmap(data->table, -1*game->viewport.width + (cos(((-1*((data->position)%game->viewport.width))/(float)game->viewport.width)*(ALLEGRO_PI))/2.0)*game->viewport.width + game->viewport.width/2.0, 0, 0);
|
||||
AnimPage(game, data, data->page, al_map_rgba_f(1,1,1,1));
|
||||
}
|
||||
else {
|
||||
al_draw_bitmap(data->table, 0, 0, 0);
|
||||
AnimPage(game, data, data->page+1, al_map_rgba_f(1,1,1,1));
|
||||
}
|
||||
DrawTextWithShadow(data->font, al_map_rgb(255,255,255), game->viewport.width/2, game->viewport.height*0.88, ALLEGRO_ALIGN_CENTRE, "Press any key to continue or escape to skip...");
|
||||
al_draw_bitmap(data->frame, 0, 0, 0);
|
||||
/*PrintConsole(game, "drawing");*/
|
||||
if (data->in_animation && data->position<=-4*game->viewport.width) {
|
||||
PrintConsole(game, "This was the last page.");
|
||||
data->in_animation = false;
|
||||
data->page--;
|
||||
StopGamestate(game, "intro");
|
||||
LoadGamestate(game, "map");
|
||||
StartGamestate(game, "map");
|
||||
}
|
||||
}
|
||||
|
||||
void Gamestate_Start(struct Game *game, struct IntroResources* data) {
|
||||
data->audiostream = NULL;
|
||||
data->position = 0;
|
||||
data->page = 0;
|
||||
data->in_animation = false;
|
||||
data->anim = 0;
|
||||
|
||||
FillPage(game, data, 1);
|
||||
al_play_sample_instance(data->music);
|
||||
FadeGamestate(game, true);
|
||||
al_set_audio_stream_playing(data->audiostream, true);
|
||||
}
|
||||
|
||||
void Gamestate_ProcessEvent(struct Game *game, struct IntroResources* data, ALLEGRO_EVENT *ev) {
|
||||
if (ev->type != ALLEGRO_EVENT_KEY_DOWN) return;
|
||||
if (ev->keyboard.keycode == ALLEGRO_KEY_ESCAPE) {
|
||||
StopGamestate(game, "intro");
|
||||
LoadGamestate(game, "map");
|
||||
StartGamestate(game, "map");
|
||||
return;
|
||||
}
|
||||
if (!data->in_animation) {
|
||||
if (data->audiostream) {
|
||||
al_set_audio_stream_playing(data->audiostream, false);
|
||||
al_destroy_audio_stream(data->audiostream);
|
||||
data->audiostream=NULL;
|
||||
}
|
||||
PrintConsole(game, "Animate page (was on %d)...", ++data->page);
|
||||
data->in_animation = true;
|
||||
}
|
||||
}
|
||||
|
||||
void* Gamestate_Load(struct Game *game, void (*progress)(struct Game*)) {
|
||||
struct IntroResources *data = malloc(sizeof(struct IntroResources));
|
||||
|
||||
data->animsprites[0] = LoadScaledBitmap(game, "intro/1.png", (int)(game->viewport.height*1.6*0.3125)*2, game->viewport.height*0.63*2);
|
||||
(*progress)(game);
|
||||
data->animsprites[1] = LoadScaledBitmap(game, "intro/2.png", (int)(game->viewport.height*1.7*0.3125)*4, game->viewport.height*0.47*3);
|
||||
(*progress)(game);
|
||||
data->animsprites[2] = LoadScaledBitmap(game, "intro/3.png", (int)(game->viewport.height*1.6*0.3125)*3, game->viewport.height*0.63*3);
|
||||
(*progress)(game);
|
||||
data->animsprites[3] = LoadScaledBitmap(game, "intro/4.png", (int)(game->viewport.height*1.6*0.3125)*2, game->viewport.height*0.63*2);
|
||||
(*progress)(game);
|
||||
data->animsprites[4] = LoadScaledBitmap(game, "intro/5.png", (int)(game->viewport.height*1.6*0.3125)*5, game->viewport.height*0.63*3);
|
||||
(*progress)(game);
|
||||
|
||||
data->table_bitmap =LoadScaledBitmap(game, "intro/paper.png", game->viewport.width, game->viewport.height);
|
||||
(*progress)(game);
|
||||
data->frame =LoadScaledBitmap(game, "intro/frame.png", game->viewport.width, game->viewport.height);
|
||||
(*progress)(game);
|
||||
|
||||
data->sample = al_load_sample( GetDataFilePath(game, "intro/intro.flac") );
|
||||
(*progress)(game);
|
||||
|
||||
data->music = al_create_sample_instance(data->sample);
|
||||
al_attach_sample_instance_to_mixer(data->music, game->audio.music);
|
||||
al_set_sample_instance_gain(data->music, 0.75);
|
||||
al_set_sample_instance_playmode(data->music, ALLEGRO_PLAYMODE_LOOP);
|
||||
(*progress)(game);
|
||||
|
||||
if (!data->sample){
|
||||
fprintf(stderr, "Audio clip sample not loaded!\n" );
|
||||
exit(-1);
|
||||
}
|
||||
data->table = al_create_bitmap(game->viewport.width*2, game->viewport.height);
|
||||
(*progress)(game);
|
||||
|
||||
data->font = al_load_ttf_font(GetDataFilePath(game, "fonts/ShadowsIntoLight.ttf"),game->viewport.height*0.04,0 );
|
||||
(*progress)(game);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void Gamestate_Unload(struct Game *game, struct IntroResources* data) {
|
||||
al_destroy_bitmap(data->frame);
|
||||
al_destroy_bitmap(data->table);
|
||||
int i;
|
||||
for (i=0; i<5; i++) {
|
||||
al_destroy_bitmap(data->animsprites[i]);
|
||||
}
|
||||
al_destroy_font(data->font);
|
||||
al_destroy_sample_instance(data->music);
|
||||
al_destroy_sample(data->sample);
|
||||
al_destroy_bitmap(data->table_bitmap);
|
||||
}
|
||||
|
||||
void Gamestate_Stop(struct Game *game, struct IntroResources* data) {
|
||||
FadeGamestate(game, false);
|
||||
if (data->audiostream) {
|
||||
al_set_audio_stream_playing(data->audiostream, false);
|
||||
al_destroy_audio_stream(data->audiostream);
|
||||
}
|
||||
al_stop_sample_instance(data->music);
|
||||
}
|
||||
|
||||
void Gamestate_Pause(struct Game *game, struct IntroResources* data) {}
|
||||
void Gamestate_Resume(struct Game *game, struct IntroResources* data) {}
|
||||
void Gamestate_Reload(struct Game *game, struct IntroResources* data) {}
|
|
@ -1,40 +0,0 @@
|
|||
/*! \file intro.h
|
||||
* \brief Intro view headers.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <allegro5/allegro.h>
|
||||
#include <allegro5/allegro_font.h>
|
||||
#include <allegro5/allegro_audio.h>
|
||||
|
||||
/*! \brief Resources used by Intro state. */
|
||||
struct IntroResources {
|
||||
int position; /*!< Position of the page. */
|
||||
int page; /*!< Current page number. */
|
||||
bool in_animation; /*!< Animation as in page transition animation. */
|
||||
float anim; /*!< Counter used for spritesheet animations. */
|
||||
ALLEGRO_BITMAP *table; /*!< Background paper bitmap, two pages long. */
|
||||
ALLEGRO_BITMAP *table_bitmap; /*!< Unscaled background paper bitmap. */
|
||||
ALLEGRO_BITMAP *frame; /*!< Bitmap with frame around the screen. */
|
||||
ALLEGRO_BITMAP *animsprites[5]; /*!< Array with spritesheet bitmaps. */
|
||||
ALLEGRO_FONT *font; /*!< Font used for text. */
|
||||
ALLEGRO_SAMPLE *sample; /*!< Background music sample. */
|
||||
ALLEGRO_SAMPLE_INSTANCE *music; /*!< Sample instance with background music. */
|
||||
ALLEGRO_AUDIO_STREAM *audiostream; /*!< Audiostream used for Celestia voice. */
|
||||
};
|
|
@ -1,709 +0,0 @@
|
|||
/*! \file menu.c
|
||||
* \brief Main Menu view.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <allegro5/allegro_ttf.h>
|
||||
#include <allegro5/allegro_primitives.h>
|
||||
#include "../config.h"
|
||||
#include "../utils.h"
|
||||
#include "../timeline.h"
|
||||
#include "level.h"
|
||||
|
||||
#define TILE_SIZE 20
|
||||
#define MAX_FUN 250.0
|
||||
#define FLOOR_OF_FUN 0.68
|
||||
#define CEIL_OF_FUN 0.88
|
||||
|
||||
int Gamestate_ProgressCount = 8;
|
||||
|
||||
void SaveScore(struct Game *game, struct LevelResources *data) {
|
||||
|
||||
if (((data->score / (double)(data->time / 10)) > (data->savedScore / (double)data->savedTime)) || ((data->score / (double)(data->time / 10)) == (data->savedScore / (double)data->savedTime) && (data->score > data->savedScore))) {
|
||||
char *text = malloc(255*sizeof(char));
|
||||
snprintf(text, 255, "%d", data->score);
|
||||
SetConfigOption(game, "TickleMonster", "score", text);
|
||||
snprintf(text, 255, "%d", data->time / 10);
|
||||
SetConfigOption(game, "TickleMonster", "time", text);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void AnimateBadguys(struct Game *game, struct LevelResources *data, int i) {
|
||||
struct Kid *tmp = data->kids[i];
|
||||
while (tmp) {
|
||||
AnimateCharacter(game, tmp->character, tmp->tickled ? 1 : tmp->speed * data->kidSpeed);
|
||||
tmp=tmp->next;
|
||||
}
|
||||
}
|
||||
|
||||
void MoveBadguys(struct Game *game, struct LevelResources *data, int i, float dx) {
|
||||
struct Kid *tmp = data->kids[i];
|
||||
while (tmp) {
|
||||
|
||||
if (!tmp->grownup) {
|
||||
if ((!tmp->character->spritesheet->kill) && (!tmp->tickled)) {
|
||||
MoveCharacter(game, tmp->character, dx * tmp->speed * data->kidSpeed, 0, 0);
|
||||
}
|
||||
|
||||
if (tmp->character->x < 30) {
|
||||
if (tmp->fun > FLOOR_OF_FUN * MAX_FUN && tmp->fun < CEIL_OF_FUN * MAX_FUN) {
|
||||
tmp->happy = true;
|
||||
al_set_sample_instance_playing(data->click, true);
|
||||
data->score++;
|
||||
} else {
|
||||
if (rand() % 3 == 0) {
|
||||
tmp->grownup = true;
|
||||
tmp->right = true;
|
||||
tmp->character->spritesheets = data->suit->spritesheets;
|
||||
SelectSpritesheet(game, tmp->character, "walk");
|
||||
MoveCharacter(game, tmp->character, 0, -8, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// grownup
|
||||
MoveCharacter(game, tmp->character, (tmp->right ? -1 : 1) * dx * tmp->speed * data->kidSpeed / 2, 0, 0);
|
||||
if (tmp->character->x > 270) {
|
||||
tmp->right = false;
|
||||
} else if (tmp->character->x < 42) {
|
||||
if (rand() % 2) { // 50% chance for getting rid
|
||||
tmp->right = true;
|
||||
} else {
|
||||
if (!tmp->right) {
|
||||
tmp->happy = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tmp->grownup) {
|
||||
if ((tmp->character->x > data->monster->x) && (tmp->character->x + 10 < data->monster->x + 20) && (abs(tmp->character->y - data->monster->y) < 5)) {
|
||||
data->lost = true;
|
||||
al_stop_sample_instance(data->laughter);
|
||||
al_stop_timer(data->timer);
|
||||
SaveScore(game, data);
|
||||
}
|
||||
}
|
||||
|
||||
if (tmp->happy) {
|
||||
if (tmp->prev) {
|
||||
tmp->prev->next = tmp->next;
|
||||
if (tmp->next) tmp->next->prev = tmp->prev;
|
||||
} else {
|
||||
data->kids[i] = tmp->next;
|
||||
if (tmp->next) tmp->next->prev = NULL;
|
||||
}
|
||||
struct Kid *old = tmp;
|
||||
tmp = tmp->next;
|
||||
old->character->dead = true;
|
||||
old->prev = NULL;
|
||||
old->next = data->destroyQueue;
|
||||
if (data->destroyQueue) data->destroyQueue->prev = old;
|
||||
data->destroyQueue = old;
|
||||
} else {
|
||||
tmp = tmp->next;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void CheckForEnd(struct Game *game, struct LevelResources *data) {
|
||||
return;
|
||||
|
||||
int i;
|
||||
bool lost = false;
|
||||
for (i=0; i<6; i++) {
|
||||
struct Kid *tmp = data->kids[i];
|
||||
while (tmp) {
|
||||
if (tmp->character->x <= (139-(i*10))-10) {
|
||||
lost = true;
|
||||
break;
|
||||
}
|
||||
tmp=tmp->next;
|
||||
}
|
||||
if (lost) break;
|
||||
}
|
||||
|
||||
if (lost) {
|
||||
|
||||
data->soloactive=false;
|
||||
data->soloanim=0;
|
||||
data->soloflash=0;
|
||||
data->soloready=0;
|
||||
|
||||
SelectSpritesheet(game, data->monster, "cry");
|
||||
}
|
||||
}
|
||||
|
||||
void DrawBadguys(struct Game *game, struct LevelResources *data, int i) {
|
||||
struct Kid *tmp = data->kids[i];
|
||||
while (tmp) {
|
||||
if (!tmp->happy) {
|
||||
DrawCharacter(game, tmp->character, al_map_rgb(255,255,255), (tmp->grownup && !tmp->right) ? ALLEGRO_FLIP_HORIZONTAL : 0);
|
||||
}
|
||||
tmp=tmp->next;
|
||||
}
|
||||
}
|
||||
|
||||
void Gamestate_Draw(struct Game *game, struct LevelResources* data) {
|
||||
|
||||
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||
|
||||
al_clear_to_color(al_map_rgb(3, 213, 255));
|
||||
|
||||
al_draw_bitmap(data->bg,0, 0,0);
|
||||
|
||||
for (int i=0; i<6; i++) {
|
||||
DrawBadguys(game, data, i);
|
||||
if ((int)((data->monster->y + 18) / 20) > i) {
|
||||
DrawCharacter(game, data->monster, al_map_rgb(255,255,255), 0);
|
||||
}
|
||||
}
|
||||
|
||||
al_draw_bitmap(data->buildings,0, 0,0);
|
||||
if (data->savedScore) {
|
||||
al_draw_bitmap(data->hid2,0, 0,0);
|
||||
} else {
|
||||
al_draw_bitmap(data->hid,0, 0,0);
|
||||
}
|
||||
|
||||
if (data->tickling && data->haskid) {
|
||||
al_draw_bitmap(data->meter,0, 0,0);
|
||||
int length = (data->tickledKid->fun / MAX_FUN) * 151;
|
||||
al_draw_filled_rectangle(160, 163, 160 + ((length > 151) ? 151 : length), 173, al_map_rgb(255,255,255));
|
||||
if ((data->tickledKid->fun / MAX_FUN) > FLOOR_OF_FUN) {
|
||||
al_draw_filled_rectangle(160 + 151 * FLOOR_OF_FUN, 163, 160 + ((length > 151 * CEIL_OF_FUN) ? (151 * CEIL_OF_FUN) : length), 173, al_map_rgb(192, 255, 192));
|
||||
}
|
||||
}
|
||||
|
||||
if (data->soloflash) {
|
||||
al_draw_filled_rectangle(0, 0, 320, 180, al_map_rgb(255,255,255));
|
||||
}
|
||||
|
||||
char *text = malloc(255*sizeof(char));
|
||||
snprintf(text, 255, "%d", data->score);
|
||||
DrawTextWithShadow(data->font, al_map_rgb(255,255,255), 21, 162, 0, text);
|
||||
snprintf(text, 255, "%d", data->time / 10);
|
||||
DrawTextWithShadow(data->font, al_map_rgb(255,255,255), 61, 162, 0, text);
|
||||
if (data->savedScore) {
|
||||
snprintf(text, 255, "%d / %d", data->savedScore, data->savedTime);
|
||||
DrawTextWithShadow(data->font, al_map_rgb(255,255,255), 106, 162, 0, text);
|
||||
}
|
||||
free(text);
|
||||
|
||||
if (data->lost) {
|
||||
al_draw_filled_rectangle(0, 0, 320, 180, al_map_rgba(0,0,0,128));
|
||||
al_draw_bitmap(data->busted,0, 0,0);
|
||||
|
||||
char *text = malloc(255*sizeof(char));
|
||||
snprintf(text, 255, "Score: %d", data->score);
|
||||
DrawTextWithShadow(data->font, al_map_rgb(255,255,255), 200, 118, 0, text);
|
||||
snprintf(text, 255, "Time: %d", data->time / 10);
|
||||
DrawTextWithShadow(data->font, al_map_rgb(255,255,255), 200, 128, 0, text);
|
||||
free(text);
|
||||
}
|
||||
|
||||
if (data->paused) {
|
||||
al_draw_filled_rectangle(0, 0, 320, 180, al_map_rgba(0,0,0,128));
|
||||
DrawTextWithShadow(data->font, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.5 - 25, ALLEGRO_ALIGN_CENTRE, "Game paused!");
|
||||
DrawTextWithShadow(data->font, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.5 + 5, ALLEGRO_ALIGN_CENTRE, "SPACE to resume");
|
||||
DrawTextWithShadow(data->font, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.5 + 15, ALLEGRO_ALIGN_CENTRE, "ESCAPE to leave");
|
||||
}
|
||||
}
|
||||
|
||||
void AddBadguy(struct Game *game, struct LevelResources* data, int i) {
|
||||
struct Kid *n = malloc(sizeof(struct Kid));
|
||||
n->next = NULL;
|
||||
n->prev = NULL;
|
||||
n->speed = (rand() % 3) * 0.25 + 1;
|
||||
n->tickled = false;
|
||||
n->grownup = false;
|
||||
n->happy = false;
|
||||
n->fun = 0;
|
||||
n->character = CreateCharacter(game, "kid");
|
||||
n->character->spritesheets = data->kid->spritesheets;
|
||||
n->character->shared = true;
|
||||
SelectSpritesheet(game, n->character, "walk");
|
||||
SetCharacterPosition(game, n->character, 280, 20+(i*TILE_SIZE), 0);
|
||||
|
||||
if (data->kids[i]) {
|
||||
struct Kid *tmp = data->kids[i];
|
||||
while (tmp->next) {
|
||||
tmp=tmp->next;
|
||||
}
|
||||
tmp->next = n;
|
||||
n->prev = tmp;
|
||||
} else {
|
||||
data->kids[i] = n;
|
||||
}
|
||||
}
|
||||
|
||||
void Fire(struct Game *game, struct LevelResources *data) {
|
||||
|
||||
if (data->movedown || data->moveup) return;
|
||||
|
||||
if (data->tickling) {
|
||||
|
||||
if (data->haskid) {
|
||||
data->tickledKid->tickled = false;
|
||||
SelectSpritesheet(game, data->tickledKid->character, "walk");
|
||||
data->haskid = false;
|
||||
al_set_sample_instance_playing(data->laughter, false);
|
||||
MoveCharacter(game, data->tickledKid->character, 0, 3, 0);
|
||||
data->tickledKid = NULL;
|
||||
}
|
||||
|
||||
SelectSpritesheet(game, data->monster, "stand");
|
||||
MoveCharacter(game, data->monster, 2, -2, 0);
|
||||
data->tickling = false;
|
||||
return;
|
||||
}
|
||||
|
||||
SelectSpritesheet(game, data->monster, "ticklefail");
|
||||
MoveCharacter(game, data->monster, -2, 2, 0);
|
||||
|
||||
data->tickling = true;
|
||||
|
||||
//PrintConsole(game, "MONSTAH %f", data->monster->x);
|
||||
}
|
||||
|
||||
void Gamestate_Logic(struct Game *game, struct LevelResources* data) {
|
||||
|
||||
if ((data->lost) || (data->paused)) return;
|
||||
|
||||
if (strcmp(data->monster->spritesheet->name, "fail") == 0) {
|
||||
data->tickling = false;
|
||||
MoveCharacter(game, data->monster, 2, -2, 0);
|
||||
SelectSpritesheet(game, data->monster, "stand");
|
||||
}
|
||||
|
||||
if (data->tickling) {
|
||||
if (!data->haskid) {
|
||||
struct Kid *tmp = data->kids[(int)((data->monster->y - 15) / 20)];
|
||||
while (tmp) {
|
||||
if ((tmp->character->x > data->monster->x + 16) && (tmp->character->x < data->monster->x + 23)) {
|
||||
if (tmp->grownup) {
|
||||
data->lost = true;
|
||||
al_stop_sample_instance(data->laughter);
|
||||
al_stop_timer(data->timer);
|
||||
SaveScore(game, data);
|
||||
} else {
|
||||
tmp->tickled = true;
|
||||
SelectSpritesheet(game, data->monster, "tickle");
|
||||
SelectSpritesheet(game, tmp->character, "laugh");
|
||||
data->haskid = true;
|
||||
data->tickledKid = tmp;
|
||||
SetCharacterPosition(game, tmp->character, data->monster->x + 22, tmp->character->y - 3, 0);
|
||||
al_set_sample_instance_playing(data->laughter, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
tmp=tmp->next;
|
||||
}
|
||||
}
|
||||
|
||||
if (data->haskid) {
|
||||
data->tickledKid->fun++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (data->keys.lastkey == data->keys.key) {
|
||||
data->keys.delay = data->keys.lastdelay; // workaround for random bugus UP/DOWN events
|
||||
}
|
||||
|
||||
if (data->moveup && data->monster->y < 14) {
|
||||
data->moveup = false;
|
||||
}
|
||||
if (data->movedown && data->monster->y > 112) {
|
||||
data->movedown = false;
|
||||
}
|
||||
|
||||
if (data->moveup) {
|
||||
MoveCharacter(game, data->monster, 0, -1, 0);
|
||||
} else if (data->movedown) {
|
||||
MoveCharacter(game, data->monster, 0, 1, 0);
|
||||
}
|
||||
|
||||
if ((int)(data->monster->y + 7) % TILE_SIZE == 0) {
|
||||
data->moveup = false;
|
||||
data->movedown = false;
|
||||
}
|
||||
|
||||
data->cloud_position-=0.1;
|
||||
if (data->cloud_position<-40) { data->cloud_position=100; PrintConsole(game, "cloud_position"); }
|
||||
AnimateCharacter(game, data->monster, 1);
|
||||
|
||||
if ((data->keys.key) && (data->keys.delay < 3)) {
|
||||
|
||||
if (!data->tickling) {
|
||||
if (data->keys.key==ALLEGRO_KEY_LEFT) {
|
||||
if (data->monster->x > 42) {
|
||||
MoveCharacter(game, data->monster, -1, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (data->keys.key==ALLEGRO_KEY_RIGHT) {
|
||||
if (data->monster->x < 256) {
|
||||
MoveCharacter(game, data->monster, 1, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (data->keys.delay == INT_MIN) data->keys.delay = 3;
|
||||
else data->keys.delay += 3;
|
||||
|
||||
} else if (data->keys.key) {
|
||||
data->keys.delay-=3;
|
||||
}
|
||||
|
||||
AnimateBadguys(game, data, 0);
|
||||
AnimateBadguys(game, data, 1);
|
||||
AnimateBadguys(game, data, 2);
|
||||
AnimateBadguys(game, data, 3);
|
||||
AnimateBadguys(game, data, 4);
|
||||
AnimateBadguys(game, data, 5);
|
||||
|
||||
MoveBadguys(game, data, 0, -0.17);
|
||||
MoveBadguys(game, data, 1, -0.18);
|
||||
MoveBadguys(game, data, 2, -0.19);
|
||||
MoveBadguys(game, data, 3, -0.2);
|
||||
MoveBadguys(game, data, 4, -0.21);
|
||||
MoveBadguys(game, data, 5, -0.22);
|
||||
|
||||
data->timeTillNextBadguy--;
|
||||
if (data->timeTillNextBadguy <= 0) {
|
||||
data->timeTillNextBadguy = data->kidRate * 2;
|
||||
data->kidRate -= data->kidRate * 0.005;
|
||||
if (data->kidRate < 50) {
|
||||
data->kidRate = 50;
|
||||
}
|
||||
|
||||
data->kidSpeed+= 0.0005;
|
||||
AddBadguy(game, data, rand() % 6);
|
||||
}
|
||||
|
||||
if (data->usage) { data->usage--; }
|
||||
if (data->lightanim) { data->lightanim++;}
|
||||
if (data->lightanim > 25) { data->lightanim = 0; }
|
||||
|
||||
CheckForEnd(game, data);
|
||||
|
||||
data->soloanim++;
|
||||
if (data->soloanim >= 60) data->soloanim=0;
|
||||
|
||||
if (data->soloflash) data->soloflash--;
|
||||
|
||||
data->keys.lastkey = data->keys.key;
|
||||
data->keys.lastdelay = data->keys.delay;
|
||||
|
||||
TM_Process(data->timeline);
|
||||
}
|
||||
|
||||
void* Gamestate_Load(struct Game *game, void (*progress)(struct Game*)) {
|
||||
|
||||
struct LevelResources *data = malloc(sizeof(struct LevelResources));
|
||||
|
||||
data->timer = al_create_timer(0.1);
|
||||
al_register_event_source(game->_priv.event_queue, al_get_timer_event_source(data->timer));
|
||||
|
||||
data->timeline = TM_Init(game, "main");
|
||||
(*progress)(game);
|
||||
|
||||
data->bg = al_load_bitmap( GetDataFilePath(game, "bg2.png") );
|
||||
data->buildings = al_load_bitmap( GetDataFilePath(game, "buildings.png") );
|
||||
data->hid = al_load_bitmap( GetDataFilePath(game, "hid.png") );
|
||||
data->hid2 = al_load_bitmap( GetDataFilePath(game, "hid2.png") );
|
||||
data->meter = al_load_bitmap( GetDataFilePath(game, "meter.png") );
|
||||
data->busted = al_load_bitmap( GetDataFilePath(game, "busted.png") );
|
||||
data->click_sample = al_load_sample( GetDataFilePath(game, "point.flac") );
|
||||
(*progress)(game);
|
||||
|
||||
data->click = al_create_sample_instance(data->click_sample);
|
||||
al_attach_sample_instance_to_mixer(data->click, game->audio.fx);
|
||||
al_set_sample_instance_playmode(data->click, ALLEGRO_PLAYMODE_ONCE);
|
||||
(*progress)(game);
|
||||
|
||||
|
||||
data->sample = al_load_sample( GetDataFilePath(game, "laughter.flac") );
|
||||
(*progress)(game);
|
||||
|
||||
data->laughter = al_create_sample_instance(data->sample);
|
||||
al_attach_sample_instance_to_mixer(data->laughter, game->audio.fx);
|
||||
al_set_sample_instance_playmode(data->laughter, ALLEGRO_PLAYMODE_LOOP);
|
||||
(*progress)(game);
|
||||
|
||||
data->font_title = al_load_ttf_font(GetDataFilePath(game, "fonts/MonkeyIsland.ttf"),game->viewport.height*0.16,0 );
|
||||
data->font = al_load_ttf_font(GetDataFilePath(game, "fonts/MonkeyIsland.ttf"),12,0 );
|
||||
(*progress)(game);
|
||||
|
||||
data->monster = CreateCharacter(game, "monster");
|
||||
RegisterSpritesheet(game, data->monster, "stand");
|
||||
RegisterSpritesheet(game, data->monster, "tickle");
|
||||
RegisterSpritesheet(game, data->monster, "ticklefail");
|
||||
RegisterSpritesheet(game, data->monster, "fail");
|
||||
RegisterSpritesheet(game, data->monster, "jump");
|
||||
LoadSpritesheets(game, data->monster);
|
||||
(*progress)(game);
|
||||
|
||||
data->suit = CreateCharacter(game, "suit");
|
||||
RegisterSpritesheet(game, data->suit, "walk");
|
||||
LoadSpritesheets(game, data->suit);
|
||||
(*progress)(game);
|
||||
|
||||
data->kid = CreateCharacter(game, "kid");
|
||||
RegisterSpritesheet(game, data->kid, "walk");
|
||||
RegisterSpritesheet(game, data->kid, "laugh");
|
||||
LoadSpritesheets(game, data->kid);
|
||||
|
||||
al_set_target_backbuffer(game->display);
|
||||
return data;
|
||||
}
|
||||
|
||||
void DestroyBadguys(struct Game *game, struct LevelResources* data, int i) {
|
||||
struct Kid *tmp = data->kids[i];
|
||||
if (!tmp) {
|
||||
tmp = data->destroyQueue;
|
||||
data->destroyQueue = NULL;
|
||||
}
|
||||
while (tmp) {
|
||||
DestroyCharacter(game, tmp->character);
|
||||
struct Kid *old = tmp;
|
||||
tmp = tmp->next;
|
||||
free(old);
|
||||
if ((!tmp) && (data->destroyQueue)) {
|
||||
tmp = data->destroyQueue;
|
||||
data->destroyQueue = NULL;
|
||||
}
|
||||
}
|
||||
data->kids[i] = NULL;
|
||||
}
|
||||
|
||||
void Gamestate_Stop(struct Game *game, struct LevelResources* data) {
|
||||
int i;
|
||||
for (i=0; i<6; i++) {
|
||||
DestroyBadguys(game, data, i);
|
||||
}
|
||||
al_set_sample_instance_playing(data->laughter, false);
|
||||
}
|
||||
|
||||
void Gamestate_Unload(struct Game *game, struct LevelResources* data) {
|
||||
al_destroy_bitmap(data->bg);
|
||||
al_destroy_bitmap(data->buildings);
|
||||
al_destroy_bitmap(data->hid);
|
||||
al_destroy_bitmap(data->hid2);
|
||||
al_destroy_bitmap(data->meter);
|
||||
al_destroy_bitmap(data->busted);
|
||||
al_destroy_font(data->font_title);
|
||||
al_destroy_font(data->font);
|
||||
al_destroy_sample_instance(data->laughter);
|
||||
al_destroy_sample_instance(data->click);
|
||||
al_destroy_sample(data->sample);
|
||||
al_destroy_sample(data->click_sample);
|
||||
DestroyCharacter(game, data->monster);
|
||||
DestroyCharacter(game, data->suit);
|
||||
DestroyCharacter(game, data->kid);
|
||||
TM_Destroy(data->timeline);
|
||||
}
|
||||
|
||||
// TODO: refactor to single Enqueue_Anim
|
||||
bool Anim_CowLook(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||
struct LevelResources *data = action->arguments->value;
|
||||
if (state == TM_ACTIONSTATE_START) {
|
||||
ChangeSpritesheet(game, data->suit, "look");
|
||||
TM_AddQueuedBackgroundAction(data->timeline, &Anim_CowLook, TM_AddToArgs(NULL, 1, data), 54*1000, "cow_look");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Anim_FixGuitar(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||
struct LevelResources *data = action->arguments->value;
|
||||
if (state == TM_ACTIONSTATE_START) {
|
||||
ChangeSpritesheet(game, data->monster, "fix");
|
||||
TM_AddQueuedBackgroundAction(data->timeline, &Anim_FixGuitar, TM_AddToArgs(NULL, 1, data), 30*1000, "fix_guitar");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void StartGame(struct Game *game, struct LevelResources *data) {
|
||||
TM_CleanQueue(data->timeline);
|
||||
TM_CleanBackgroundQueue(data->timeline);
|
||||
ChangeSpritesheet(game, data->monster, "stand");
|
||||
}
|
||||
|
||||
void Gamestate_Start(struct Game *game, struct LevelResources* data) {
|
||||
data->cloud_position = 100;
|
||||
SetCharacterPosition(game, data->monster, 150, 73, 0);
|
||||
SetCharacterPosition(game, data->suit, 65, 88, 0);
|
||||
|
||||
al_start_timer(data->timer);
|
||||
|
||||
data->score = 0;
|
||||
data->time = 0;
|
||||
data->paused = false;
|
||||
|
||||
data->lost = false;
|
||||
data->tickling = false;
|
||||
data->haskid = false;
|
||||
|
||||
data->movedown = false;
|
||||
data->moveup = false;
|
||||
|
||||
data->markx = 119;
|
||||
data->marky = 2;
|
||||
|
||||
data->soloactive = false;
|
||||
data->soloanim = 0;
|
||||
data->soloflash = 0;
|
||||
data->soloready = 0;
|
||||
|
||||
data->keys.key = 0;
|
||||
data->keys.delay = 0;
|
||||
data->keys.shift = false;
|
||||
data->keys.lastkey = -1;
|
||||
|
||||
data->lightanim=0;
|
||||
|
||||
data->kidSpeed = 0.8;
|
||||
|
||||
data->usage = 0;
|
||||
|
||||
SelectSpritesheet(game, data->monster, "stand");
|
||||
//TM_AddQueuedBackgroundAction(data->timeline, &Anim_FixGuitar, TM_AddToArgs(NULL, 1, data), 15*1000, "fix_guitar");
|
||||
//TM_AddQueuedBackgroundAction(data->timeline, &Anim_CowLook, TM_AddToArgs(NULL, 1, data), 5*1000, "cow_look");
|
||||
|
||||
data->kids[0] = NULL;
|
||||
data->kids[1] = NULL;
|
||||
data->kids[2] = NULL;
|
||||
data->kids[3] = NULL;
|
||||
data->kids[4] = NULL;
|
||||
data->kids[5] = NULL;
|
||||
data->destroyQueue = NULL;
|
||||
|
||||
data->kidRate = 100;
|
||||
data->timeTillNextBadguy = 0;
|
||||
|
||||
char *end = "";
|
||||
|
||||
data->savedScore = strtol(GetConfigOptionDefault(game, "TickleMonster", "score", "0"), &end, 10);
|
||||
data->savedTime = strtol(GetConfigOptionDefault(game, "TickleMonster", "time", "-1"), &end, 10);
|
||||
|
||||
}
|
||||
|
||||
void Gamestate_ProcessEvent(struct Game *game, struct LevelResources* data, ALLEGRO_EVENT *ev) {
|
||||
TM_HandleEvent(data->timeline, ev);
|
||||
|
||||
if (ev->type == ALLEGRO_EVENT_TIMER) {
|
||||
if (ev->timer.source == data->timer) {
|
||||
data->time++;
|
||||
}
|
||||
}
|
||||
|
||||
if (ev->type == ALLEGRO_EVENT_KEY_DOWN) {
|
||||
if (ev->keyboard.keycode == ALLEGRO_KEY_ESCAPE) {
|
||||
if ((data->paused) || (data->lost)) {
|
||||
SwitchGamestate(game, "level", "menu");
|
||||
}
|
||||
al_stop_timer(data->timer);
|
||||
data->paused = true;
|
||||
return;
|
||||
}
|
||||
if (data->lost && ev->keyboard.keycode == ALLEGRO_KEY_ENTER) {
|
||||
SwitchGamestate(game, "level", "menu");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (data->lost) return;
|
||||
|
||||
if (ev->type == ALLEGRO_EVENT_KEY_DOWN) {
|
||||
|
||||
switch (ev->keyboard.keycode) {
|
||||
case ALLEGRO_KEY_LEFT:
|
||||
case ALLEGRO_KEY_RIGHT:
|
||||
if (!data->tickling) {
|
||||
if (data->keys.key != ev->keyboard.keycode) {
|
||||
data->keys.key = ev->keyboard.keycode;
|
||||
data->keys.delay = INT_MIN;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ALLEGRO_KEY_UP:
|
||||
if (!data->tickling) {
|
||||
if (!data->moveup && !data->movedown) {
|
||||
SelectSpritesheet(game, data->monster, "jump");
|
||||
}
|
||||
data->moveup = true;
|
||||
data->movedown = false;
|
||||
}
|
||||
break;
|
||||
case ALLEGRO_KEY_DOWN:
|
||||
if (!data->tickling) {
|
||||
if (!data->moveup && !data->movedown) {
|
||||
SelectSpritesheet(game, data->monster, "jump");
|
||||
}
|
||||
data->moveup = false;
|
||||
data->movedown = true;
|
||||
}
|
||||
break;
|
||||
case ALLEGRO_KEY_SPACE:
|
||||
if (data->paused) {
|
||||
al_start_timer(data->timer);
|
||||
data->paused = false;
|
||||
} else {
|
||||
Fire(game, data);
|
||||
}
|
||||
break;
|
||||
case ALLEGRO_KEY_LSHIFT:
|
||||
case ALLEGRO_KEY_RSHIFT:
|
||||
data->keys.shift = true;
|
||||
break;
|
||||
case ALLEGRO_KEY_ENTER:
|
||||
break;
|
||||
default:
|
||||
data->keys.key = 0;
|
||||
break;
|
||||
}
|
||||
} else if (ev->type == ALLEGRO_EVENT_KEY_UP) {
|
||||
switch (ev->keyboard.keycode) {
|
||||
case ALLEGRO_KEY_LSHIFT:
|
||||
case ALLEGRO_KEY_RSHIFT:
|
||||
data->keys.shift = false;
|
||||
break;
|
||||
default:
|
||||
if (ev->keyboard.keycode == data->keys.key) {
|
||||
data->keys.key = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Gamestate_Pause(struct Game *game, struct LevelResources* data) {
|
||||
data->paused = true;
|
||||
TM_Pause(data->timeline);
|
||||
}
|
||||
void Gamestate_Resume(struct Game *game, struct LevelResources* data) {
|
||||
data->paused = false;
|
||||
TM_Resume(data->timeline);
|
||||
}
|
||||
void Gamestate_Reload(struct Game *game, struct LevelResources* data) {}
|
|
@ -1,86 +0,0 @@
|
|||
/*! \file menu.h
|
||||
* \brief Main Menu view headers.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <allegro5/allegro.h>
|
||||
#include <allegro5/allegro_font.h>
|
||||
#include <allegro5/allegro_audio.h>
|
||||
|
||||
/*! \brief Resources used by Menu state. */
|
||||
struct LevelResources {
|
||||
ALLEGRO_BITMAP *bg; /*!< Bitmap with lower portion of menu landscape. */
|
||||
ALLEGRO_BITMAP *buildings;
|
||||
ALLEGRO_BITMAP *hid;
|
||||
ALLEGRO_BITMAP *hid2;
|
||||
ALLEGRO_BITMAP *meter;
|
||||
ALLEGRO_BITMAP *busted;
|
||||
|
||||
ALLEGRO_TIMER *timer;
|
||||
|
||||
float kidSpeed;
|
||||
|
||||
int markx, marky;
|
||||
|
||||
int usage;
|
||||
int lightx, lighty, lightanim;
|
||||
|
||||
int soloready, soloanim, soloflash;
|
||||
bool soloactive;
|
||||
|
||||
bool tickling, moveup, movedown, haskid, lost, paused;
|
||||
|
||||
struct Kid {
|
||||
struct Character *character;
|
||||
struct Kid *next, *prev;
|
||||
float speed;
|
||||
bool tickled;
|
||||
bool grownup;
|
||||
int fun;
|
||||
bool happy;
|
||||
bool right;
|
||||
} *kids[6], *destroyQueue, *tickledKid;
|
||||
|
||||
int timeTillNextBadguy, kidRate;
|
||||
|
||||
struct Character *monster;
|
||||
struct Character *suit;
|
||||
struct Character *kid;
|
||||
struct Timeline *timeline;
|
||||
float cloud_position; /*!< Position of bigger cloud. */
|
||||
ALLEGRO_SAMPLE *sample; /*!< Music sample. */
|
||||
ALLEGRO_SAMPLE *click_sample; /*!< Click sound sample. */
|
||||
ALLEGRO_SAMPLE_INSTANCE *laughter; /*!< Sample instance with music sound. */
|
||||
ALLEGRO_SAMPLE_INSTANCE *click; /*!< Sample instance with click sound. */
|
||||
ALLEGRO_FONT *font_title; /*!< Font of "Super Derpy" text. */
|
||||
ALLEGRO_FONT *font; /*!< Font of standard menu item. */
|
||||
int selected; /*!< Number of selected menu item. */
|
||||
|
||||
struct {
|
||||
int key;
|
||||
bool shift;
|
||||
int delay;
|
||||
// workaround for random bogus UP/DOWN events
|
||||
int lastkey;
|
||||
int lastdelay;
|
||||
} keys;
|
||||
|
||||
int savedScore, savedTime;
|
||||
int score, time;
|
||||
};
|
|
@ -38,11 +38,9 @@ void* Load(struct Game *game) {
|
|||
al_clear_to_color(al_map_rgb(0,0,0));
|
||||
|
||||
data->loading_bitmap = al_create_bitmap(game->viewport.width, game->viewport.height);
|
||||
data->bg = al_load_bitmap( GetDataFilePath(game, "bg.png") );
|
||||
|
||||
al_set_target_bitmap(data->loading_bitmap);
|
||||
al_clear_to_color(al_map_rgb(0,0,0));
|
||||
al_draw_bitmap(data->bg, 0, 0, 0);
|
||||
al_draw_filled_rectangle(0, game->viewport.height/2 - 1, game->viewport.width, game->viewport.height/2 + 1, al_map_rgba(32,32,32,32));
|
||||
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||
return data;
|
||||
|
@ -52,6 +50,5 @@ void Start(struct Game *game, struct LoadingResources *data) {}
|
|||
void Stop(struct Game *game, struct LoadingResources *data) {}
|
||||
void Unload(struct Game *game, struct LoadingResources *data) {
|
||||
al_destroy_bitmap(data->loading_bitmap);
|
||||
al_destroy_bitmap(data->bg);
|
||||
free(data);
|
||||
}
|
||||
|
|
|
@ -26,5 +26,4 @@
|
|||
/*! \brief Resources used by Loading state. */
|
||||
struct LoadingResources {
|
||||
ALLEGRO_BITMAP *loading_bitmap; /*!< Rendered loading bitmap. */
|
||||
ALLEGRO_BITMAP *bg;
|
||||
};
|
||||
|
|
|
@ -1,311 +0,0 @@
|
|||
/*! \file dosowisko.c
|
||||
* \brief Init animation with dosowisko.net logo.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <allegro5/allegro_ttf.h>
|
||||
#include <allegro5/allegro_primitives.h>
|
||||
#include <math.h>
|
||||
#include "../utils.h"
|
||||
#include "../timeline.h"
|
||||
#include "lollipop.h"
|
||||
|
||||
int Gamestate_ProgressCount = 4;
|
||||
|
||||
|
||||
bool switchMinigame(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||
if (state == TM_ACTIONSTATE_START) {
|
||||
StopGamestate(game, "lollipop");
|
||||
game->mediator.next = "riots";
|
||||
StartGamestate(game, GetAbstractIsItBonusLevelTimeNowFactoryProvider(game) ? "bonus" : "riots");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool theEnd(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||
if (state == TM_ACTIONSTATE_START) {
|
||||
StopGamestate(game, "lollipop");
|
||||
StartGamestate(game, "theend");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void Gamestate_Logic(struct Game *game, struct RocketsResources* data) {
|
||||
|
||||
if ((data->spawncounter == data->currentspawn) && ((data->counter < data->timelimit) || (data->lost))) {
|
||||
data->dx = (( (rand() / (float)RAND_MAX) - 0.5)/ 200.0) * game->mediator.modificator;
|
||||
PrintConsole(game, "DX %f", data->dx);
|
||||
data->spawncounter = 0;
|
||||
}
|
||||
|
||||
if ((data->lost) && (data->hearts > 80)) {
|
||||
AnimateCharacter(game, game->mediator.heart, 1);
|
||||
if (game->mediator.heart->pos == 6) {
|
||||
al_play_sample_instance(data->jump_sound);
|
||||
}
|
||||
}
|
||||
|
||||
if (data->lost) {
|
||||
data->hearts++;
|
||||
}
|
||||
|
||||
if ((data->counter >= data->timelimit) && (!data->lost) && (!data->won)) {
|
||||
al_play_sample_instance(data->rainbow_sound);
|
||||
data->won = true;
|
||||
AdvanceLevel(game, true);
|
||||
SelectSpritesheet(game, data->riot, "win");
|
||||
|
||||
TM_AddDelay(data->timeline, 2500);
|
||||
TM_AddAction(data->timeline, switchMinigame, NULL, "switchMinigame");
|
||||
}
|
||||
|
||||
if (data->won) {
|
||||
AnimateCharacter(game, data->riot, 1);
|
||||
} else {
|
||||
|
||||
if ((data->currentpos < -0.15) || (data->currentpos > 0.15)) {
|
||||
if (!data->lost) {
|
||||
AdvanceLevel(game, false);
|
||||
data->lost = true;
|
||||
SelectSpritesheet(game, data->riot, "end");
|
||||
TM_AddDelay(data->timeline, 3500);
|
||||
if (game->mediator.lives > 0) {
|
||||
TM_AddAction(data->timeline, switchMinigame, NULL, "switchMinigame");
|
||||
} else {
|
||||
|
||||
TM_AddAction(data->timeline, theEnd, NULL, "switchMinigame");
|
||||
}
|
||||
al_play_sample_instance(data->boom_sound);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int newstate = 0;
|
||||
if (data->currentpos < -0.05) {
|
||||
newstate = -1;
|
||||
} else if (data->currentpos > 0.05) {
|
||||
newstate = 1;
|
||||
}
|
||||
|
||||
if (data->oldstate != newstate) {
|
||||
if (newstate == 0) {
|
||||
SelectSpritesheet(game, data->faces, "center");
|
||||
} else if (newstate == 1) {
|
||||
SelectSpritesheet(game, data->faces, "right");
|
||||
} else {
|
||||
SelectSpritesheet(game, data->faces, "left");
|
||||
}
|
||||
data->oldstate = newstate;
|
||||
}
|
||||
|
||||
data->counter++;
|
||||
data->spawncounter++;
|
||||
|
||||
if (!data->lost) {
|
||||
data->currentpos += data->dx;
|
||||
}
|
||||
|
||||
TM_Process(data->timeline);
|
||||
}
|
||||
|
||||
void Gamestate_Draw(struct Game *game, struct RocketsResources* data) {
|
||||
|
||||
al_set_target_bitmap(data->pixelator);
|
||||
al_clear_to_color(al_map_rgba(128,192,255,0));
|
||||
al_draw_bitmap(data->bg, 0, 0, 0);
|
||||
|
||||
|
||||
if (data->won) {
|
||||
//DrawCharacter(game, data->euro, al_map_rgb(255,255,255), 0);
|
||||
}
|
||||
|
||||
if ((!data->lost) && (!data->won)) {
|
||||
if (data->counter / (float)data->timelimit < 0.5) {
|
||||
al_draw_rotated_bitmap(data->earth2, 158, 140, 158, 140, data->currentpos, 0);
|
||||
} else if (data->counter / (float)data->timelimit < 0.8) {
|
||||
al_draw_rotated_bitmap(data->earth3, 158, 140, 158, 140, data->currentpos, 0);
|
||||
} else {
|
||||
al_draw_rotated_bitmap(data->earth4, 158, 140, 158, 140, data->currentpos, 0);
|
||||
}
|
||||
al_draw_bitmap(data->earth, 0, 0, 0);
|
||||
DrawCharacter(game, data->faces, al_map_rgb(255,255,255), 0);
|
||||
|
||||
//DrawCharacter(game, data->cursor, al_map_rgb(255,255,255), 0);
|
||||
}
|
||||
|
||||
if ((!data->lost) && (!data->won)) {
|
||||
al_draw_filled_rectangle(78, 5, 78+164, 5+5, al_map_rgb(155, 142, 142));
|
||||
al_draw_filled_rectangle(80, 6, 80+160, 6+3, al_map_rgb(66, 55, 30));
|
||||
al_draw_filled_rectangle(80, 6, (data->counter < data->timelimit) ? (80+ 160 * (1 - (data->counter / (float)data->timelimit))) : 80, 6+3, al_map_rgb(225,182, 80));
|
||||
}
|
||||
|
||||
al_set_target_backbuffer(game->display);
|
||||
al_draw_bitmap(data->pixelator, 0, 0, 0);
|
||||
|
||||
if ((!data->lost) && (!data->won)) {
|
||||
al_draw_filled_rectangle(78, 5, 78+164, 5+5, al_map_rgb(155, 142, 142));
|
||||
al_draw_filled_rectangle(80, 6, 80+160, 6+3, al_map_rgb(66, 55, 30));
|
||||
al_draw_filled_rectangle(80, 6, (data->counter < data->timelimit) ? (80+160 * (1 - (data->counter / (float)data->timelimit))) : 80, 6+3, al_map_rgb(225,182, 80));
|
||||
}
|
||||
|
||||
if (data->won) {
|
||||
DrawCharacter(game, data->riot, al_map_rgb(255,255,255), 0);
|
||||
}
|
||||
|
||||
if (data->lost) {
|
||||
al_draw_bitmap(data->currentpos < 0 ? data->clouds : data->combined, 0, 0, 0);
|
||||
if (data->hearts > 80) {
|
||||
ShowLevelStatistics(game);
|
||||
}
|
||||
}
|
||||
|
||||
//Gamestate_Logic(game, data);
|
||||
|
||||
}
|
||||
|
||||
void Gamestate_Start(struct Game *game, struct RocketsResources* data) {
|
||||
|
||||
data->timelimit = 400 * game->mediator.modificator;
|
||||
data->spawnspeed = 40 / game->mediator.modificator;
|
||||
data->currentspawn = data->spawnspeed;
|
||||
data->spawncounter = data->spawnspeed;
|
||||
|
||||
data->lost = false;
|
||||
data->won = false;
|
||||
|
||||
data->hearts = 0;
|
||||
|
||||
data->currentpos = 0;
|
||||
data->dx = 0;
|
||||
|
||||
SetCharacterPosition(game, data->riot, 0, 0, 0);
|
||||
SelectSpritesheet(game, data->riot, "win");
|
||||
SelectSpritesheet(game, data->faces, "center");
|
||||
SetCharacterPosition(game, data->faces, 0, 0, 0);
|
||||
|
||||
data->oldstate = 0;
|
||||
|
||||
data->counter = 0;
|
||||
|
||||
al_set_mouse_xy(game->display, al_get_display_width(game->display) / 2, al_get_display_height(game->display) / 2);
|
||||
|
||||
}
|
||||
|
||||
void Gamestate_ProcessEvent(struct Game *game, struct RocketsResources* data, ALLEGRO_EVENT *ev) {
|
||||
TM_HandleEvent(data->timeline, ev);
|
||||
if ((ev->type==ALLEGRO_EVENT_KEY_DOWN) && (ev->keyboard.keycode == ALLEGRO_KEY_ESCAPE)) {
|
||||
SwitchGamestate(game, "lollipop", "theend");
|
||||
} else if (ev->type == ALLEGRO_EVENT_MOUSE_AXES) {
|
||||
int mousex = ev->mouse.dx / (al_get_display_width(game->display) / 320);
|
||||
|
||||
if (!data->lost) {
|
||||
data->currentpos += mousex / 5000.0 / game->mediator.modificator;
|
||||
}
|
||||
al_set_mouse_xy(game->display, al_get_display_width(game->display) / 2, al_get_display_height(game->display) / 2);
|
||||
}
|
||||
}
|
||||
|
||||
void* Gamestate_Load(struct Game *game, void (*progress)(struct Game*)) {
|
||||
struct RocketsResources *data = malloc(sizeof(struct RocketsResources));
|
||||
|
||||
data->timeline = TM_Init(game, "lollipop");
|
||||
|
||||
data->bg = al_load_bitmap( GetDataFilePath(game, "lollipop/bg.png"));
|
||||
(*progress)(game);
|
||||
|
||||
data->earth = al_load_bitmap( GetDataFilePath(game, "lollipop/peoples.png"));
|
||||
data->earth2 = al_load_bitmap( GetDataFilePath(game, "lollipop/lollipop.png"));
|
||||
data->earth3 = al_load_bitmap( GetDataFilePath(game, "lollipop/lollipop2.png"));
|
||||
data->earth4 = al_load_bitmap( GetDataFilePath(game, "lollipop/lollipop3.png"));
|
||||
|
||||
data->clouds = al_load_bitmap( GetDataFilePath(game, "lollipop/przegrywdziew.png"));
|
||||
data->combined = al_load_bitmap( GetDataFilePath(game, "lollipop/przegrywchop.png"));
|
||||
|
||||
data->boom_sample = al_load_sample( GetDataFilePath(game, "lollipop/lost.flac") );
|
||||
data->jump_sample = al_load_sample( GetDataFilePath(game, "boom.flac") );
|
||||
data->rainbow_sample = al_load_sample( GetDataFilePath(game, "lollipop/success.flac") );
|
||||
(*progress)(game);
|
||||
|
||||
data->boom_sound = al_create_sample_instance(data->boom_sample);
|
||||
al_attach_sample_instance_to_mixer(data->boom_sound, game->audio.fx);
|
||||
al_set_sample_instance_playmode(data->boom_sound, ALLEGRO_PLAYMODE_ONCE);
|
||||
|
||||
data->rainbow_sound = al_create_sample_instance(data->rainbow_sample);
|
||||
al_attach_sample_instance_to_mixer(data->rainbow_sound, game->audio.fx);
|
||||
al_set_sample_instance_playmode(data->rainbow_sound, ALLEGRO_PLAYMODE_ONCE);
|
||||
al_set_sample_instance_gain(data->rainbow_sound, 1.25);
|
||||
|
||||
data->jump_sound = al_create_sample_instance(data->jump_sample);
|
||||
al_attach_sample_instance_to_mixer(data->jump_sound, game->audio.fx);
|
||||
al_set_sample_instance_playmode(data->jump_sound, ALLEGRO_PLAYMODE_ONCE);
|
||||
|
||||
(*progress)(game);
|
||||
|
||||
data->riot = CreateCharacter(game, "loliwin");
|
||||
RegisterSpritesheet(game, data->riot, "win");
|
||||
RegisterSpritesheet(game, data->riot, "end");
|
||||
LoadSpritesheets(game, data->riot);
|
||||
(*progress)(game);
|
||||
|
||||
data->faces = CreateCharacter(game, "faces");
|
||||
RegisterSpritesheet(game, data->faces, "left");
|
||||
RegisterSpritesheet(game, data->faces, "center");
|
||||
RegisterSpritesheet(game, data->faces, "right");
|
||||
LoadSpritesheets(game, data->faces);
|
||||
(*progress)(game);
|
||||
|
||||
data->pixelator = al_create_bitmap(320, 180);
|
||||
al_set_target_bitmap(data->pixelator);
|
||||
al_clear_to_color(al_map_rgb(0, 0, 0));
|
||||
al_set_target_backbuffer(game->display);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void Gamestate_Stop(struct Game *game, struct RocketsResources* data) {
|
||||
TM_CleanQueue(data->timeline);
|
||||
}
|
||||
|
||||
void Gamestate_Unload(struct Game *game, struct RocketsResources* data) {
|
||||
al_destroy_bitmap(data->bg);
|
||||
al_destroy_bitmap(data->earth);
|
||||
al_destroy_bitmap(data->earth2);
|
||||
al_destroy_bitmap(data->earth3);
|
||||
al_destroy_bitmap(data->earth4);
|
||||
al_destroy_bitmap(data->clouds);
|
||||
al_destroy_bitmap(data->combined);
|
||||
al_destroy_bitmap(data->pixelator);
|
||||
al_destroy_sample_instance(data->boom_sound);
|
||||
al_destroy_sample(data->boom_sample);
|
||||
DestroyCharacter(game, data->faces);
|
||||
DestroyCharacter(game, data->riot);
|
||||
// TODO: Destroy all the stuff
|
||||
free(data);
|
||||
}
|
||||
|
||||
void Gamestate_Reload(struct Game *game, struct RocketsResources* data) {}
|
||||
|
||||
void Gamestate_Resume(struct Game *game, struct RocketsResources* data) {
|
||||
TM_Resume(data->timeline);
|
||||
}
|
||||
void Gamestate_Pause(struct Game *game, struct RocketsResources* data) {
|
||||
TM_Pause(data->timeline);
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
/*! \file dosowisko.h
|
||||
* \brief Init animation with dosowisko.net logo.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
struct RocketsResources {
|
||||
ALLEGRO_FONT *font;
|
||||
ALLEGRO_BITMAP *bg, *earth, *earth2, *earth3, *earth4, *pixelator, *combined, *clouds;
|
||||
struct Character *riot, *faces;
|
||||
|
||||
int counter, hearts;
|
||||
|
||||
ALLEGRO_SAMPLE *boom_sample, *rainbow_sample, *jump_sample;
|
||||
ALLEGRO_SAMPLE_INSTANCE *boom_sound, *rainbow_sound, *jump_sound;
|
||||
|
||||
bool lost, won;
|
||||
|
||||
int oldstate;
|
||||
|
||||
int timelimit, spawnspeed, currentspawn, spawncounter;
|
||||
|
||||
float dx;
|
||||
float currentpos;
|
||||
|
||||
struct Timeline *timeline;
|
||||
};
|
|
@ -1,169 +0,0 @@
|
|||
/*! \file map.c
|
||||
* \brief View with Map of levels.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include "../utils.h"
|
||||
#include "../config.h"
|
||||
#include "map.h"
|
||||
|
||||
int Gamestate_ProgressCount = 10;
|
||||
|
||||
void Gamestate_Draw(struct Game *game, struct MapResources* data) {
|
||||
al_draw_bitmap(data->map, 0, 0, 0);
|
||||
float x=0,y=0;
|
||||
switch (data->selected) {
|
||||
case 1:
|
||||
x=0.2;
|
||||
y=0.25;
|
||||
break;
|
||||
case 2:
|
||||
x=0.495;
|
||||
y=0.35;
|
||||
break;
|
||||
case 3:
|
||||
x=0.72;
|
||||
y=0.4;
|
||||
break;
|
||||
case 4:
|
||||
x=0.7;
|
||||
y=0.77;
|
||||
break;
|
||||
case 5:
|
||||
x=0.248;
|
||||
y=0.75;
|
||||
break;
|
||||
case 6:
|
||||
x=0.425;
|
||||
y=0.675;
|
||||
break;
|
||||
}
|
||||
al_draw_scaled_bitmap(data->arrow, 0, 0, al_get_bitmap_width(data->arrow), al_get_bitmap_height(data->arrow), (game->viewport.width-game->viewport.height*1.6)/2+game->viewport.height*1.6*x, game->viewport.height*y + ((sin(data->arrowpos)+0.5)/20.0)*game->viewport.height, game->viewport.height*1.6*0.1, game->viewport.height*0.16, 0);
|
||||
}
|
||||
|
||||
void Gamestate_Logic(struct Game *game, struct MapResources* data) {
|
||||
data->arrowpos += 0.1;
|
||||
}
|
||||
|
||||
void Gamestate_Start(struct Game *game, struct MapResources* data) {
|
||||
al_play_sample_instance(data->music);
|
||||
FadeGamestate(game, true);
|
||||
}
|
||||
|
||||
void Gamestate_ProcessEvent(struct Game *game, struct MapResources* data, ALLEGRO_EVENT *ev) {
|
||||
if (ev->type!=ALLEGRO_EVENT_KEY_DOWN) return;
|
||||
if ((((data->selected<4) || (data->selected==6)) && (ev->keyboard.keycode==ALLEGRO_KEY_LEFT)) || ((data->selected>4) && (data->selected!=6) && (ev->keyboard.keycode==ALLEGRO_KEY_RIGHT)) || ((data->selected==4) && (ev->keyboard.keycode==ALLEGRO_KEY_UP)) || ((data->selected==6) && (ev->keyboard.keycode==ALLEGRO_KEY_DOWN))) {
|
||||
data->selected--;
|
||||
al_play_sample_instance(data->click);
|
||||
} else if (((data->selected<3) && (ev->keyboard.keycode==ALLEGRO_KEY_RIGHT)) || ((data->selected==4) && (ev->keyboard.keycode==ALLEGRO_KEY_LEFT)) || ((data->selected==3) && (ev->keyboard.keycode==ALLEGRO_KEY_DOWN)) || ((data->selected==5) && (ev->keyboard.keycode==ALLEGRO_KEY_UP))) {
|
||||
data->selected++;
|
||||
al_play_sample_instance(data->click);
|
||||
} else if ((ev->keyboard.keycode==ALLEGRO_KEY_LEFT) || (ev->keyboard.keycode==ALLEGRO_KEY_RIGHT) || (ev->keyboard.keycode==ALLEGRO_KEY_UP) || (ev->keyboard.keycode==ALLEGRO_KEY_DOWN)) {
|
||||
al_play_sample_instance(data->click);
|
||||
} else if (ev->keyboard.keycode==ALLEGRO_KEY_ENTER) {
|
||||
al_play_sample_instance(data->click);
|
||||
//game->level.input.current_level = data->selected;
|
||||
PrintConsole(game, "Selecting level %d...", data->selected);
|
||||
char gamestate[255] = {};
|
||||
snprintf(gamestate, 255, "level%d", data->selected);
|
||||
SwitchGamestate(game, "map", gamestate);
|
||||
return;
|
||||
} else if (ev->keyboard.keycode == ALLEGRO_KEY_ESCAPE) {
|
||||
SwitchGamestate(game, "map", "menu");
|
||||
return;
|
||||
}
|
||||
if (data->selected<1) data->selected=1;
|
||||
if (data->selected>data->available) data->selected=data->available;
|
||||
}
|
||||
|
||||
void* Gamestate_Load(struct Game *game, void (*progress)(struct Game*)) {
|
||||
|
||||
struct MapResources *data = malloc(sizeof(struct MapResources));
|
||||
data->available = atoi(GetConfigOptionDefault(game, "MuffinAttack", "level", "1"));
|
||||
if ((data->available<1) || (data->available>6)) data->available=1;
|
||||
data->selected = data->available;
|
||||
PrintConsole(game, "Last level available: %d", data->selected);
|
||||
data->arrowpos = 0;
|
||||
(*progress)(game);
|
||||
|
||||
data->map_bg = LoadScaledBitmap(game, "map/background.png", game->viewport.height*1.6, game->viewport.height);
|
||||
(*progress)(game);
|
||||
char filename[30] = { };
|
||||
snprintf(filename, 30, "map/highlight%d.png", data->available);
|
||||
data->highlight = LoadScaledBitmap(game, filename, game->viewport.height*1.6, game->viewport.height);
|
||||
(*progress)(game);
|
||||
|
||||
data->arrow = al_load_bitmap( GetDataFilePath(game, "map/arrow.png") );
|
||||
(*progress)(game);
|
||||
|
||||
data->click_sample = al_load_sample( GetDataFilePath(game, "menu/click.flac") );
|
||||
(*progress)(game);
|
||||
data->sample = al_load_sample( GetDataFilePath(game, "map/map.flac") );
|
||||
(*progress)(game);
|
||||
|
||||
data->music = al_create_sample_instance(data->sample);
|
||||
al_attach_sample_instance_to_mixer(data->music, game->audio.music);
|
||||
al_set_sample_instance_playmode(data->music, ALLEGRO_PLAYMODE_LOOP);
|
||||
(*progress)(game);
|
||||
|
||||
data->click = al_create_sample_instance(data->click_sample);
|
||||
al_attach_sample_instance_to_mixer(data->click, game->audio.fx);
|
||||
al_set_sample_instance_playmode(data->click, ALLEGRO_PLAYMODE_ONCE);
|
||||
(*progress)(game);
|
||||
|
||||
if (!data->sample){
|
||||
fprintf(stderr, "Audio clip sample not loaded!\n" );
|
||||
exit(-1);
|
||||
}
|
||||
if (!data->click_sample){
|
||||
fprintf(stderr, "Audio clip sample#2 not loaded!\n" );
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
data->map = LoadScaledBitmap(game, "table.png", game->viewport.width, game->viewport.height);
|
||||
(*progress)(game);
|
||||
al_set_target_bitmap(data->map);
|
||||
al_draw_bitmap(data->map_bg, (game->viewport.width-game->viewport.height*1.6)/2, 0 ,0);
|
||||
al_draw_bitmap(data->highlight, (game->viewport.width-game->viewport.height*1.6)/2, 0 ,0);
|
||||
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||
(*progress)(game);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void Gamestate_Unload(struct Game *game, struct MapResources* data) {
|
||||
al_destroy_bitmap(data->map);
|
||||
al_destroy_bitmap(data->map_bg);
|
||||
al_destroy_bitmap(data->highlight);
|
||||
al_destroy_bitmap(data->arrow);
|
||||
al_destroy_sample_instance(data->music);
|
||||
al_destroy_sample(data->sample);
|
||||
al_destroy_sample_instance(data->click);
|
||||
al_destroy_sample(data->click_sample);
|
||||
}
|
||||
|
||||
void Gamestate_Stop(struct Game *game, struct MapResources* data) {
|
||||
FadeGamestate(game, false);
|
||||
al_stop_sample_instance(data->music);
|
||||
}
|
||||
|
||||
void Gamestate_Pause(struct Game *game, struct MapResources* data) {}
|
||||
void Gamestate_Resume(struct Game *game, struct MapResources* data) {}
|
||||
void Gamestate_Reload(struct Game *game, struct MapResources* data) {}
|
|
@ -1,39 +0,0 @@
|
|||
/*! \file map.h
|
||||
* \brief Map view headers.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <allegro5/allegro.h>
|
||||
#include <allegro5/allegro_font.h>
|
||||
#include <allegro5/allegro_audio.h>
|
||||
|
||||
/*! \brief Resources used by Map state. */
|
||||
struct MapResources {
|
||||
ALLEGRO_BITMAP *map; /*!< Background table bitmap. */
|
||||
ALLEGRO_BITMAP *map_bg; /*!< Map bitmap. */
|
||||
ALLEGRO_BITMAP *highlight; /*!< Level highlights bitmap. */
|
||||
ALLEGRO_BITMAP *arrow; /*!< Arrow bitmap. */
|
||||
int selected; /*!< Number of currently selected level. */
|
||||
int available; /*!< Number of highest available level. */
|
||||
float arrowpos; /*!< Vertical position of the arrow. */
|
||||
ALLEGRO_SAMPLE *sample; /*!< Sample with backgrond music. */
|
||||
ALLEGRO_SAMPLE *click_sample; /*!< Sample with click sound. */
|
||||
ALLEGRO_SAMPLE_INSTANCE *music; /*!< Sample instance with background music. */
|
||||
ALLEGRO_SAMPLE_INSTANCE *click; /*!< Sample instance with click sound. */
|
||||
};
|
|
@ -1,507 +0,0 @@
|
|||
/*! \file menu.c
|
||||
* \brief Main Menu view.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <allegro5/allegro_ttf.h>
|
||||
#include <allegro5/allegro_primitives.h>
|
||||
#include "../config.h"
|
||||
#include "../utils.h"
|
||||
#include "../timeline.h"
|
||||
#include "menu.h"
|
||||
|
||||
int Gamestate_ProgressCount = 4;
|
||||
|
||||
void About(struct Game *game, struct MenuResources* data) {
|
||||
ALLEGRO_TRANSFORM trans;
|
||||
al_identity_transform(&trans);
|
||||
al_use_transform(&trans);
|
||||
|
||||
if (!game->_priv.font_bsod) {
|
||||
game->_priv.font_bsod = al_create_builtin_font();
|
||||
}
|
||||
|
||||
al_set_target_backbuffer(game->display);
|
||||
al_clear_to_color(al_map_rgb(0,0,170));
|
||||
|
||||
char *header = "MEDIATOR";
|
||||
|
||||
al_draw_filled_rectangle(al_get_display_width(game->display)/2 - al_get_text_width(game->_priv.font_bsod, header)/2 - 4, (int)(al_get_display_height(game->display) * 0.32), 4 + al_get_display_width(game->display)/2 + al_get_text_width(game->_priv.font_bsod, header)/2, (int)(al_get_display_height(game->display) * 0.32) + al_get_font_line_height(game->_priv.font_bsod), al_map_rgb(170,170,170));
|
||||
|
||||
al_draw_text(game->_priv.font_bsod, al_map_rgb(0, 0, 170), al_get_display_width(game->display)/2, (int)(al_get_display_height(game->display) * 0.32), ALLEGRO_ALIGN_CENTRE, header);
|
||||
|
||||
char *header2 = "A fatal exception 0xD3RP has occured at 0028:M00F11NZ in GST SD(01) +";
|
||||
|
||||
al_draw_text(game->_priv.font_bsod, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, (int)(al_get_display_height(game->display) * 0.32+2*al_get_font_line_height(game->_priv.font_bsod)*1.25), ALLEGRO_ALIGN_CENTRE, header2);
|
||||
al_draw_textf(game->_priv.font_bsod, al_map_rgb(255,255,255), al_get_display_width(game->display)/2 - al_get_text_width(game->_priv.font_bsod, header2)/2, (int)(al_get_display_height(game->display) * 0.32+3*al_get_font_line_height(game->_priv.font_bsod)*1.25), ALLEGRO_ALIGN_LEFT, "%p and system just doesn't know what went wrong.", (void*)game);
|
||||
|
||||
al_draw_text(game->_priv.font_bsod, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, (int)(al_get_display_height(game->display) * 0.32+5*al_get_font_line_height(game->_priv.font_bsod)*1.25), ALLEGRO_ALIGN_CENTRE, "About screen not implemented!");
|
||||
al_draw_text(game->_priv.font_bsod, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, (int)(al_get_display_height(game->display) * 0.32+7*al_get_font_line_height(game->_priv.font_bsod)*1.25), ALLEGRO_ALIGN_CENTRE, "Made in the theater by Sebastian Krzyszkowiak and Konrad Burandt");
|
||||
|
||||
al_draw_text(game->_priv.font_bsod, al_map_rgb(255,255,255), al_get_display_width(game->display)/2 - al_get_text_width(game->_priv.font_bsod, header2)/2, (int)(al_get_display_height(game->display) * 0.32+9*al_get_font_line_height(game->_priv.font_bsod)*1.25), ALLEGRO_ALIGN_LEFT, "* Press any key to terminate this error.");
|
||||
al_draw_text(game->_priv.font_bsod, al_map_rgb(255,255,255), al_get_display_width(game->display)/2 - al_get_text_width(game->_priv.font_bsod, header2)/2, (int)(al_get_display_height(game->display) * 0.32+10*al_get_font_line_height(game->_priv.font_bsod)*1.25), ALLEGRO_ALIGN_LEFT, "* Press any key to destroy all muffins in the world.");
|
||||
al_draw_text(game->_priv.font_bsod, al_map_rgb(255,255,255), al_get_display_width(game->display)/2 - al_get_text_width(game->_priv.font_bsod, header2)/2, (int)(al_get_display_height(game->display) * 0.32+11*al_get_font_line_height(game->_priv.font_bsod)*1.25), ALLEGRO_ALIGN_LEFT, "* Just kidding, please press any key anyway.");
|
||||
|
||||
al_draw_text(game->_priv.font_bsod, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, (int)(al_get_display_height(game->display) * 0.32+13*al_get_font_line_height(game->_priv.font_bsod)*1.25), ALLEGRO_ALIGN_CENTRE, "Press any key to continue _");
|
||||
|
||||
al_use_transform(&game->projection);
|
||||
}
|
||||
|
||||
void DrawMenuState(struct Game *game, struct MenuResources *data) {
|
||||
|
||||
const ALLEGRO_TRANSFORM *tmp_trans = al_get_current_transform();
|
||||
ALLEGRO_TRANSFORM trans, cur_trans;
|
||||
al_copy_transform(&trans, tmp_trans);
|
||||
al_copy_transform(&cur_trans, tmp_trans);
|
||||
al_translate_transform(&trans, (al_get_display_width(game->display) / 320.0) * 80, (al_get_display_height(game->display) / 260.0) * ((180-data->screen_pos) - 48));
|
||||
al_use_transform(&trans);
|
||||
|
||||
ALLEGRO_FONT *font = data->font;
|
||||
char* text = malloc(255*sizeof(char));
|
||||
struct ALLEGRO_COLOR color;
|
||||
switch (data->menustate) {
|
||||
case MENUSTATE_MAIN:
|
||||
case MENUSTATE_HIDDEN:
|
||||
if (!data->invisible) {
|
||||
DrawTextWithShadow(font, data->selected==0 ? al_map_rgb(255,222, 120) : al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.5, ALLEGRO_ALIGN_CENTRE, "Start game");
|
||||
DrawTextWithShadow(font, data->selected==1 ? al_map_rgb(255,222, 120) : al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.6, ALLEGRO_ALIGN_CENTRE, "Options");
|
||||
DrawTextWithShadow(font, data->selected==2 ? al_map_rgb(255,222, 120) : al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.7, ALLEGRO_ALIGN_CENTRE, "About");
|
||||
DrawTextWithShadow(font, data->selected==3 ? al_map_rgb(255,222, 120) : al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.8, ALLEGRO_ALIGN_CENTRE, "Exit");
|
||||
}
|
||||
break;
|
||||
case MENUSTATE_OPTIONS:
|
||||
DrawTextWithShadow(font, data->selected==0 ? al_map_rgb(255,222, 120) : al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.5, ALLEGRO_ALIGN_CENTRE, "Video settings");
|
||||
DrawTextWithShadow(font, data->selected==1 ? al_map_rgb(255,222, 120) : al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.6, ALLEGRO_ALIGN_CENTRE, "Audio settings");
|
||||
DrawTextWithShadow(font, data->selected==3 ? al_map_rgb(255,222, 120) : al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.8, ALLEGRO_ALIGN_CENTRE, "Back");
|
||||
break;
|
||||
case MENUSTATE_AUDIO:
|
||||
if (game->config.music) snprintf(text, 255, "Music volume: %d0%%", game->config.music);
|
||||
else sprintf(text, "Music disabled");
|
||||
DrawTextWithShadow(font, data->selected==0 ? al_map_rgb(255,222, 120) : al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.5, ALLEGRO_ALIGN_CENTRE, text);
|
||||
if (game->config.fx) snprintf(text, 255, "Effects volume: %d0%%", game->config.fx);
|
||||
else sprintf(text, "Effects disabled");
|
||||
DrawTextWithShadow(font, data->selected==1 ? al_map_rgb(255,222, 120) : al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.6, ALLEGRO_ALIGN_CENTRE, text);
|
||||
DrawTextWithShadow(font, data->selected==3 ? al_map_rgb(255,222, 120) : al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.8, ALLEGRO_ALIGN_CENTRE, "Back");
|
||||
break;
|
||||
case MENUSTATE_ABOUT:
|
||||
al_use_transform(&cur_trans);
|
||||
About(game, data);
|
||||
break;
|
||||
case MENUSTATE_VIDEO:
|
||||
if (data->options.fullscreen) {
|
||||
sprintf(text, "Fullscreen: yes");
|
||||
color = al_map_rgba(0,0,0,128);
|
||||
}
|
||||
else {
|
||||
sprintf(text, "Fullscreen: no");
|
||||
color = data->selected==1 ? al_map_rgb(255,222, 120) : al_map_rgb(255,255,255);
|
||||
}
|
||||
DrawTextWithShadow(font, data->selected==0 ? al_map_rgb(255,222, 120) : al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.5, ALLEGRO_ALIGN_CENTRE, text);
|
||||
sprintf(text, "Resolution: %dx", data->options.resolution);
|
||||
DrawTextWithShadow(font, color, game->viewport.width*0.5, game->viewport.height*0.6, ALLEGRO_ALIGN_CENTRE, text);
|
||||
DrawTextWithShadow(font, data->selected==3 ? al_map_rgb(255,222, 120) : al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.8, ALLEGRO_ALIGN_CENTRE, "Back");
|
||||
break;
|
||||
default:
|
||||
data->selected=0;
|
||||
DrawTextWithShadow(font, data->selected==0 ? al_map_rgb(255,222, 120) : al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.5, ALLEGRO_ALIGN_CENTRE, "Not implemented yet");
|
||||
break;
|
||||
}
|
||||
free(text);
|
||||
|
||||
al_use_transform(&cur_trans);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ChangeMenuState(struct Game *game, struct MenuResources* data, enum menustate_enum state) {
|
||||
data->menustate=state;
|
||||
data->selected=0;
|
||||
if (state == MENUSTATE_HIDDEN) {
|
||||
al_set_sample_instance_gain(game->muzyczka.instance.fg, 0.0);
|
||||
} else {
|
||||
al_set_sample_instance_gain(game->muzyczka.instance.fg, 1.5);
|
||||
}
|
||||
PrintConsole(game, "menu state changed %d", state);
|
||||
}
|
||||
|
||||
void Gamestate_Draw(struct Game *game, struct MenuResources* data) {
|
||||
|
||||
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||
|
||||
al_clear_to_color(al_map_rgb(3, 213, 255));
|
||||
|
||||
al_draw_bitmap(data->bg, 0, 0, 0);
|
||||
al_draw_bitmap(data->monster, data->monster_pos, 10, 0);
|
||||
if (!data->starting) {
|
||||
al_draw_bitmap(data->title, 12, 25 - (pow(sin(data->title_pos), 2) * 16) - data->screen_pos, 0);
|
||||
}
|
||||
|
||||
if ((data->menustate == MENUSTATE_HIDDEN) && (!data->starting)) {
|
||||
DrawTextWithShadow(game->_priv.font, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.9, ALLEGRO_ALIGN_CENTRE, "Press RETURN");
|
||||
}
|
||||
|
||||
DrawMenuState(game, data);
|
||||
}
|
||||
|
||||
|
||||
void Gamestate_Logic(struct Game *game, struct MenuResources* data) {
|
||||
|
||||
data->title_pos += 0.05;
|
||||
|
||||
if (data->starting) {
|
||||
data->monster_pos -= 6;
|
||||
|
||||
if (data->monster_pos < -202) {
|
||||
data->starting = false;
|
||||
LoadGamestate(game, "theend");
|
||||
LoadGamestate(game, "info");
|
||||
LoadGamestate(game, "rockets");
|
||||
LoadGamestate(game, "riots");
|
||||
LoadGamestate(game, "lollipop");
|
||||
LoadGamestate(game, "bonus");
|
||||
StartGamestate(game, "info");
|
||||
StopGamestate(game, "menu");
|
||||
}
|
||||
|
||||
} else {
|
||||
data->monster_pos += 6;
|
||||
if (data->monster_pos > -40) {
|
||||
data->monster_pos = -40;
|
||||
}
|
||||
}
|
||||
|
||||
if (data->menustate == MENUSTATE_HIDDEN) {
|
||||
data->screen_pos -= (180 - data->screen_pos) / 4 + 1;
|
||||
if (data->screen_pos < 0) {
|
||||
data->screen_pos = 0;
|
||||
data->invisible = false;
|
||||
}
|
||||
} else {
|
||||
data->invisible = false;
|
||||
data->screen_pos += (data->screen_pos) / 4 + 1;
|
||||
if (data->screen_pos > 180) {
|
||||
data->screen_pos = 180;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void* Gamestate_Load(struct Game *game, void (*progress)(struct Game*)) {
|
||||
|
||||
struct MenuResources *data = malloc(sizeof(struct MenuResources));
|
||||
|
||||
data->options.fullscreen = game->config.fullscreen;
|
||||
data->options.fps = game->config.fps;
|
||||
data->options.width = game->config.width;
|
||||
data->options.height = game->config.height;
|
||||
data->options.resolution = game->config.width / 320;
|
||||
if (game->config.height / 180 < data->options.resolution) data->options.resolution = game->config.height / 180;
|
||||
(*progress)(game);
|
||||
|
||||
data->bg = al_load_bitmap( GetDataFilePath(game, "bg.png") );
|
||||
data->monster = al_load_bitmap( GetDataFilePath(game, "light.png") );
|
||||
data->title = al_load_bitmap( GetDataFilePath(game, "title.png") );
|
||||
(*progress)(game);
|
||||
|
||||
game->muzyczka.sample.fg = al_load_sample( GetDataFilePath(game, "song-fg.flac") );
|
||||
game->muzyczka.sample.bg = al_load_sample( GetDataFilePath(game, "song-bg.flac") );
|
||||
game->muzyczka.sample.drums = al_load_sample( GetDataFilePath(game, "song-drums.flac") );
|
||||
data->click_sample = al_load_sample( GetDataFilePath(game, "click.flac") );
|
||||
(*progress)(game);
|
||||
|
||||
game->muzyczka.instance.fg = al_create_sample_instance(game->muzyczka.sample.fg);
|
||||
al_attach_sample_instance_to_mixer(game->muzyczka.instance.fg, game->audio.music);
|
||||
al_set_sample_instance_playmode(game->muzyczka.instance.fg, ALLEGRO_PLAYMODE_LOOP);
|
||||
|
||||
game->muzyczka.instance.bg = al_create_sample_instance(game->muzyczka.sample.bg);
|
||||
al_attach_sample_instance_to_mixer(game->muzyczka.instance.bg, game->audio.music);
|
||||
al_set_sample_instance_playmode(game->muzyczka.instance.bg, ALLEGRO_PLAYMODE_LOOP);
|
||||
|
||||
game->muzyczka.instance.drums = al_create_sample_instance(game->muzyczka.sample.drums);
|
||||
al_attach_sample_instance_to_mixer(game->muzyczka.instance.drums, game->audio.music);
|
||||
al_set_sample_instance_playmode(game->muzyczka.instance.drums, ALLEGRO_PLAYMODE_LOOP);
|
||||
|
||||
data->click = al_create_sample_instance(data->click_sample);
|
||||
al_attach_sample_instance_to_mixer(data->click, game->audio.fx);
|
||||
al_set_sample_instance_playmode(data->click, ALLEGRO_PLAYMODE_ONCE);
|
||||
|
||||
if (!data->click_sample){
|
||||
fprintf(stderr, "Audio clip sample not loaded!\n" );
|
||||
exit(-1);
|
||||
}
|
||||
(*progress)(game);
|
||||
|
||||
data->font = al_load_ttf_font(GetDataFilePath(game, "fonts/MonkeyIsland.ttf"),game->viewport.height*0.05,0 );
|
||||
|
||||
al_set_target_backbuffer(game->display);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
void Gamestate_Stop(struct Game *game, struct MenuResources* data) {
|
||||
//al_stop_sample_instance(data->music);
|
||||
}
|
||||
|
||||
void Gamestate_Unload(struct Game *game, struct MenuResources* data) {
|
||||
//al_stop_sample_instance(data->music);
|
||||
al_destroy_bitmap(data->bg);
|
||||
al_destroy_bitmap(data->title);
|
||||
al_destroy_bitmap(data->monster);
|
||||
al_destroy_font(data->font);
|
||||
//al_destroy_sample_instance(data->music);
|
||||
al_destroy_sample_instance(data->click);
|
||||
//al_destroy_sample(data->sample);
|
||||
al_destroy_sample(data->click_sample);
|
||||
}
|
||||
|
||||
|
||||
void StartGame(struct Game *game, struct MenuResources *data) {
|
||||
|
||||
game->mediator.lives = 3;
|
||||
game->mediator.score = 0;
|
||||
game->mediator.modificator = 0.9756;
|
||||
|
||||
ChangeMenuState(game,data,MENUSTATE_HIDDEN);
|
||||
al_set_sample_instance_gain(game->muzyczka.instance.drums, 0.0);
|
||||
al_set_sample_instance_gain(game->muzyczka.instance.fg, 1.5);
|
||||
al_set_sample_instance_gain(game->muzyczka.instance.bg, 1.5);
|
||||
data->starting = true;
|
||||
}
|
||||
|
||||
|
||||
void Gamestate_Start(struct Game *game, struct MenuResources* data) {
|
||||
|
||||
al_ungrab_mouse();
|
||||
if (!game->config.fullscreen) al_show_mouse_cursor(game->display);
|
||||
|
||||
data->title_pos = 0;
|
||||
data->screen_pos = 180;
|
||||
data->invisible = true;
|
||||
data->monster_pos = -202;
|
||||
data->starting = false;
|
||||
|
||||
ChangeMenuState(game,data,MENUSTATE_HIDDEN);
|
||||
al_play_sample_instance(game->muzyczka.instance.fg);
|
||||
al_play_sample_instance(game->muzyczka.instance.bg);
|
||||
al_play_sample_instance(game->muzyczka.instance.drums);
|
||||
al_set_sample_instance_gain(game->muzyczka.instance.fg, 0.0);
|
||||
al_set_sample_instance_gain(game->muzyczka.instance.bg, 1.5);
|
||||
al_set_sample_instance_gain(game->muzyczka.instance.drums, 1.5);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Gamestate_ProcessEvent(struct Game *game, struct MenuResources* data, ALLEGRO_EVENT *ev) {
|
||||
|
||||
if ((data->menustate == MENUSTATE_ABOUT) && (ev->type == ALLEGRO_EVENT_KEY_DOWN)) {
|
||||
ChangeMenuState(game, data, MENUSTATE_MAIN);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ev->type != ALLEGRO_EVENT_KEY_DOWN) return;
|
||||
|
||||
if (data->starting) return;
|
||||
|
||||
if (ev->keyboard.keycode==ALLEGRO_KEY_UP) {
|
||||
data->selected--;
|
||||
if ((data->selected == 2) && ((data->menustate==MENUSTATE_VIDEO) || (data->menustate==MENUSTATE_OPTIONS) || (data->menustate==MENUSTATE_AUDIO))) {
|
||||
data->selected --;
|
||||
}
|
||||
if ((data->menustate==MENUSTATE_VIDEO) && (data->selected==1) && (data->options.fullscreen)) data->selected--;
|
||||
al_play_sample_instance(data->click);
|
||||
} else if (ev->keyboard.keycode==ALLEGRO_KEY_DOWN) {
|
||||
data->selected++;
|
||||
if ((data->menustate==MENUSTATE_VIDEO) && (data->selected==1) && (data->options.fullscreen)) data->selected++;
|
||||
if ((data->selected == 2) && ((data->menustate==MENUSTATE_VIDEO) || (data->menustate==MENUSTATE_OPTIONS) || (data->menustate==MENUSTATE_AUDIO))) {
|
||||
data->selected ++;
|
||||
}
|
||||
|
||||
|
||||
al_play_sample_instance(data->click);
|
||||
}
|
||||
|
||||
if (ev->keyboard.keycode==ALLEGRO_KEY_ENTER) {
|
||||
char *text;
|
||||
al_play_sample_instance(data->click);
|
||||
switch (data->menustate) {
|
||||
case MENUSTATE_MAIN:
|
||||
switch (data->selected) {
|
||||
case 0:
|
||||
StartGame(game, data);
|
||||
break;
|
||||
case 1:
|
||||
ChangeMenuState(game,data,MENUSTATE_OPTIONS);
|
||||
break;
|
||||
case 2:
|
||||
ChangeMenuState(game,data,MENUSTATE_ABOUT);
|
||||
break;
|
||||
case 3:
|
||||
UnloadGamestate(game, "menu");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case MENUSTATE_HIDDEN:
|
||||
ChangeMenuState(game,data,MENUSTATE_MAIN);
|
||||
break;
|
||||
case MENUSTATE_AUDIO:
|
||||
text = malloc(255*sizeof(char));
|
||||
switch (data->selected) {
|
||||
case 0:
|
||||
game->config.music--;
|
||||
if (game->config.music<0) game->config.music=10;
|
||||
snprintf(text, 255, "%d", game->config.music);
|
||||
SetConfigOption(game, "SuperDerpy", "music", text);
|
||||
al_set_mixer_gain(game->audio.music, game->config.music/10.0);
|
||||
break;
|
||||
case 1:
|
||||
game->config.fx--;
|
||||
if (game->config.fx<0) game->config.fx=10;
|
||||
snprintf(text, 255, "%d", game->config.fx);
|
||||
SetConfigOption(game, "SuperDerpy", "fx", text);
|
||||
al_set_mixer_gain(game->audio.fx, game->config.fx/10.0);
|
||||
break;
|
||||
case 2:
|
||||
game->config.voice--;
|
||||
if (game->config.voice<0) game->config.voice=10;
|
||||
snprintf(text, 255, "%d", game->config.voice);
|
||||
SetConfigOption(game, "SuperDerpy", "voice", text);
|
||||
al_set_mixer_gain(game->audio.voice, game->config.voice/10.0);
|
||||
break;
|
||||
case 3:
|
||||
ChangeMenuState(game,data,MENUSTATE_OPTIONS);
|
||||
break;
|
||||
}
|
||||
free(text);
|
||||
break;
|
||||
case MENUSTATE_OPTIONS:
|
||||
switch (data->selected) {
|
||||
case 0:
|
||||
ChangeMenuState(game,data,MENUSTATE_VIDEO);
|
||||
break;
|
||||
case 1:
|
||||
ChangeMenuState(game,data,MENUSTATE_AUDIO);
|
||||
break;
|
||||
case 3:
|
||||
ChangeMenuState(game,data,MENUSTATE_MAIN);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case MENUSTATE_VIDEO:
|
||||
switch (data->selected) {
|
||||
case 0:
|
||||
data->options.fullscreen = !data->options.fullscreen;
|
||||
if (data->options.fullscreen)
|
||||
SetConfigOption(game, "SuperDerpy", "fullscreen", "1");
|
||||
else
|
||||
SetConfigOption(game, "SuperDerpy", "fullscreen", "0");
|
||||
al_set_display_flag(game->display, ALLEGRO_FULLSCREEN_WINDOW, data->options.fullscreen);
|
||||
game->config.fullscreen = data->options.fullscreen;
|
||||
if (!data->options.fullscreen) {
|
||||
al_show_mouse_cursor(game->display);
|
||||
} else {
|
||||
al_hide_mouse_cursor(game->display);
|
||||
}
|
||||
SetupViewport(game);
|
||||
PrintConsole(game, "Fullscreen toggled");
|
||||
break;
|
||||
case 1:
|
||||
data->options.resolution++;
|
||||
|
||||
int max = 0, i = 0;
|
||||
|
||||
for (i=0; i < al_get_num_video_adapters(); i++) {
|
||||
ALLEGRO_MONITOR_INFO aminfo;
|
||||
al_get_monitor_info(i , &aminfo);
|
||||
int desktop_width = aminfo.x2 - aminfo.x1 + 1;
|
||||
int desktop_height = aminfo.y2 - aminfo.y1 + 1;
|
||||
int localmax = desktop_width / 320;
|
||||
if (desktop_height / 180 < localmax) localmax = desktop_height / 180;
|
||||
if (localmax > max) max = localmax;
|
||||
}
|
||||
|
||||
|
||||
if (data->options.resolution > max) data->options.resolution = 1;
|
||||
text = malloc(255*sizeof(char));
|
||||
snprintf(text, 255, "%d", data->options.resolution * 320);
|
||||
SetConfigOption(game, "SuperDerpy", "width", text);
|
||||
snprintf(text, 255, "%d", data->options.resolution * 180);
|
||||
SetConfigOption(game, "SuperDerpy", "height", text);
|
||||
free(text);
|
||||
al_resize_display(game->display, data->options.resolution * 320, data->options.resolution * 180);
|
||||
|
||||
if ((al_get_display_width(game->display) < (data->options.resolution * 320)) || (al_get_display_height(game->display) < (data->options.resolution * 180))) {
|
||||
SetConfigOption(game, "SuperDerpy", "width", "320");
|
||||
SetConfigOption(game, "SuperDerpy", "height", "180");
|
||||
data->options.resolution = 1;
|
||||
al_resize_display(game->display, 320, 180);
|
||||
}
|
||||
|
||||
SetupViewport(game);
|
||||
PrintConsole(game, "Resolution changed");
|
||||
break;
|
||||
case 3:
|
||||
ChangeMenuState(game,data,MENUSTATE_OPTIONS);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case MENUSTATE_ABOUT:
|
||||
break;
|
||||
default:
|
||||
UnloadGamestate(game, "menu");
|
||||
return;
|
||||
break;
|
||||
}
|
||||
} else if (ev->keyboard.keycode==ALLEGRO_KEY_ESCAPE) {
|
||||
switch (data->menustate) {
|
||||
case MENUSTATE_OPTIONS:
|
||||
ChangeMenuState(game,data,MENUSTATE_MAIN);
|
||||
break;
|
||||
case MENUSTATE_ABOUT:
|
||||
ChangeMenuState(game,data,MENUSTATE_MAIN);
|
||||
break;
|
||||
case MENUSTATE_HIDDEN:
|
||||
UnloadGamestate(game, "menu");
|
||||
break;
|
||||
case MENUSTATE_VIDEO:
|
||||
ChangeMenuState(game,data,MENUSTATE_OPTIONS);
|
||||
break;
|
||||
case MENUSTATE_AUDIO:
|
||||
ChangeMenuState(game,data,MENUSTATE_OPTIONS);
|
||||
break;
|
||||
default:
|
||||
ChangeMenuState(game,data,MENUSTATE_HIDDEN);
|
||||
data->selected = -1;
|
||||
data->title_pos = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (data->selected==-1) data->selected=3;
|
||||
if (data->selected==4) data->selected=0;
|
||||
return;
|
||||
}
|
||||
|
||||
void Gamestate_Pause(struct Game *game, struct MenuResources* data) {}
|
||||
void Gamestate_Resume(struct Game *game, struct MenuResources* data) {}
|
||||
void Gamestate_Reload(struct Game *game, struct MenuResources* data) {}
|
|
@ -1,63 +0,0 @@
|
|||
/*! \file menu.h
|
||||
* \brief Main Menu view headers.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <allegro5/allegro.h>
|
||||
#include <allegro5/allegro_font.h>
|
||||
#include <allegro5/allegro_audio.h>
|
||||
|
||||
/*! \brief Enum of menu states in Menu and Pause game states. */
|
||||
enum menustate_enum {
|
||||
MENUSTATE_HIDDEN,
|
||||
MENUSTATE_MAIN,
|
||||
MENUSTATE_OPTIONS,
|
||||
MENUSTATE_VIDEO,
|
||||
MENUSTATE_AUDIO,
|
||||
MENUSTATE_ABOUT
|
||||
};
|
||||
|
||||
/*! \brief Resources used by Menu state. */
|
||||
struct MenuResources {
|
||||
ALLEGRO_BITMAP *bg;
|
||||
ALLEGRO_BITMAP *monster; /*!< Bitmap with bigger cloud. */
|
||||
ALLEGRO_BITMAP *title;
|
||||
|
||||
double title_pos;
|
||||
int screen_pos;
|
||||
bool invisible;
|
||||
int monster_pos;
|
||||
bool starting;
|
||||
|
||||
ALLEGRO_SAMPLE *sample; /*!< Music sample. */
|
||||
ALLEGRO_SAMPLE *click_sample; /*!< Click sound sample. */
|
||||
ALLEGRO_SAMPLE_INSTANCE *music; /*!< Sample instance with music sound. */
|
||||
ALLEGRO_SAMPLE_INSTANCE *click; /*!< Sample instance with click sound. */
|
||||
ALLEGRO_FONT *font; /*!< Font of standard menu item. */
|
||||
int selected; /*!< Number of selected menu item. */
|
||||
enum menustate_enum menustate; /*!< Current menu page. */
|
||||
struct {
|
||||
bool fullscreen;
|
||||
int fps;
|
||||
int width;
|
||||
int height;
|
||||
int resolution;
|
||||
} options; /*!< Options which can be changed in menu. */
|
||||
|
||||
};
|
|
@ -1,117 +0,0 @@
|
|||
/*! \file pause.c
|
||||
* \brief Pause state.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "../config.h"
|
||||
#include "pause.h"
|
||||
#include "menu.h"
|
||||
#include "level.h"
|
||||
#include "loading.h"
|
||||
|
||||
int Pause_Keydown(struct Game *game, ALLEGRO_EVENT *ev) {
|
||||
if ((game->menu.menustate==MENUSTATE_OPTIONS) && ((ev->keyboard.keycode==ALLEGRO_KEY_ESCAPE) || ((ev->keyboard.keycode==ALLEGRO_KEY_ENTER) && (game->menu.selected==3)))) {
|
||||
al_play_sample_instance(game->menu.click);
|
||||
ChangeMenuState(game,MENUSTATE_PAUSE);
|
||||
} else if ((game->menu.menustate==MENUSTATE_VIDEO) && ((ev->keyboard.keycode==ALLEGRO_KEY_ESCAPE) || ((ev->keyboard.keycode==ALLEGRO_KEY_ENTER) && (game->menu.selected==3)))) {
|
||||
al_play_sample_instance(game->menu.click);
|
||||
ChangeMenuState(game,MENUSTATE_OPTIONS);
|
||||
if (game->menu.options.fullscreen!=game->fullscreen) {
|
||||
al_toggle_display_flag(game->display, ALLEGRO_FULLSCREEN_WINDOW, game->menu.options.fullscreen);
|
||||
al_clear_to_color(al_map_rgb(0,0,0));
|
||||
al_flip_display();
|
||||
game->fullscreen = game->menu.options.fullscreen;
|
||||
if (game->fullscreen) al_hide_mouse_cursor(game->display);
|
||||
else al_show_mouse_cursor(game->display);
|
||||
Shared_Unload(game);
|
||||
al_clear_to_color(al_map_rgb(0,0,0));
|
||||
al_flip_display();
|
||||
SetupViewport(game);
|
||||
Shared_Load(game);
|
||||
|
||||
void Progress(struct Game *game, float p) {
|
||||
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||
al_clear_to_color(al_map_rgb(0,0,0));
|
||||
al_draw_text_with_shadow(game->font, al_map_rgb(255,255,255), game->viewportWidth*0.0234, game->viewportHeight*0.84, ALLEGRO_ALIGN_LEFT, "Loading...");
|
||||
al_draw_filled_rectangle(0, game->viewportHeight*0.985, game->viewportWidth, game->viewportHeight, al_map_rgba(128,128,128,128));
|
||||
al_draw_filled_rectangle(0, game->viewportHeight*0.985, p*game->viewportWidth, game->viewportHeight, al_map_rgba(255,255,255,255));
|
||||
al_flip_display();
|
||||
}
|
||||
Progress(game, 0);
|
||||
|
||||
Loading_Unload(game);
|
||||
Loading_Load(game);
|
||||
Menu_Unload(game);
|
||||
Menu_Preload(game, NULL);
|
||||
Level_UnloadBitmaps(game);
|
||||
Level_PreloadBitmaps(game, &Progress);
|
||||
Pause_Unload_Real(game);
|
||||
Pause_Preload(game);
|
||||
Pause_Load(game);
|
||||
}
|
||||
} else return Menu_Keydown(game, ev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Pause_Preload(struct Game* game) {
|
||||
game->pause.bitmap = NULL;
|
||||
game->pause.derpy = LoadScaledBitmap("levels/derpy_pause.png", game->viewportHeight*1.6*0.53, game->viewportHeight*0.604);
|
||||
PrintConsole(game,"Pause preloaded.");
|
||||
if (!game->menu.loaded) {
|
||||
PrintConsole(game,"Pause: Preloading GAMESTATE_MENU...");
|
||||
Menu_Preload(game, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void Pause_Load(struct Game* game) {
|
||||
ALLEGRO_BITMAP *fade = al_create_bitmap(game->viewportWidth, game->viewportHeight);
|
||||
al_set_target_bitmap(fade);
|
||||
al_clear_to_color(al_map_rgb(0,0,0));
|
||||
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||
game->pause.bitmap = fade;
|
||||
ChangeMenuState(game,MENUSTATE_PAUSE);
|
||||
PrintConsole(game,"Game paused.");
|
||||
al_play_sample_instance(game->menu.click);
|
||||
}
|
||||
|
||||
void Pause_Draw(struct Game* game) {
|
||||
game->gamestate=game->loadstate;
|
||||
game->loadstate=GAMESTATE_PAUSE;
|
||||
DrawGameState(game);
|
||||
game->loadstate=game->gamestate;
|
||||
game->gamestate=GAMESTATE_PAUSE;
|
||||
al_draw_tinted_bitmap(game->pause.bitmap,al_map_rgba_f(1,1,1,0.75),0,0,0);
|
||||
al_draw_bitmap(game->pause.derpy, game->viewportWidth-al_get_bitmap_width(game->pause.derpy), game->viewportHeight*0.4, 0);
|
||||
al_draw_text_with_shadow(game->menu.font_title, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.1, ALLEGRO_ALIGN_CENTRE, "Super Derpy");
|
||||
al_draw_text_with_shadow(game->menu.font_subtitle, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.275, ALLEGRO_ALIGN_CENTRE, "Game paused.");
|
||||
DrawMenuState(game);
|
||||
}
|
||||
|
||||
void Pause_Unload_Real(struct Game* game) {
|
||||
PrintConsole(game,"Pause unloaded.");
|
||||
if (game->pause.bitmap) al_destroy_bitmap(game->pause.bitmap);
|
||||
al_destroy_bitmap(game->pause.derpy);
|
||||
}
|
||||
|
||||
void Pause_Unload(struct Game* game) {
|
||||
game->gamestate=game->loadstate;
|
||||
UnloadGameState(game);
|
||||
PrintConsole(game, "Pause: Unloading GAMESTATE_MENU...");
|
||||
Menu_Unload(game);
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
/*! \file pause.h
|
||||
* \brief Pause state headers.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#include "../main.h"
|
||||
|
||||
void Pause_Draw(struct Game *game);
|
||||
void Pause_Preload(struct Game *game);
|
||||
void Pause_Unload_Real(struct Game* game);
|
||||
void Pause_Unload(struct Game *game);
|
||||
void Pause_Load(struct Game *game);
|
||||
int Pause_Keydown(struct Game *game, ALLEGRO_EVENT *ev);
|
|
@ -1,506 +0,0 @@
|
|||
/*! \file dosowisko.c
|
||||
* \brief Init animation with dosowisko.net logo.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <allegro5/allegro_ttf.h>
|
||||
#include <allegro5/allegro_primitives.h>
|
||||
#include <math.h>
|
||||
#include "../utils.h"
|
||||
#include "../timeline.h"
|
||||
#include "riots.h"
|
||||
|
||||
int Gamestate_ProgressCount = 11;
|
||||
|
||||
struct Rocket* CreateRocket(struct Game *game, struct RocketsResources* data, struct Rocket* rockets, bool right) {
|
||||
struct Rocket *n = malloc(sizeof(struct Rocket));
|
||||
n->next = NULL;
|
||||
n->prev = NULL;
|
||||
n->dx = (right ? -1.5 : 1.5) + (rand() / (float)RAND_MAX) * 0.6 - 0.3;
|
||||
n->dy = -2.1 + (rand() / (float)RAND_MAX) * 0.5 - 0.25;
|
||||
n->modifier = 0.025;
|
||||
n->blown = false;
|
||||
n->character = CreateCharacter(game, "rocket");
|
||||
n->character->spritesheets = data->rocket_template->spritesheets;
|
||||
n->character->shared = true;
|
||||
SelectSpritesheet(game, n->character, rand() % 2 ? "rock" : rand() % 2 ? "bottle" : "bottle2");
|
||||
SetCharacterPosition(game, n->character, (right ? 250 : 50) + rand() % 90 - 40, 100, right ? -0.33 : 0.33);
|
||||
al_play_sample_instance(data->jump_sound);
|
||||
data->currentspawn = data->spawnspeed + (data->spawnspeed * 0.1) * (float)(rand() / (float)RAND_MAX * 2) - (data->spawnspeed * 0.05);
|
||||
|
||||
if (rockets) {
|
||||
struct Rocket *tmp = rockets;
|
||||
while (tmp->next) {
|
||||
tmp=tmp->next;
|
||||
}
|
||||
tmp->next = n;
|
||||
n->prev = tmp;
|
||||
return rockets;
|
||||
} else {
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DrawRockets(struct Game *game, struct RocketsResources* data, struct Rocket* rockets) {
|
||||
struct Rocket *tmp = rockets;
|
||||
while (tmp) {
|
||||
DrawCharacter(game, tmp->character, al_map_rgb(255,255,255), 0);
|
||||
|
||||
tmp=tmp->next;
|
||||
}
|
||||
}
|
||||
|
||||
bool switchMinigame(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||
if (state == TM_ACTIONSTATE_START) {
|
||||
StopGamestate(game, "riots");
|
||||
game->mediator.next = "rockets";
|
||||
StartGamestate(game, GetAbstractIsItBonusLevelTimeNowFactoryProvider(game) ? "bonus" : "rockets");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool theEnd(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||
if (state == TM_ACTIONSTATE_START) {
|
||||
StopGamestate(game, "riots");
|
||||
StartGamestate(game, "theend");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void UpdateRockets(struct Game *game, struct RocketsResources *data, struct Rocket* rockets) {
|
||||
struct Rocket *tmp = rockets;
|
||||
while (tmp) {
|
||||
tmp->dy+= tmp->modifier;
|
||||
if (!tmp->blown) {
|
||||
tmp->dx+= (tmp->dx > 0) ? (-tmp->modifier / 5 + 0.001) : (tmp->modifier / 5 - 0.001);
|
||||
}
|
||||
MoveCharacter(game, tmp->character, tmp->dx, tmp->dy, tmp->blown ? 0 : ((tmp->dx > 0) ? 0.0166 : -0.0166));
|
||||
AnimateCharacter(game, tmp->character, 1);
|
||||
|
||||
if (!tmp->blown) {
|
||||
|
||||
if (((((tmp->character->y > 90) && (rand() % 4 == 0) && (tmp->dy > 0)))) && (tmp->character->x > -20 && tmp->character->x < 320)) {
|
||||
tmp->blown = true;
|
||||
tmp->modifier = 0;
|
||||
tmp->character->angle = 0;
|
||||
tmp->dx = 0;
|
||||
tmp->dy = 0;
|
||||
SelectSpritesheet(game, tmp->character, "boom");
|
||||
MoveCharacter(game, tmp->character, 5, 5, 0);
|
||||
|
||||
if (!((tmp->character->x > 140) && (tmp->character->x < 180))) {
|
||||
if (!data->lost) {
|
||||
AdvanceLevel(game, false);
|
||||
|
||||
data->lost = true;
|
||||
data->flash = 4;
|
||||
data->counter = 0;
|
||||
TM_AddDelay(data->timeline, 3500);
|
||||
if (game->mediator.lives > 0) {
|
||||
TM_AddAction(data->timeline, switchMinigame, NULL, "switchMinigame");
|
||||
} else {
|
||||
TM_AddAction(data->timeline, theEnd, NULL, "theEnd");
|
||||
}
|
||||
data->spawnspeed = 10;
|
||||
|
||||
al_play_sample_instance(data->riot_sound);
|
||||
|
||||
}
|
||||
al_play_sample_instance(data->boom_sound);
|
||||
|
||||
}
|
||||
|
||||
} else if (tmp->character->x < -20 || tmp->character->x > 320) {
|
||||
tmp->blown = true;
|
||||
tmp->modifier = 0;
|
||||
tmp->character->angle = 0;
|
||||
tmp->dx = 0;
|
||||
tmp->dy = 0;
|
||||
SelectSpritesheet(game, tmp->character, "blank");
|
||||
al_play_sample_instance(data->boom_sound);
|
||||
}
|
||||
}
|
||||
tmp=tmp->next;
|
||||
}
|
||||
}
|
||||
|
||||
void Gamestate_Logic(struct Game *game, struct RocketsResources* data) {
|
||||
|
||||
if ((data->spawncounter == data->currentspawn) && ((data->counter < data->timelimit) || (data->lost))) {
|
||||
if (rand() % 2 == 0) {
|
||||
data->rockets_left = CreateRocket(game, data, data->rockets_left, false);
|
||||
} else {
|
||||
data->rockets_right = CreateRocket(game, data, data->rockets_right, true);
|
||||
}
|
||||
data->spawncounter = 0;
|
||||
}
|
||||
|
||||
if (!data->flash) {
|
||||
UpdateRockets(game, data, data->rockets_left);
|
||||
UpdateRockets(game, data, data->rockets_right);
|
||||
} else {
|
||||
data->flash--;
|
||||
}
|
||||
|
||||
if (data->lost) {
|
||||
data->zadyma++;
|
||||
if (data->zadyma >= 255) {
|
||||
data->zadyma = 255;
|
||||
}
|
||||
}
|
||||
|
||||
AnimateCharacter(game, data->usa_flag, 1);
|
||||
AnimateCharacter(game, data->ru_flag, 1);
|
||||
AnimateCharacter(game, data->riot, 1);
|
||||
if ((data->lost) && (data->hearts > 80)) {
|
||||
AnimateCharacter(game, game->mediator.heart, 1);
|
||||
if (game->mediator.heart->pos == 6) {
|
||||
al_play_sample_instance(data->boom_sound);
|
||||
}
|
||||
}
|
||||
|
||||
if (data->lost) {
|
||||
data->hearts++;
|
||||
}
|
||||
|
||||
if (data->won) {
|
||||
AnimateCharacter(game, data->euro, 1);
|
||||
}
|
||||
|
||||
if ((data->counter >= data->timelimit) && (!data->lost) && (!data->won)) {
|
||||
bool stillthere = false;
|
||||
struct Rocket *tmp = data->rockets_left;
|
||||
while (tmp) {
|
||||
if (!tmp->blown) {
|
||||
stillthere = true;
|
||||
break;
|
||||
}
|
||||
tmp = tmp->next;
|
||||
}
|
||||
tmp = data->rockets_right;
|
||||
while (tmp) {
|
||||
if (!tmp->blown) {
|
||||
stillthere = true;
|
||||
break;
|
||||
}
|
||||
tmp = tmp->next;
|
||||
}
|
||||
if (!stillthere) {
|
||||
SelectSpritesheet(game, data->euro, "euro");
|
||||
SetCharacterPosition(game, data->euro, 0, 0, 0);
|
||||
al_play_sample_instance(data->wuwu_sound);
|
||||
data->won = true;
|
||||
AdvanceLevel(game, true);
|
||||
SelectSpritesheet(game, data->usa_flag, "poland");
|
||||
SelectSpritesheet(game, data->ru_flag, "poland");
|
||||
TM_AddDelay(data->timeline, 2500);
|
||||
TM_AddAction(data->timeline, switchMinigame, NULL, "switchMinigame");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void iterate(struct Rocket *start) {
|
||||
struct Rocket *tmp1 = start;
|
||||
while (tmp1) {
|
||||
if (!tmp1->blown) {
|
||||
// if (CheckCollision(game, data, data->cursor, tmp1->character)) {
|
||||
|
||||
if ( (abs(tmp1->character->y - data->cursor->y) <= 10) &&
|
||||
(((tmp1->character->x <= data->cursor->x + al_get_bitmap_width(data->cursor->bitmap)) && (tmp1->character->x + al_get_bitmap_width(tmp1->character->bitmap) >= data->cursor->x + al_get_bitmap_width(data->cursor->bitmap))) ||
|
||||
|
||||
((tmp1->character->x + al_get_bitmap_width(tmp1->character->bitmap) >= data->cursor->x) && (tmp1->character->x + al_get_bitmap_width(tmp1->character->bitmap) <= data->cursor->x + al_get_bitmap_width(data->cursor->bitmap))) )) {
|
||||
|
||||
if (tmp1->character->y < data->cursor->y) {
|
||||
tmp1->dx = 0;
|
||||
tmp1->dy = 0;
|
||||
tmp1->modifier = 0;
|
||||
tmp1->blown = true;
|
||||
SelectSpritesheet(game, tmp1->character, "blank");
|
||||
} else if (tmp1->dy < 0) {
|
||||
tmp1->dy *= -1;
|
||||
}
|
||||
|
||||
al_play_sample_instance(data->rocket_sound);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
tmp1 = tmp1->next;
|
||||
}
|
||||
|
||||
}
|
||||
iterate(data->rockets_left);
|
||||
iterate(data->rockets_right);
|
||||
|
||||
data->counter++;
|
||||
data->spawncounter++;
|
||||
data->cloud_rotation += 0.002;
|
||||
|
||||
TM_Process(data->timeline);
|
||||
}
|
||||
|
||||
void Gamestate_Draw(struct Game *game, struct RocketsResources* data) {
|
||||
|
||||
al_set_target_bitmap(data->pixelator);
|
||||
|
||||
if (!data->lost) {
|
||||
al_draw_bitmap(data->bg, 0, 0, 0);
|
||||
//al_draw_bitmap(data->earth2, 0, 0, 0);
|
||||
//al_draw_bitmap(data->combined, 0, 0, 0);
|
||||
} else if (!data->won) {
|
||||
al_draw_tinted_bitmap(data->bg, al_map_rgb(255, 192, 128), 0, 0, 0);
|
||||
//al_draw_tinted_bitmap(data->earth2, al_map_rgb(255, 192, 128), 0, 0, 0);
|
||||
//al_draw_tinted_bitmap(data->combined, al_map_rgb(255, 192, 128), 0, 0, 0);
|
||||
} else {
|
||||
al_draw_bitmap(data->bg, 0, 0, 0);
|
||||
al_draw_filled_rectangle(0, 0, 320, 180, al_map_rgba(255,255,255, 64));
|
||||
}
|
||||
|
||||
if (data->won) {
|
||||
DrawCharacter(game, data->euro, al_map_rgb(255,255,255), 0);
|
||||
}
|
||||
|
||||
|
||||
if ((!data->lost) && (!data->won)) {
|
||||
DrawCharacter(game, data->cursor, al_map_rgb(255,255,255), 0);
|
||||
}
|
||||
|
||||
DrawRockets(game, data, data->rockets_left);
|
||||
DrawRockets(game, data, data->rockets_right);
|
||||
|
||||
if (data->lost) {
|
||||
DrawCharacter(game, data->riot, al_map_rgb(255,255,255), 0);
|
||||
} else {
|
||||
DrawCharacter(game, data->usa_flag, al_map_rgb(255,255,255), 1);
|
||||
DrawCharacter(game, data->ru_flag, al_map_rgb(255,255,255), 0);
|
||||
al_draw_bitmap(data->earth, 5, 50, 0);
|
||||
}
|
||||
|
||||
|
||||
if (data->lost) {
|
||||
al_draw_tinted_bitmap(data->clouds, al_map_rgba(data->zadyma, data->zadyma, data->zadyma, data->zadyma), -data->counter / 2, 0, 0);
|
||||
al_draw_tinted_bitmap(data->clouds, al_map_rgba(data->zadyma, data->zadyma, data->zadyma, data->zadyma), -data->counter / 2 + 640, 0, 0);
|
||||
} else {
|
||||
al_draw_tinted_bitmap(data->clouds, al_map_rgba(data->zadyma, data->zadyma, data->zadyma, data->zadyma), -data->counter / 3, 0, 0);
|
||||
al_draw_tinted_bitmap(data->clouds, al_map_rgba(data->zadyma, data->zadyma, data->zadyma, data->zadyma), -data->counter / 3 + 640, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
if ((!data->lost) && (!data->won)) {
|
||||
al_draw_filled_rectangle(78, 5, 78+164, 5+5, al_map_rgb(155, 142, 142));
|
||||
al_draw_filled_rectangle(80, 6, 80+160, 6+3, al_map_rgb(66, 55, 30));
|
||||
al_draw_filled_rectangle(80, 6, (data->counter < data->timelimit) ? (80+ 160 * (1 - (data->counter / (float)data->timelimit))) : 80, 6+3, al_map_rgb(225,182, 80));
|
||||
}
|
||||
|
||||
if (data->flash) {
|
||||
al_draw_filled_rectangle(0, 0, 320, 180, al_map_rgb(255, 255, 255));
|
||||
}
|
||||
|
||||
al_set_target_backbuffer(game->display);
|
||||
al_draw_bitmap(data->pixelator, 0, 0, 0);
|
||||
|
||||
if ((data->lost) && (data->hearts > 80)) {
|
||||
ShowLevelStatistics(game);
|
||||
}
|
||||
|
||||
//Gamestate_Logic(game, data);
|
||||
|
||||
}
|
||||
|
||||
void Gamestate_Start(struct Game *game, struct RocketsResources* data) {
|
||||
data->rockets_left = NULL;
|
||||
data->rockets_right = NULL;
|
||||
|
||||
data->timelimit = 400 * game->mediator.modificator;
|
||||
data->spawnspeed = 80 / game->mediator.modificator;
|
||||
data->currentspawn = data->spawnspeed;
|
||||
data->spawncounter = data->spawnspeed - 20;
|
||||
|
||||
data->lost = false;
|
||||
data->won = false;
|
||||
data->hearts = 0;
|
||||
|
||||
data->flash = 0;
|
||||
data->zadyma = 16;
|
||||
|
||||
SetCharacterPosition(game, data->usa_flag, 185, 80, 0);
|
||||
SetCharacterPosition(game, data->ru_flag, 25, 80, 0);
|
||||
|
||||
SetCharacterPosition(game, data->cursor, 320/2, 50, 0);
|
||||
|
||||
SetCharacterPosition(game, data->riot, 0, 0, 0);
|
||||
SelectSpritesheet(game, data->riot, "riot");
|
||||
|
||||
SelectSpritesheet(game, data->usa_flag, "legia");
|
||||
SelectSpritesheet(game, data->ru_flag, "lech");
|
||||
|
||||
SelectSpritesheet(game, data->cursor, "hand");
|
||||
|
||||
data->counter = 0;
|
||||
data->cloud_rotation = 0;
|
||||
|
||||
data->mousemove.bottom = false;
|
||||
data->mousemove.top = false;
|
||||
data->mousemove.left = false;
|
||||
data->mousemove.right = false;
|
||||
|
||||
al_set_mouse_xy(game->display, al_get_display_width(game->display) / 2, al_get_display_height(game->display) / 2);
|
||||
|
||||
}
|
||||
|
||||
void Gamestate_ProcessEvent(struct Game *game, struct RocketsResources* data, ALLEGRO_EVENT *ev) {
|
||||
TM_HandleEvent(data->timeline, ev);
|
||||
if ((ev->type==ALLEGRO_EVENT_KEY_DOWN) && (ev->keyboard.keycode == ALLEGRO_KEY_ESCAPE)) {
|
||||
SwitchGamestate(game, "riots", "theend");
|
||||
} else if (ev->type == ALLEGRO_EVENT_MOUSE_AXES) {
|
||||
int mousex = ev->mouse.x / (al_get_display_width(game->display) / 320);
|
||||
int mousey = 50;
|
||||
data->mousemove.right = mousex > data->cursor->x;
|
||||
data->mousemove.top = mousey < data->cursor->y;
|
||||
data->mousemove.left = mousex < data->cursor->x;
|
||||
data->mousemove.bottom = mousey > data->cursor->y;
|
||||
SetCharacterPosition(game, data->cursor, mousex, mousey , 0); // FIXMEEEE!
|
||||
}
|
||||
}
|
||||
|
||||
void* Gamestate_Load(struct Game *game, void (*progress)(struct Game*)) {
|
||||
struct RocketsResources *data = malloc(sizeof(struct RocketsResources));
|
||||
|
||||
data->timeline = TM_Init(game, "riots");
|
||||
|
||||
data->bg = al_load_bitmap( GetDataFilePath(game, "riots/bg.png"));
|
||||
|
||||
data->earth = al_load_bitmap( GetDataFilePath(game, "riots/separator.png"));
|
||||
|
||||
data->clouds = al_load_bitmap( GetDataFilePath(game, "riots/fog.png"));
|
||||
(*progress)(game);
|
||||
|
||||
data->rocket_sample = al_load_sample( GetDataFilePath(game, "bump.flac") );
|
||||
(*progress)(game);
|
||||
data->boom_sample = al_load_sample( GetDataFilePath(game, "boom.flac") );
|
||||
(*progress)(game);
|
||||
data->jump_sample = al_load_sample( GetDataFilePath(game, "launch.flac") );
|
||||
(*progress)(game);
|
||||
data->rainbow_sample = al_load_sample( GetDataFilePath(game, "win.flac") );
|
||||
(*progress)(game);
|
||||
data->wuwu_sample = al_load_sample( GetDataFilePath(game, "riots/vuvu.flac") );
|
||||
(*progress)(game);
|
||||
data->riot_sample = al_load_sample( GetDataFilePath(game, "riots/riot.flac") );
|
||||
(*progress)(game);
|
||||
|
||||
data->rocket_sound = al_create_sample_instance(data->rocket_sample);
|
||||
al_attach_sample_instance_to_mixer(data->rocket_sound, game->audio.fx);
|
||||
al_set_sample_instance_playmode(data->rocket_sound, ALLEGRO_PLAYMODE_ONCE);
|
||||
|
||||
data->boom_sound = al_create_sample_instance(data->boom_sample);
|
||||
al_attach_sample_instance_to_mixer(data->boom_sound, game->audio.fx);
|
||||
al_set_sample_instance_playmode(data->boom_sound, ALLEGRO_PLAYMODE_ONCE);
|
||||
|
||||
data->rainbow_sound = al_create_sample_instance(data->rainbow_sample);
|
||||
al_attach_sample_instance_to_mixer(data->rainbow_sound, game->audio.fx);
|
||||
al_set_sample_instance_playmode(data->rainbow_sound, ALLEGRO_PLAYMODE_ONCE);
|
||||
|
||||
data->jump_sound = al_create_sample_instance(data->jump_sample);
|
||||
al_attach_sample_instance_to_mixer(data->jump_sound, game->audio.fx);
|
||||
al_set_sample_instance_playmode(data->jump_sound, ALLEGRO_PLAYMODE_ONCE);
|
||||
|
||||
data->riot_sound = al_create_sample_instance(data->riot_sample);
|
||||
al_attach_sample_instance_to_mixer(data->riot_sound, game->audio.fx);
|
||||
al_set_sample_instance_playmode(data->riot_sound, ALLEGRO_PLAYMODE_ONCE);
|
||||
|
||||
data->wuwu_sound = al_create_sample_instance(data->wuwu_sample);
|
||||
al_attach_sample_instance_to_mixer(data->wuwu_sound, game->audio.fx);
|
||||
al_set_sample_instance_playmode(data->wuwu_sound, ALLEGRO_PLAYMODE_ONCE);
|
||||
|
||||
|
||||
data->cursor = CreateCharacter(game, "cursor");
|
||||
RegisterSpritesheet(game, data->cursor, "hand");
|
||||
LoadSpritesheets(game, data->cursor);
|
||||
(*progress)(game);
|
||||
|
||||
data->pixelator = al_create_bitmap(320, 180);
|
||||
al_set_target_bitmap(data->pixelator);
|
||||
al_clear_to_color(al_map_rgb(0, 0, 0));
|
||||
|
||||
al_set_target_backbuffer(game->display);
|
||||
|
||||
data->rocket_template = CreateCharacter(game, "rocket");
|
||||
RegisterSpritesheet(game, data->rocket_template, "rock");
|
||||
RegisterSpritesheet(game, data->rocket_template, "bottle");
|
||||
RegisterSpritesheet(game, data->rocket_template, "bottle2");
|
||||
RegisterSpritesheet(game, data->rocket_template, "atom");
|
||||
RegisterSpritesheet(game, data->rocket_template, "boom");
|
||||
RegisterSpritesheet(game, data->rocket_template, "blank");
|
||||
LoadSpritesheets(game, data->rocket_template);
|
||||
(*progress)(game);
|
||||
|
||||
data->usa_flag = CreateCharacter(game, "kibols");
|
||||
RegisterSpritesheet(game, data->usa_flag, "legia");
|
||||
RegisterSpritesheet(game, data->usa_flag, "poland");
|
||||
LoadSpritesheets(game, data->usa_flag);
|
||||
|
||||
data->ru_flag = CreateCharacter(game, "kibols");
|
||||
RegisterSpritesheet(game, data->ru_flag, "lech");
|
||||
RegisterSpritesheet(game, data->ru_flag, "poland");
|
||||
LoadSpritesheets(game, data->ru_flag);
|
||||
(*progress)(game);
|
||||
|
||||
data->rainbow = CreateCharacter(game, "rainbow");
|
||||
RegisterSpritesheet(game, data->rainbow, "shine");
|
||||
RegisterSpritesheet(game, data->rainbow, "be");
|
||||
LoadSpritesheets(game, data->rainbow);
|
||||
|
||||
data->riot = CreateCharacter(game, "riot");
|
||||
RegisterSpritesheet(game, data->riot, "riot");
|
||||
LoadSpritesheets(game, data->riot);
|
||||
(*progress)(game);
|
||||
|
||||
data->euro = CreateCharacter(game, "euro");
|
||||
RegisterSpritesheet(game, data->euro, "euro");
|
||||
LoadSpritesheets(game, data->euro);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void Gamestate_Stop(struct Game *game, struct RocketsResources* data) {
|
||||
TM_CleanQueue(data->timeline);
|
||||
}
|
||||
|
||||
void Gamestate_Unload(struct Game *game, struct RocketsResources* data) {
|
||||
al_destroy_bitmap(data->bg);
|
||||
al_destroy_bitmap(data->earth);
|
||||
al_destroy_bitmap(data->clouds);
|
||||
al_destroy_bitmap(data->pixelator);
|
||||
al_destroy_sample_instance(data->rocket_sound);
|
||||
al_destroy_sample_instance(data->boom_sound);
|
||||
al_destroy_sample(data->rocket_sample);
|
||||
al_destroy_sample(data->boom_sample);
|
||||
// TODO: DestroyCharacters
|
||||
free(data);
|
||||
}
|
||||
|
||||
void Gamestate_Reload(struct Game *game, struct RocketsResources* data) {}
|
||||
|
||||
void Gamestate_Resume(struct Game *game, struct RocketsResources* data) {
|
||||
TM_Resume(data->timeline);
|
||||
}
|
||||
void Gamestate_Pause(struct Game *game, struct RocketsResources* data) {
|
||||
TM_Pause(data->timeline);
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
/*! \file dosowisko.h
|
||||
* \brief Init animation with dosowisko.net logo.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
struct RocketsResources {
|
||||
ALLEGRO_FONT *font;
|
||||
ALLEGRO_BITMAP *bg, *earth, *earth2, *pixelator, *clouds;
|
||||
struct Character *rocket_template, *usa_flag, *ru_flag, *cursor, *rainbow, *riot, *euro;
|
||||
|
||||
struct Rocket {
|
||||
struct Character *character;
|
||||
float dx, dy, modifier;
|
||||
bool blown, bumped;
|
||||
struct Rocket *next, *prev;
|
||||
} *rockets_left, *rockets_right;
|
||||
|
||||
int counter, hearts;
|
||||
float cloud_rotation;
|
||||
|
||||
struct {
|
||||
bool top, right, left, bottom;
|
||||
} mousemove;
|
||||
|
||||
ALLEGRO_SAMPLE *rocket_sample, *boom_sample, *rainbow_sample, *jump_sample, *wuwu_sample, *riot_sample;
|
||||
ALLEGRO_SAMPLE_INSTANCE *rocket_sound, *boom_sound, *rainbow_sound, *jump_sound, *wuwu_sound, *riot_sound;
|
||||
|
||||
bool lost, won;
|
||||
|
||||
int flash, zadyma;
|
||||
|
||||
int timelimit, spawnspeed, currentspawn, spawncounter;
|
||||
|
||||
struct Timeline *timeline;
|
||||
};
|
|
@ -1,588 +0,0 @@
|
|||
/*! \file dosowisko.c
|
||||
* \brief Init animation with dosowisko.net logo.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <allegro5/allegro_ttf.h>
|
||||
#include <allegro5/allegro_primitives.h>
|
||||
#include <math.h>
|
||||
#include "../utils.h"
|
||||
#include "../timeline.h"
|
||||
#include "rockets.h"
|
||||
|
||||
int Gamestate_ProgressCount = 9;
|
||||
|
||||
struct Rocket* CreateRocket(struct Game *game, struct RocketsResources* data, struct Rocket* rockets, bool right) {
|
||||
struct Rocket *n = malloc(sizeof(struct Rocket));
|
||||
n->next = NULL;
|
||||
n->prev = NULL;
|
||||
n->dx = (right ? -1.5 : 1.5) + (rand() / (float)RAND_MAX) * 0.6 - 0.3;
|
||||
n->dy = -2.1 + (rand() / (float)RAND_MAX) * 0.5 - 0.25;
|
||||
n->modifier = 0.025;
|
||||
n->blown = false;
|
||||
n->character = CreateCharacter(game, "rocket");
|
||||
n->character->spritesheets = data->rocket_template->spritesheets;
|
||||
n->character->shared = true;
|
||||
SelectSpritesheet(game, n->character, right ? "usa" : "ru");
|
||||
SetCharacterPosition(game, n->character, right ? 270 : 48, right ? 136 : 122, right ? -0.33 : 0.33);
|
||||
al_play_sample_instance(data->jump_sound);
|
||||
|
||||
data->currentspawn = data->spawnspeed + (data->spawnspeed * 0.1) * (float)(rand() / (float)RAND_MAX * 2) - (data->spawnspeed * 0.05);
|
||||
|
||||
if (rockets) {
|
||||
struct Rocket *tmp = rockets;
|
||||
while (tmp->next) {
|
||||
tmp=tmp->next;
|
||||
}
|
||||
tmp->next = n;
|
||||
n->prev = tmp;
|
||||
return rockets;
|
||||
} else {
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
bool CheckCollision(struct Game *game, struct RocketsResources* data, struct Character* character1, struct Character* character2) {
|
||||
|
||||
bool check(int x, int y, int w, int h, int x2, int y2, int w2, int h2) {
|
||||
|
||||
// HACK LOL I DON'T EVEN
|
||||
w /= character2->spritesheet->cols;
|
||||
h /= character2->spritesheet->cols;
|
||||
w2 /= character1->spritesheet->cols;
|
||||
h2 /= character1->spritesheet->cols;
|
||||
|
||||
//if ((((x>=derpyx+0.38*derpyw+derpyo) && (x<=derpyx+0.94*derpyw+derpyo)) || ((x+w>=derpyx+0.38*derpyw+derpyo) && (x+w<=derpyx+0.94*derpyw+derpyo)) || ((x<=derpyx+0.38*derpyw+derpyo) && (x+w>=derpyx+0.94*derpyw+derpyo))) &&
|
||||
// (((y>=derpyy+0.26*derpyh) && (y<=derpyy+0.76*derpyh)) || ((y+h>=derpyy+0.26*derpyh) && (y+h<=derpyy+0.76*derpyh)) || ((y<=derpyy+0.26*derpyh) && (y+h>=derpyy+0.76*derpyh)))) {
|
||||
al_draw_rectangle(x, y, x+w, y+h, al_map_rgb(255, 255, 255), 1);
|
||||
al_draw_rectangle(x2, y2, x2+w2, y2+h2, al_map_rgb(255, 255, 255), 1);
|
||||
if ((((x>=x2) && (x<=x2+w2)) || ((x+w>=x2) && (x+w<=x2+w2))) && (((y>=y2) && (y<=y2+h2)) || ((y+h>=y2) && (y+h<=y2+h2)))) {
|
||||
al_draw_rectangle(x, y, x+w, y+h, al_map_rgb(255, 0, 0), 1);
|
||||
al_draw_rectangle(x2, y2, x2+w2, y2+h2, al_map_rgb(0, 255, 0), 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool pointInside(int x, int y, int w, int h) {
|
||||
|
||||
bool value = false;
|
||||
|
||||
if ((character2->angle <= 1.0 && character2->angle >= 0.0) || (character2->angle < -2.0 && character2->angle > -2.6)) {
|
||||
value = value || check(character2->x + 8, character2->y + 15, al_get_bitmap_width(character2->bitmap) - 16, al_get_bitmap_height(character2->bitmap) - 9, x, y, w, h);
|
||||
value = value || check(character2->x + 15, character2->y + 7, al_get_bitmap_width(character2->bitmap) - 9, al_get_bitmap_height(character2->bitmap) - 15, x, y, w, h);
|
||||
} else if ((character2->angle >= -1.0 && character2->angle <= 0.0) || (character2->angle > 2.0 && character2->angle < 2.6)) {
|
||||
value = value || check(character2->x + 14, character2->y + 15, al_get_bitmap_width(character2->bitmap) - 9,al_get_bitmap_height(character2->bitmap) - 10, x, y, w, h);
|
||||
value = value || check(character2->x + 7, character2->y + 7, al_get_bitmap_width(character2->bitmap) - 16, al_get_bitmap_height(character2->bitmap) - 16, x, y, w, h);
|
||||
} else if ((character2->angle > 1.0 && character2->angle < 2.0) || (character2->angle < -1.0 && character2->angle > -2.0)) {
|
||||
value = value || check(character2->x + 6, character2->y + 12, al_get_bitmap_width(character2->bitmap) + 10, al_get_bitmap_height(character2->bitmap) - 18, x, y, w, h);
|
||||
} else {
|
||||
value = value || check(character2->x + 13, character2->y + 5, al_get_bitmap_width(character2->bitmap) - 18,al_get_bitmap_height(character2->bitmap) + 8, x, y, w, h);
|
||||
}
|
||||
|
||||
return value;
|
||||
|
||||
}
|
||||
|
||||
bool value = false;
|
||||
|
||||
if (character1 == data->cursor) {
|
||||
return pointInside(character1->x, character1->y, al_get_bitmap_width(character1->bitmap), al_get_bitmap_height(character1->bitmap));
|
||||
}
|
||||
|
||||
if ((character1->angle <= 1.0 && character1->angle >= 0.0) || (character1->angle < -2.0 && character1->angle > -2.6)) {
|
||||
value = value || pointInside(character1->x + 8, character1->y + 15, al_get_bitmap_width(character1->bitmap) - 16, al_get_bitmap_height(character1->bitmap) - 9);
|
||||
value = value || pointInside(character1->x + 15, character1->y + 7, al_get_bitmap_width(character1->bitmap) - 9, al_get_bitmap_height(character1->bitmap) - 15);
|
||||
} else if ((character1->angle >= -1.0 && character1->angle <= 0.0) || (character1->angle > 2.0 && character1->angle < 2.6)) {
|
||||
value = value || pointInside(character1->x + 14, character1->y + 15, al_get_bitmap_width(character1->bitmap) - 9, al_get_bitmap_height(character1->bitmap) - 10);
|
||||
value = value || pointInside(character1->x + 7, character1->y + 7,al_get_bitmap_width(character1->bitmap) - 16,al_get_bitmap_height(character1->bitmap) - 16);
|
||||
} else if ((character1->angle > 1.0 && character1->angle < 2.0) || (character1->angle < -1.0 && character1->angle > -2.0)) {
|
||||
value = value || pointInside(character1->x + 6, character1->y + 12, al_get_bitmap_width(character1->bitmap) + 10,al_get_bitmap_height(character1->bitmap) - 18);
|
||||
} else {
|
||||
value = value || pointInside(character1->x + 13, character1->y + 5, al_get_bitmap_width(character1->bitmap) - 18,al_get_bitmap_height(character1->bitmap) + 8);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void DrawRockets(struct Game *game, struct RocketsResources* data, struct Rocket* rockets) {
|
||||
struct Rocket *tmp = rockets;
|
||||
while (tmp) {
|
||||
DrawCharacter(game, tmp->character, al_map_rgb(255,255,255), 0);
|
||||
|
||||
tmp=tmp->next;
|
||||
}
|
||||
}
|
||||
|
||||
bool switchMinigame(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||
if (state == TM_ACTIONSTATE_START) {
|
||||
StopGamestate(game, "rockets");
|
||||
game->mediator.next = "lollipop";
|
||||
StartGamestate(game, GetAbstractIsItBonusLevelTimeNowFactoryProvider(game) ? "bonus" : "lollipop");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool theEnd(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||
if (state == TM_ACTIONSTATE_START) {
|
||||
StopGamestate(game, "rockets");
|
||||
StartGamestate(game, "theend");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void UpdateRockets(struct Game *game, struct RocketsResources *data, struct Rocket* rockets) {
|
||||
struct Rocket *tmp = rockets;
|
||||
while (tmp) {
|
||||
tmp->dy+= tmp->modifier;
|
||||
if (!tmp->blown) {
|
||||
tmp->dx+= (tmp->dx > 0) ? (-tmp->modifier / 5 + 0.001) : (tmp->modifier / 5 - 0.001);
|
||||
}
|
||||
MoveCharacter(game, tmp->character, tmp->dx, tmp->dy, tmp->blown ? 0 : ((tmp->dx > 0) ? 0.0166 : -0.0166));
|
||||
AnimateCharacter(game, tmp->character, 1);
|
||||
|
||||
if (!tmp->blown) {
|
||||
|
||||
bool dupy = false; // nice sos, sos
|
||||
|
||||
void iterate(struct Rocket *start) {
|
||||
struct Rocket *tmp1 = start;
|
||||
while (tmp1) {
|
||||
if ((tmp != tmp1) && (!tmp1->blown)) {
|
||||
if (CheckCollision(game, data, tmp->character, tmp1->character)) {
|
||||
dupy = true;
|
||||
|
||||
tmp1->blown = true;
|
||||
tmp1->modifier = 0;
|
||||
tmp1->character->angle = 0;
|
||||
tmp1->dx = 0;
|
||||
tmp1->dy = 0;
|
||||
SelectSpritesheet(game, tmp1->character, "boom");
|
||||
MoveCharacter(game, tmp1->character, 5, 5, 0);
|
||||
//DrawCharacter(game, tmp->character, al_map_rgb(255,0,0), 0);
|
||||
al_play_sample_instance(data->boom_sound);
|
||||
}
|
||||
|
||||
}
|
||||
tmp1 = tmp1->next;
|
||||
}
|
||||
|
||||
}
|
||||
iterate(data->rockets_left);
|
||||
iterate(data->rockets_right);
|
||||
|
||||
|
||||
if (((((tmp->character->y > 120) && (rand() % 4 == 0) && (tmp->dy > 0)) || (dupy))) && (tmp->character->x > -20 && tmp->character->x < 310)) {
|
||||
tmp->blown = true;
|
||||
tmp->modifier = 0;
|
||||
tmp->character->angle = 0;
|
||||
tmp->dx = 0;
|
||||
tmp->dy = 0;
|
||||
SelectSpritesheet(game, tmp->character, "boom");
|
||||
MoveCharacter(game, tmp->character, 5, 5, 0);
|
||||
|
||||
if (!dupy) {
|
||||
if (!data->lost) {
|
||||
AdvanceLevel(game, false);
|
||||
}
|
||||
data->lost = true;
|
||||
data->flash = 4;
|
||||
TM_AddDelay(data->timeline, 3500);
|
||||
if (game->mediator.lives > 0) {
|
||||
TM_AddAction(data->timeline, switchMinigame, NULL, "switchMinigame");
|
||||
} else {
|
||||
|
||||
TM_AddAction(data->timeline, theEnd, NULL, "switchMinigame");
|
||||
}
|
||||
data->spawnspeed = 10;
|
||||
al_play_sample_instance(data->atom_sound);
|
||||
SelectSpritesheet(game, data->usa_flag, "brokenusa");
|
||||
SelectSpritesheet(game, data->ru_flag, "brokenru");
|
||||
}
|
||||
if (!dupy) {
|
||||
SelectSpritesheet(game, tmp->character, "atom");
|
||||
MoveCharacter(game, tmp->character, 0, -11, 0);
|
||||
tmp->character->angle = ((tmp->character->x - 160) / 160) * 0.8;
|
||||
}
|
||||
} else if (tmp->character->x <= -20 || tmp->character->x >= 310) {
|
||||
tmp->blown = true;
|
||||
tmp->modifier = 0;
|
||||
tmp->character->angle = 0;
|
||||
tmp->dx = 0;
|
||||
tmp->dy = 0;
|
||||
SelectSpritesheet(game, tmp->character, "blank");
|
||||
}
|
||||
}
|
||||
tmp=tmp->next;
|
||||
}
|
||||
}
|
||||
|
||||
void Gamestate_Logic(struct Game *game, struct RocketsResources* data) {
|
||||
|
||||
if ((data->spawncounter == data->currentspawn) && ((data->counter < data->timelimit) || (data->lost))) {
|
||||
data->next = !data->next;
|
||||
if (data->next) {
|
||||
data->rockets_left = CreateRocket(game, data, data->rockets_left, false);
|
||||
} else {
|
||||
data->rockets_right = CreateRocket(game, data, data->rockets_right, true);
|
||||
}
|
||||
data->spawncounter = 0;
|
||||
}
|
||||
|
||||
if (!data->flash) {
|
||||
UpdateRockets(game, data, data->rockets_left);
|
||||
UpdateRockets(game, data, data->rockets_right);
|
||||
} else {
|
||||
data->flash--;
|
||||
}
|
||||
|
||||
|
||||
if (data->lost) {
|
||||
data->hearts++;
|
||||
}
|
||||
|
||||
AnimateCharacter(game, data->usa_flag, 1);
|
||||
AnimateCharacter(game, data->ru_flag, 1);
|
||||
if ((data->lost) && (data->hearts > 80)) {
|
||||
AnimateCharacter(game, game->mediator.heart, 1);
|
||||
if (game->mediator.heart->pos == 6) {
|
||||
al_play_sample_instance(data->boom_sound);
|
||||
}
|
||||
}
|
||||
|
||||
if (data->won) {
|
||||
AnimateCharacter(game, data->rainbow, 1);
|
||||
}
|
||||
|
||||
if ((data->counter >= data->timelimit) && (!data->lost) && (!data->won)) {
|
||||
bool stillthere = false;
|
||||
struct Rocket *tmp = data->rockets_left;
|
||||
while (tmp) {
|
||||
if (!tmp->blown) {
|
||||
stillthere = true;
|
||||
break;
|
||||
}
|
||||
tmp = tmp->next;
|
||||
}
|
||||
tmp = data->rockets_right;
|
||||
while (tmp) {
|
||||
if (!tmp->blown) {
|
||||
stillthere = true;
|
||||
break;
|
||||
}
|
||||
tmp = tmp->next;
|
||||
}
|
||||
if (!stillthere) {
|
||||
SelectSpritesheet(game, data->rainbow, "shine");
|
||||
SetCharacterPosition(game, data->rainbow, 89, 42, 0);
|
||||
al_play_sample_instance(data->rainbow_sound);
|
||||
data->won = true;
|
||||
AdvanceLevel(game, true);
|
||||
TM_AddDelay(data->timeline, 2500);
|
||||
TM_AddAction(data->timeline, switchMinigame, NULL, "switchMinigame");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void iterate(struct Rocket *start) {
|
||||
struct Rocket *tmp1 = start;
|
||||
while (tmp1) {
|
||||
if (!tmp1->blown) {
|
||||
if (CheckCollision(game, data, data->cursor, tmp1->character)) {
|
||||
|
||||
if (!tmp1->bumped) {
|
||||
tmp1->bumped = true;
|
||||
al_play_sample_instance(data->rocket_sound);
|
||||
if (data->mousemove.top || data->mousemove.bottom) {
|
||||
tmp1->dy = (data->mousemove.bottom * 2) - 1;
|
||||
}
|
||||
tmp1->dx += (data->mousemove.left * -0.3) + (data->mousemove.right * 0.3);
|
||||
tmp1->character->angle += (tmp1->character->angle < 0) ? 0.25 : -0.25;
|
||||
|
||||
//PrintConsole(game, "collision TOP %d rIGHT %d", data->mousemove.top, data->mousemove.right);
|
||||
|
||||
int movex = 0, movey = 0;
|
||||
|
||||
if (data->mousemove.right) {
|
||||
movex = -3;
|
||||
}
|
||||
if (data->mousemove.left) {
|
||||
movex = 3;
|
||||
}
|
||||
if (data->mousemove.top) {
|
||||
movey = 3;
|
||||
}
|
||||
if (data->mousemove.bottom) {
|
||||
movey =-3;
|
||||
}
|
||||
|
||||
MoveCharacter(game, data->cursor, movex, movey, 0);
|
||||
al_set_mouse_xy(game->display, data->cursor->x * (al_get_display_width(game->display) / 320), data->cursor->y * (al_get_display_height(game->display) / 180));
|
||||
|
||||
data->mousemove.top = false;
|
||||
data->mousemove.bottom = false;
|
||||
data->mousemove.left = false;
|
||||
data->mousemove.right = false;
|
||||
|
||||
}
|
||||
} else {
|
||||
tmp1->bumped = false;
|
||||
}
|
||||
|
||||
}
|
||||
tmp1 = tmp1->next;
|
||||
}
|
||||
|
||||
}
|
||||
iterate(data->rockets_left);
|
||||
iterate(data->rockets_right);
|
||||
|
||||
data->counter++;
|
||||
data->spawncounter++;
|
||||
data->cloud_rotation += 0.002;
|
||||
|
||||
TM_Process(data->timeline);
|
||||
}
|
||||
|
||||
void Gamestate_Draw(struct Game *game, struct RocketsResources* data) {
|
||||
|
||||
al_set_target_bitmap(data->combined);
|
||||
al_clear_to_color(al_map_rgba(0,0,0,0));
|
||||
al_draw_bitmap(data->earth, 0, 0, 0);
|
||||
//al_draw_bitmap(data->clouds, -140, -210, 0);
|
||||
//al_set_separate_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA, ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_ZERO);
|
||||
al_set_blender(ALLEGRO_ADD, ALLEGRO_ZERO, ALLEGRO_INVERSE_ALPHA);
|
||||
al_draw_rotated_bitmap(data->clouds, 250, 250, -90 + 250, -160 + 250 + 20, data->cloud_rotation, 0);
|
||||
al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA);
|
||||
|
||||
al_set_target_bitmap(data->pixelator);
|
||||
|
||||
if (!data->lost) {
|
||||
al_draw_bitmap(data->bg, 0, 0, 0);
|
||||
al_draw_bitmap(data->earth2, 0, 0, 0);
|
||||
al_draw_bitmap(data->combined, 0, 0, 0);
|
||||
} else {
|
||||
al_draw_tinted_bitmap(data->bg, al_map_rgb(255, 192, 128), 0, 0, 0);
|
||||
//al_draw_tinted_bitmap(data->earth2, al_map_rgb(255, 192, 128), 0, 0, 0);
|
||||
al_draw_tinted_bitmap(data->combined, al_map_rgb(255, 192, 128), 0, 0, 0);
|
||||
}
|
||||
|
||||
if (data->won) {
|
||||
DrawCharacter(game, data->rainbow, al_map_rgb(255,255,255), 0);
|
||||
}
|
||||
|
||||
DrawCharacter(game, data->usa_flag, al_map_rgb(255,255,255), 0);
|
||||
DrawCharacter(game, data->ru_flag, al_map_rgb(255,255,255), 0);
|
||||
|
||||
if ((!data->lost) && (!data->won)) {
|
||||
DrawCharacter(game, data->cursor, al_map_rgb(255,255,255), 0);
|
||||
}
|
||||
|
||||
DrawRockets(game, data, data->rockets_left);
|
||||
DrawRockets(game, data, data->rockets_right);
|
||||
|
||||
if ((!data->lost) && (!data->won)) {
|
||||
al_draw_filled_rectangle(78, 5, 78+164, 5+5, al_map_rgb(155, 142, 142));
|
||||
al_draw_filled_rectangle(80, 6, 80+160, 6+3, al_map_rgb(66, 55, 30));
|
||||
al_draw_filled_rectangle(80, 6, (data->counter < data->timelimit) ? (80+160 * (1 - (data->counter / (float)data->timelimit))) : 80, 6+3, al_map_rgb(225,182, 80));
|
||||
}
|
||||
|
||||
if (data->flash) {
|
||||
al_draw_filled_rectangle(0, 0, 320, 180, al_map_rgb(255, 255, 255));
|
||||
}
|
||||
|
||||
al_set_target_backbuffer(game->display);
|
||||
al_draw_bitmap(data->pixelator, 0, 0, 0);
|
||||
|
||||
if ((data->lost) && (data->hearts > 80)) {
|
||||
ShowLevelStatistics(game);
|
||||
}
|
||||
|
||||
//Gamestate_Logic(game, data);
|
||||
|
||||
}
|
||||
|
||||
void Gamestate_Start(struct Game *game, struct RocketsResources* data) {
|
||||
data->rockets_left = NULL;
|
||||
data->rockets_right = NULL;
|
||||
|
||||
data->timelimit = 480 * game->mediator.modificator;
|
||||
data->spawnspeed = 60 / game->mediator.modificator;
|
||||
data->currentspawn = data->spawnspeed;
|
||||
data->spawncounter = data->spawnspeed - 20;
|
||||
|
||||
data->lost = false;
|
||||
data->won = false;
|
||||
data->hearts = 0;
|
||||
|
||||
data->flash = 0;
|
||||
|
||||
data->next = rand() % 2;
|
||||
|
||||
SetCharacterPosition(game, data->usa_flag, 266, 105, 0);
|
||||
SetCharacterPosition(game, data->ru_flag, 13, 103, 0);
|
||||
|
||||
SetCharacterPosition(game, data->cursor, 320 / 2, 180 / 2, 0);
|
||||
|
||||
SelectSpritesheet(game, data->usa_flag, "usa");
|
||||
SelectSpritesheet(game, data->ru_flag, "ru");
|
||||
|
||||
SelectSpritesheet(game, data->cursor, "be");
|
||||
|
||||
data->counter = 0;
|
||||
data->cloud_rotation = 0;
|
||||
|
||||
al_set_mouse_xy(game->display, al_get_display_width(game->display) / 2, al_get_display_height(game->display) / 2);
|
||||
|
||||
data->mousemove.bottom = false;
|
||||
data->mousemove.top = false;
|
||||
data->mousemove.left = false;
|
||||
data->mousemove.right = false;
|
||||
}
|
||||
|
||||
void Gamestate_ProcessEvent(struct Game *game, struct RocketsResources* data, ALLEGRO_EVENT *ev) {
|
||||
TM_HandleEvent(data->timeline, ev);
|
||||
if ((ev->type==ALLEGRO_EVENT_KEY_DOWN) && (ev->keyboard.keycode == ALLEGRO_KEY_ESCAPE)) {
|
||||
SwitchGamestate(game, "rockets", "theend");
|
||||
} else if (ev->type == ALLEGRO_EVENT_MOUSE_AXES) {
|
||||
int mousex = ev->mouse.x / (al_get_display_width(game->display) / 320);
|
||||
int mousey = ev->mouse.y / (al_get_display_height(game->display) / 180);
|
||||
data->mousemove.right = mousex > data->cursor->x;
|
||||
data->mousemove.top = mousey < data->cursor->y;
|
||||
data->mousemove.left = mousex < data->cursor->x;
|
||||
data->mousemove.bottom = mousey > data->cursor->y;
|
||||
SetCharacterPosition(game, data->cursor, mousex, mousey , 0); // FIXMEEEE!
|
||||
}
|
||||
}
|
||||
|
||||
void* Gamestate_Load(struct Game *game, void (*progress)(struct Game*)) {
|
||||
struct RocketsResources *data = malloc(sizeof(struct RocketsResources));
|
||||
|
||||
data->timeline = TM_Init(game, "rockets");
|
||||
|
||||
data->bg = al_load_bitmap( GetDataFilePath(game, "rockets/bg.png"));
|
||||
|
||||
data->earth = al_load_bitmap( GetDataFilePath(game, "rockets/earth.png"));
|
||||
data->earth2 = al_load_bitmap( GetDataFilePath(game, "rockets/earth2.png"));
|
||||
|
||||
data->clouds = al_load_bitmap( GetDataFilePath(game, "rockets/clouds.png"));
|
||||
(*progress)(game);
|
||||
|
||||
data->rocket_sample = al_load_sample( GetDataFilePath(game, "bump.flac") );
|
||||
(*progress)(game);
|
||||
data->boom_sample = al_load_sample( GetDataFilePath(game, "boom.flac") );
|
||||
(*progress)(game);
|
||||
data->atom_sample = al_load_sample( GetDataFilePath(game, "rockets/atom.flac") );
|
||||
(*progress)(game);
|
||||
data->jump_sample = al_load_sample( GetDataFilePath(game, "launch.flac") );
|
||||
(*progress)(game);
|
||||
data->rainbow_sample = al_load_sample( GetDataFilePath(game, "win.flac") );
|
||||
(*progress)(game);
|
||||
|
||||
data->rocket_sound = al_create_sample_instance(data->rocket_sample);
|
||||
al_attach_sample_instance_to_mixer(data->rocket_sound, game->audio.fx);
|
||||
al_set_sample_instance_playmode(data->rocket_sound, ALLEGRO_PLAYMODE_ONCE);
|
||||
|
||||
data->atom_sound = al_create_sample_instance(data->atom_sample);
|
||||
al_attach_sample_instance_to_mixer(data->atom_sound, game->audio.fx);
|
||||
al_set_sample_instance_playmode(data->atom_sound, ALLEGRO_PLAYMODE_ONCE);
|
||||
|
||||
data->boom_sound = al_create_sample_instance(data->boom_sample);
|
||||
al_attach_sample_instance_to_mixer(data->boom_sound, game->audio.fx);
|
||||
al_set_sample_instance_playmode(data->boom_sound, ALLEGRO_PLAYMODE_ONCE);
|
||||
|
||||
data->jump_sound = al_create_sample_instance(data->jump_sample);
|
||||
al_attach_sample_instance_to_mixer(data->jump_sound, game->audio.fx);
|
||||
al_set_sample_instance_playmode(data->jump_sound, ALLEGRO_PLAYMODE_ONCE);
|
||||
|
||||
data->rainbow_sound = al_create_sample_instance(data->rainbow_sample);
|
||||
al_attach_sample_instance_to_mixer(data->rainbow_sound, game->audio.fx);
|
||||
al_set_sample_instance_playmode(data->rainbow_sound, ALLEGRO_PLAYMODE_ONCE);
|
||||
|
||||
data->cursor = CreateCharacter(game, "cursor");
|
||||
RegisterSpritesheet(game, data->cursor, "be");
|
||||
LoadSpritesheets(game, data->cursor);
|
||||
(*progress)(game);
|
||||
|
||||
data->pixelator = al_create_bitmap(320, 180);
|
||||
al_set_target_bitmap(data->pixelator);
|
||||
al_clear_to_color(al_map_rgb(0, 0, 0));
|
||||
|
||||
data->combined = al_create_bitmap(320, 180);
|
||||
al_set_target_bitmap(data->combined);
|
||||
al_clear_to_color(al_map_rgba(0, 0, 0, 0));
|
||||
|
||||
al_set_target_backbuffer(game->display);
|
||||
|
||||
data->rocket_template = CreateCharacter(game, "rocket");
|
||||
RegisterSpritesheet(game, data->rocket_template, "usa");
|
||||
RegisterSpritesheet(game, data->rocket_template, "ru");
|
||||
RegisterSpritesheet(game, data->rocket_template, "atom");
|
||||
RegisterSpritesheet(game, data->rocket_template, "boom");
|
||||
RegisterSpritesheet(game, data->rocket_template, "blank");
|
||||
LoadSpritesheets(game, data->rocket_template);
|
||||
(*progress)(game);
|
||||
|
||||
data->usa_flag = CreateCharacter(game, "flag");
|
||||
RegisterSpritesheet(game, data->usa_flag, "usa");
|
||||
RegisterSpritesheet(game, data->usa_flag, "brokenusa");
|
||||
LoadSpritesheets(game, data->usa_flag);
|
||||
|
||||
data->ru_flag = CreateCharacter(game, "flag");
|
||||
RegisterSpritesheet(game, data->ru_flag, "ru");
|
||||
RegisterSpritesheet(game, data->ru_flag, "brokenru");
|
||||
LoadSpritesheets(game, data->ru_flag);
|
||||
(*progress)(game);
|
||||
|
||||
data->rainbow = CreateCharacter(game, "rainbow");
|
||||
RegisterSpritesheet(game, data->rainbow, "shine");
|
||||
RegisterSpritesheet(game, data->rainbow, "be");
|
||||
LoadSpritesheets(game, data->rainbow);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void Gamestate_Stop(struct Game *game, struct RocketsResources* data) {
|
||||
TM_CleanQueue(data->timeline);
|
||||
}
|
||||
|
||||
void Gamestate_Unload(struct Game *game, struct RocketsResources* data) {
|
||||
al_destroy_bitmap(data->bg);
|
||||
al_destroy_bitmap(data->earth);
|
||||
al_destroy_bitmap(data->earth2);
|
||||
al_destroy_bitmap(data->clouds);
|
||||
al_destroy_bitmap(data->combined);
|
||||
al_destroy_bitmap(data->pixelator);
|
||||
al_destroy_sample_instance(data->rocket_sound);
|
||||
al_destroy_sample_instance(data->boom_sound);
|
||||
al_destroy_sample(data->rocket_sample);
|
||||
al_destroy_sample(data->boom_sample);
|
||||
// TODO: DestroyCharacters
|
||||
free(data);
|
||||
}
|
||||
|
||||
void Gamestate_Reload(struct Game *game, struct RocketsResources* data) {}
|
||||
|
||||
void Gamestate_Resume(struct Game *game, struct RocketsResources* data) {
|
||||
TM_Resume(data->timeline);
|
||||
}
|
||||
void Gamestate_Pause(struct Game *game, struct RocketsResources* data) {
|
||||
TM_Pause(data->timeline);
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
/*! \file dosowisko.h
|
||||
* \brief Init animation with dosowisko.net logo.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
struct RocketsResources {
|
||||
ALLEGRO_FONT *font;
|
||||
ALLEGRO_BITMAP *bg, *earth, *earth2, *pixelator, *combined, *clouds;
|
||||
struct Character *rocket_template, *usa_flag, *ru_flag, *cursor, *rainbow;
|
||||
|
||||
struct Rocket {
|
||||
struct Character *character;
|
||||
float dx, dy, modifier;
|
||||
bool blown, bumped;
|
||||
struct Rocket *next, *prev;
|
||||
} *rockets_left, *rockets_right;
|
||||
|
||||
int counter, hearts;
|
||||
float cloud_rotation;
|
||||
|
||||
struct {
|
||||
bool top, right, left, bottom;
|
||||
} mousemove;
|
||||
|
||||
ALLEGRO_SAMPLE *rocket_sample, *boom_sample, *rainbow_sample, *atom_sample, *jump_sample;
|
||||
ALLEGRO_SAMPLE_INSTANCE *rocket_sound, *boom_sound, *rainbow_sound, *atom_sound, *jump_sound;
|
||||
|
||||
bool lost, won;
|
||||
|
||||
int flash;
|
||||
|
||||
int timelimit, spawnspeed, currentspawn, spawncounter;
|
||||
|
||||
bool next;
|
||||
|
||||
struct Timeline *timeline;
|
||||
};
|
|
@ -1,113 +0,0 @@
|
|||
/*! \file dosowisko.c
|
||||
* \brief Init animation with dosowisko.net logo.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <allegro5/allegro_ttf.h>
|
||||
#include <allegro5/allegro_primitives.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "../utils.h"
|
||||
#include "../timeline.h"
|
||||
#include "../config.h"
|
||||
#include "theend.h"
|
||||
|
||||
int Gamestate_ProgressCount = 1;
|
||||
|
||||
void Gamestate_Logic(struct Game *game, struct dosowiskoResources* data) {
|
||||
|
||||
}
|
||||
|
||||
void Gamestate_Draw(struct Game *game, struct dosowiskoResources* data) {
|
||||
al_draw_bitmap(data->bitmap, 0, 0, 0);
|
||||
char text[255];
|
||||
snprintf(text, 255, "%d", game->mediator.score);
|
||||
DrawTextWithShadow(game->_priv.font, al_map_rgb(255,255,255), 320/2, 20, ALLEGRO_ALIGN_CENTER, "Score:");
|
||||
DrawTextWithShadow(data->font, al_map_rgb(255,255,255), 320/2, 30, ALLEGRO_ALIGN_CENTER, text);
|
||||
snprintf(text, 255, "High score: %d", data->score);
|
||||
if (game->mediator.score == data->score) {
|
||||
DrawTextWithShadow(game->_priv.font, al_map_rgb(255,222, 120), 320/2, 140, ALLEGRO_ALIGN_CENTER, text);
|
||||
} else {
|
||||
DrawTextWithShadow(game->_priv.font, al_map_rgb(255,255,255), 320/2, 140, ALLEGRO_ALIGN_CENTER, text);
|
||||
}
|
||||
DrawTextWithShadow(game->_priv.font, al_map_rgb(255,255,255), 320/2, 162, ALLEGRO_ALIGN_CENTER, "Press RETURN");
|
||||
}
|
||||
|
||||
void Gamestate_Start(struct Game *game, struct dosowiskoResources* data) {
|
||||
al_set_sample_instance_gain(game->muzyczka.instance.drums, 0.0);
|
||||
al_set_sample_instance_gain(game->muzyczka.instance.fg, 0.0);
|
||||
al_set_sample_instance_gain(game->muzyczka.instance.bg, 1.5);
|
||||
|
||||
char *end = "";
|
||||
data->score = strtol(GetConfigOptionDefault(game, "Mediator", "score", "0"), &end, 10);
|
||||
|
||||
if (game->mediator.score > data->score) {
|
||||
char text[255];
|
||||
snprintf(text, 255, "%d", game->mediator.score);
|
||||
SetConfigOption(game, "Mediator", "score", text);
|
||||
data->score = game->mediator.score;
|
||||
}
|
||||
|
||||
al_ungrab_mouse();
|
||||
if (!game->config.fullscreen) al_show_mouse_cursor(game->display);
|
||||
|
||||
al_play_sample_instance(data->sound);
|
||||
|
||||
}
|
||||
|
||||
void Gamestate_ProcessEvent(struct Game *game, struct dosowiskoResources* data, ALLEGRO_EVENT *ev) {
|
||||
//TM_HandleEvent(data->timeline, ev);
|
||||
if ((ev->type==ALLEGRO_EVENT_KEY_DOWN) && (ev->keyboard.keycode == ALLEGRO_KEY_ESCAPE)) {
|
||||
SwitchGamestate(game, "theend", "menu");
|
||||
}
|
||||
if ((ev->type==ALLEGRO_EVENT_KEY_DOWN) && (ev->keyboard.keycode == ALLEGRO_KEY_ENTER)) {
|
||||
SwitchGamestate(game, "theend", "menu");
|
||||
}
|
||||
}
|
||||
|
||||
void* Gamestate_Load(struct Game *game, void (*progress)(struct Game*)) {
|
||||
struct dosowiskoResources *data = malloc(sizeof(struct dosowiskoResources));
|
||||
data->bitmap = al_load_bitmap( GetDataFilePath(game, "bg.png"));
|
||||
|
||||
data->font = al_load_ttf_font(GetDataFilePath(game, "fonts/MonkeyIsland.ttf"),100,0 );
|
||||
(*progress)(game);
|
||||
|
||||
data->sample = al_load_sample( GetDataFilePath(game, "end.flac") );
|
||||
|
||||
data->sound = al_create_sample_instance(data->sample);
|
||||
al_attach_sample_instance_to_mixer(data->sound, game->audio.fx);
|
||||
al_set_sample_instance_playmode(data->sound, ALLEGRO_PLAYMODE_ONCE);
|
||||
al_set_sample_instance_gain(data->sound, 1.5);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void Gamestate_Stop(struct Game *game, struct dosowiskoResources* data) {
|
||||
|
||||
}
|
||||
|
||||
void Gamestate_Unload(struct Game *game, struct dosowiskoResources* data) {
|
||||
free(data);
|
||||
}
|
||||
|
||||
void Gamestate_Reload(struct Game *game, struct dosowiskoResources* data) {}
|
||||
|
||||
void Gamestate_Resume(struct Game *game, struct dosowiskoResources* data) {}
|
||||
void Gamestate_Pause(struct Game *game, struct dosowiskoResources* data) {}
|
|
@ -1,28 +0,0 @@
|
|||
/*! \file dosowisko.h
|
||||
* \brief Init animation with dosowisko.net logo.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
struct dosowiskoResources {
|
||||
ALLEGRO_FONT *font;
|
||||
ALLEGRO_BITMAP *bitmap;
|
||||
ALLEGRO_SAMPLE *sample;
|
||||
ALLEGRO_SAMPLE_INSTANCE *sound;
|
||||
int score;
|
||||
};
|
|
@ -1,27 +0,0 @@
|
|||
add_library("libsuperderpy-muffinattack-levels" SHARED "actions.c" "../gamestates/level.c" "modules/moonwalk.c" "modules/dodger.c" "modules/dodger/actions.c" "modules/dodger/callbacks.c")
|
||||
|
||||
SET_TARGET_PROPERTIES("libsuperderpy-muffinattack-levels" PROPERTIES PREFIX "")
|
||||
|
||||
target_link_libraries("libsuperderpy-muffinattack-levels" ${ALLEGRO5_LIBRARIES} ${ALLEGRO5_FONT_LIBRARIES} ${ALLEGRO5_TTF_LIBRARIES} ${ALLEGRO5_PRIMITIVES_LIBRARIES} ${ALLEGRO5_AUDIO_LIBRARIES} ${ALLEGRO5_ACODEC_LIBRARIES} ${ALLEGRO5_IMAGE_LIBRARIES} m libsuperderpy)
|
||||
|
||||
install(TARGETS "libsuperderpy-muffinattack-levels" DESTINATION ${LIB_INSTALL_DIR})
|
||||
|
||||
|
||||
MACRO(GAMESTATE name)
|
||||
|
||||
add_library("libsuperderpy-muffinattack-${name}" SHARED "${name}.c")
|
||||
|
||||
SET_TARGET_PROPERTIES("libsuperderpy-muffinattack-${name}" PROPERTIES PREFIX "")
|
||||
|
||||
target_link_libraries("libsuperderpy-muffinattack-${name}" ${ALLEGRO5_LIBRARIES} ${ALLEGRO5_FONT_LIBRARIES} ${ALLEGRO5_TTF_LIBRARIES} ${ALLEGRO5_PRIMITIVES_LIBRARIES} ${ALLEGRO5_AUDIO_LIBRARIES} ${ALLEGRO5_ACODEC_LIBRARIES} ${ALLEGRO5_IMAGE_LIBRARIES} m libsuperderpy libsuperderpy-muffinattack-levels)
|
||||
|
||||
install(TARGETS "libsuperderpy-muffinattack-${name}" DESTINATION ${LIB_INSTALL_DIR})
|
||||
|
||||
ENDMACRO()
|
||||
|
||||
GAMESTATE("level1")
|
||||
GAMESTATE("level2")
|
||||
GAMESTATE("level3")
|
||||
GAMESTATE("level4")
|
||||
GAMESTATE("level5")
|
||||
GAMESTATE("level6")
|
|
@ -1,226 +0,0 @@
|
|||
/*! \file levels/actions.c
|
||||
* \brief Level actions for Timeline Manager.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <allegro5/allegro_primitives.h>
|
||||
#include "../utils.h"
|
||||
#include "../gamestate.h"
|
||||
#include "../gamestates/level.h"
|
||||
#include "actions.h"
|
||||
|
||||
bool LevelFailed(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||
if (state == TM_ACTIONSTATE_DRAW) {
|
||||
al_draw_filled_rectangle(0, 0, game->viewport.width, game->viewport.height, al_map_rgba(0,0,0,100));
|
||||
//FIXME: font
|
||||
//DrawTextWithShadow(game->menu.font_title, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.4, ALLEGRO_ALIGN_CENTRE, "Failed!");
|
||||
} else if (state == TM_ACTIONSTATE_RUNNING) {
|
||||
// FIXME: this should be more generic. Some callback function?
|
||||
// FIXME: data
|
||||
//game->level.speed-=0.00001;
|
||||
//if (game->level.speed<=0) {
|
||||
return true;
|
||||
//}
|
||||
} else if (state == TM_ACTIONSTATE_DESTROY) {
|
||||
SwitchGamestate(game, "level", "map");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ShowMeter(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||
if (state != TM_ACTIONSTATE_RUNNING) return false;
|
||||
//FIXME: data
|
||||
//game->level.meter_alpha+=4;
|
||||
//if (game->level.meter_alpha>=255) {
|
||||
// game->level.meter_alpha=255;
|
||||
return true;
|
||||
//}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Stop(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||
if (state != TM_ACTIONSTATE_RUNNING) return false;
|
||||
//FIXME: data
|
||||
//game->level.speed=0;
|
||||
//SelectDerpySpritesheet(game, "stand");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FadeIn(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||
if (!action->arguments) {
|
||||
action->arguments = TM_AddToArgs(action->arguments, 2, malloc(sizeof(float)), (void*)al_create_bitmap(game->viewport.width, game->viewport.height));
|
||||
}
|
||||
float* fadeloop;
|
||||
ALLEGRO_BITMAP* fade_bitmap;
|
||||
fadeloop = (float*)action->arguments->value;
|
||||
fade_bitmap = (ALLEGRO_BITMAP*)action->arguments->next->value;
|
||||
if (state == TM_ACTIONSTATE_INIT) {
|
||||
*fadeloop = 255;
|
||||
al_set_target_bitmap(fade_bitmap);
|
||||
al_clear_to_color(al_map_rgb(0,0,0));
|
||||
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||
} else if (state == TM_ACTIONSTATE_RUNNING) {
|
||||
*fadeloop-=10;
|
||||
if (*fadeloop<=0) return true;
|
||||
} else if (state == TM_ACTIONSTATE_DRAW) {
|
||||
al_draw_tinted_bitmap(fade_bitmap,al_map_rgba_f(1,1,1,*fadeloop/255.0),0,0,0);
|
||||
} else if (state == TM_ACTIONSTATE_DESTROY) {
|
||||
al_destroy_bitmap(fade_bitmap);
|
||||
free(fadeloop);
|
||||
TM_DestroyArgs(action->arguments);
|
||||
action->arguments = NULL;
|
||||
//FIXME: data
|
||||
//al_play_sample_instance(game->level.music);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FadeOut(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||
if (!action->arguments) {
|
||||
action->arguments = TM_AddToArgs(action->arguments, 2, malloc(sizeof(float)), (void*)al_create_bitmap(game->viewport.width, game->viewport.height));
|
||||
}
|
||||
float* fadeloop;
|
||||
ALLEGRO_BITMAP* fade_bitmap;
|
||||
fadeloop = (float*)action->arguments->value;
|
||||
fade_bitmap = (ALLEGRO_BITMAP*)action->arguments->next->value;
|
||||
if (state == TM_ACTIONSTATE_INIT) {
|
||||
*fadeloop = 0;
|
||||
al_set_target_bitmap(fade_bitmap);
|
||||
al_clear_to_color(al_map_rgb(0,0,0));
|
||||
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||
} else if (state == TM_ACTIONSTATE_RUNNING) {
|
||||
*fadeloop+=10;
|
||||
if (*fadeloop>=256) return true;
|
||||
} else if (state == TM_ACTIONSTATE_DRAW) {
|
||||
al_draw_tinted_bitmap(fade_bitmap,al_map_rgba_f(1,1,1,*fadeloop/255.0),0,0,0);
|
||||
} else if (state == TM_ACTIONSTATE_DESTROY) {
|
||||
//FIXME: data
|
||||
//PrintConsole(game, "Leaving level with %d HP", (int)(game->level.hp*100));
|
||||
al_destroy_bitmap(fade_bitmap);
|
||||
free(fadeloop);
|
||||
SwitchGamestate(game, "level", "map");
|
||||
TM_DestroyArgs(action->arguments);
|
||||
action->arguments = NULL;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Welcome(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||
float* tmp; bool* in;
|
||||
if (!action->arguments) {
|
||||
action->arguments = TM_AddToArgs(action->arguments, 2, malloc(sizeof(float)), malloc(sizeof(bool)));
|
||||
}
|
||||
tmp = (float*)action->arguments->value;
|
||||
in = (bool*)action->arguments->next->value;
|
||||
if (state == TM_ACTIONSTATE_INIT) {
|
||||
*tmp = 0;
|
||||
*in = true;
|
||||
/*PrintConsole(game, "WELCOME INIT");*/
|
||||
}
|
||||
else if (state == TM_ACTIONSTATE_RUNNING) {
|
||||
/*PrintConsole(game, "WELCOME RUNNING FADE=%f, IN=%d", *in); */
|
||||
float fade = *tmp;
|
||||
if (fade>255) fade=255;
|
||||
if (*tmp > 2048) { *tmp=255; *in=false; }
|
||||
if (*in) {
|
||||
*tmp+=10;
|
||||
} else {
|
||||
*tmp-=10;
|
||||
if (*tmp<=0) { return true; }
|
||||
}
|
||||
} else if (state == TM_ACTIONSTATE_DRAW) {
|
||||
//FIXME: data
|
||||
//al_draw_tinted_bitmap(game->level.welcome, al_map_rgba_f(*tmp/255.0,*tmp/255.0,*tmp/255.0,*tmp/255.0), 0, 0, 0);
|
||||
} else if (state == TM_ACTIONSTATE_DESTROY) {
|
||||
free(action->arguments->value);
|
||||
free(action->arguments->next->value);
|
||||
TM_DestroyArgs(action->arguments);
|
||||
action->arguments = NULL;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PassLevel(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||
if (state == TM_ACTIONSTATE_DESTROY) {
|
||||
if (*((int*)action->arguments->next->value) < 6) {
|
||||
AdvanceLevel(game, *((int*)action->arguments->next->value), false);
|
||||
SwitchGamestate(game, (char*)action->arguments->value, "map");
|
||||
} else {
|
||||
AdvanceLevel(game, *((int*)action->arguments->next->value), true);
|
||||
SwitchGamestate(game, (char*)action->arguments->value, "about");
|
||||
}
|
||||
//FIXME: data
|
||||
/*Level_Passed(game);
|
||||
Level_Unload(game);
|
||||
if (game->level.current_level<6) {
|
||||
game->gamestate = GAMESTATE_LOADING;
|
||||
game->loadstate = GAMESTATE_MAP;
|
||||
} else {
|
||||
game->gamestate = GAMESTATE_LOADING;
|
||||
game->loadstate = GAMESTATE_ABOUT;
|
||||
}*/
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Letter(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||
if (state == TM_ACTIONSTATE_INIT) {
|
||||
TM_WrapArg(float, f, 0);
|
||||
TM_WrapArg(ALLEGRO_AUDIO_STREAM*, stream, al_load_audio_stream(GetDataFilePath(game, "levels/1/letter.flac"), 4, 1024));
|
||||
//FIXME: GetLevelFilename
|
||||
//*stream = al_load_audio_stream(GetDataFilePath(game, GetLevelFilename(game, "levels/?/letter.flac")), 4, 1024);
|
||||
al_attach_audio_stream_to_mixer(*stream, game->audio.voice);
|
||||
al_set_audio_stream_playing(*stream, false);
|
||||
al_set_audio_stream_gain(*stream, 2.00); // FIXME: fix audio file instead of gaining it here...
|
||||
action->arguments = TM_AddToArgs(action->arguments, 2, f, stream);
|
||||
action->arguments->next->next = NULL;
|
||||
} else if (state == TM_ACTIONSTATE_DESTROY) {
|
||||
ALLEGRO_AUDIO_STREAM** stream = (ALLEGRO_AUDIO_STREAM**)action->arguments->next->value;
|
||||
al_set_audio_stream_playing(*stream, false);
|
||||
al_destroy_audio_stream(*stream);
|
||||
free(action->arguments->next->value);
|
||||
free(action->arguments->value);
|
||||
TM_DestroyArgs(action->arguments);
|
||||
} else if (state == TM_ACTIONSTATE_DRAW) {
|
||||
//float* f = (float*)action->arguments->value;
|
||||
//FIXME: data
|
||||
//al_draw_tinted_bitmap(game->level.letter, al_map_rgba(*f,*f,*f,*f), (game->viewport.width-al_get_bitmap_width(game->level.letter))/2.0, al_get_bitmap_height(game->level.letter)*-0.05, 0);
|
||||
return false;
|
||||
} else if (state == TM_ACTIONSTATE_PAUSE) {
|
||||
ALLEGRO_AUDIO_STREAM** stream = (ALLEGRO_AUDIO_STREAM**)action->arguments->next->value;
|
||||
al_set_audio_stream_playing(*stream, false);
|
||||
} else if ((state == TM_ACTIONSTATE_RESUME) || (state == TM_ACTIONSTATE_START)) {
|
||||
ALLEGRO_AUDIO_STREAM** stream = (ALLEGRO_AUDIO_STREAM**)action->arguments->next->value;
|
||||
al_set_audio_stream_playing(*stream, true);
|
||||
}
|
||||
if (state != TM_ACTIONSTATE_RUNNING) return false;
|
||||
|
||||
float* f = (float*)action->arguments->value;
|
||||
*f+=5;
|
||||
if (*f>255) *f=255;
|
||||
//FIXME: data
|
||||
//al_draw_tinted_bitmap(game->level.letter, al_map_rgba(*f,*f,*f,*f), (game->viewport.width-al_get_bitmap_width(game->level.letter))/2.0, al_get_bitmap_height(game->level.letter)*-0.05, 0);
|
||||
struct ALLEGRO_KEYBOARD_STATE keyboard;
|
||||
al_get_keyboard_state(&keyboard);
|
||||
// FIXME: do it the proper way
|
||||
if (al_key_down(&keyboard, ALLEGRO_KEY_ENTER)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
/*! \file levels/actions.h
|
||||
* \brief Header file with Level actions for Timeline Manager.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "../main.h"
|
||||
#include "../timeline.h"
|
||||
|
||||
/*! \brief Display level failed screen and set fade-out to be run after few seconds. */
|
||||
bool LevelFailed(struct Game *game, struct TM_Action *action, enum TM_ActionState state);
|
||||
|
||||
/*! \brief Fade-in HP meter. */
|
||||
bool ShowMeter(struct Game *game, struct TM_Action *action, enum TM_ActionState state);
|
||||
|
||||
/*! \brief Stops Derpy. */
|
||||
bool Stop(struct Game *game, struct TM_Action *action, enum TM_ActionState state);
|
||||
|
||||
/*! \brief Fade-in screen. */
|
||||
bool FadeIn(struct Game *game, struct TM_Action *action, enum TM_ActionState state);
|
||||
|
||||
/*! \brief Fade-out screen. */
|
||||
bool FadeOut(struct Game *game, struct TM_Action *action, enum TM_ActionState state);
|
||||
|
||||
/*! \brief Show welcome screen (for instance "Level 1: Fluttershy"). */
|
||||
bool Welcome(struct Game *game, struct TM_Action *action, enum TM_ActionState state);
|
||||
|
||||
/*! \brief Pass level and fade-out after few seconds. */
|
||||
bool PassLevel(struct Game *game, struct TM_Action *action, enum TM_ActionState state);
|
||||
|
||||
/*! \brief Shows letter from Twilight on screen. */
|
||||
bool Letter(struct Game *game, struct TM_Action *action, enum TM_ActionState state);
|
|
@ -1,219 +0,0 @@
|
|||
/*! \file level1.c
|
||||
* \brief Level 1 code.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "allegro5/allegro_ttf.h"
|
||||
#include "../timeline.h"
|
||||
#include "../gamestates/level.h"
|
||||
#include "actions.h"
|
||||
#include "../utils.h"
|
||||
#include "modules/dodger.h"
|
||||
#include "modules/dodger/actions.h"
|
||||
#include "level1.h"
|
||||
|
||||
int Gamestate_ProgressCount = 2;
|
||||
|
||||
void Gamestate_Start(struct Game *game, struct Level1Resources* data) {
|
||||
TM_AddBackgroundAction(data->dodger->timeline, &FadeIn, NULL, 0, "fadein");
|
||||
TM_AddDelay(data->dodger->timeline, 1000);
|
||||
TM_AddQueuedBackgroundAction(data->dodger->timeline, &Welcome, NULL, 0, "welcome");
|
||||
TM_AddDelay(data->dodger->timeline, 1000);
|
||||
TM_AddAction(data->dodger->timeline, &Walk, NULL, "walk");
|
||||
TM_AddAction(data->dodger->timeline, &Move, NULL, "move");
|
||||
TM_AddAction(data->dodger->timeline, &Stop, NULL, "stop");
|
||||
TM_AddDelay(data->dodger->timeline, 1000);
|
||||
TM_AddAction(data->dodger->timeline, &Letter, NULL, "letter");
|
||||
TM_AddDelay(data->dodger->timeline, 200);
|
||||
TM_AddQueuedBackgroundAction(data->dodger->timeline, &Accelerate, NULL, 0, "accelerate");
|
||||
TM_AddAction(data->dodger->timeline, &Fly, NULL, "fly");
|
||||
TM_AddDelay(data->dodger->timeline, 500);
|
||||
/* first part gameplay goes here */
|
||||
|
||||
/* actions for generating obstacles should go here
|
||||
* probably as regular actions. When one ends, harder one
|
||||
* begins. After last one part with muffins starts. */
|
||||
TM_AddAction(data->dodger->timeline, &GenerateObstacles, NULL, "obstacles");
|
||||
TM_AddDelay(data->dodger->timeline, 3*1000);
|
||||
/* wings disappear, deccelerate */
|
||||
TM_AddAction(data->dodger->timeline, &Run, NULL, "run");
|
||||
TM_AddDelay(data->dodger->timeline, 3*1000);
|
||||
/* show Fluttershy's house
|
||||
|
||||
// second part gameplay goes here
|
||||
|
||||
// cutscene goes here */
|
||||
|
||||
TM_WrapArg(int, level, 1);
|
||||
TM_AddAction(data->dodger->timeline, &PassLevel, TM_AddToArgs(NULL, 2, strdup("level1"), level), "passlevel");
|
||||
|
||||
// init level specific obstacle (owl) for Dodger module
|
||||
struct Obstacle *obst = malloc(sizeof(struct Obstacle));
|
||||
obst->prev = NULL;
|
||||
obst->next = NULL;
|
||||
obst->x = (game->viewport.height*1.33625)/game->viewport.width*100;
|
||||
obst->y = 55;
|
||||
obst->speed = 1;
|
||||
obst->points = 0;
|
||||
obst->hit = false;
|
||||
obst->rows = 1;
|
||||
obst->cols = 1;
|
||||
obst->pos = 0;
|
||||
obst->blanks = 0;
|
||||
obst->anim_speed = 0;
|
||||
obst->tmp_pos = 0;
|
||||
obst->angle = 0;
|
||||
obst->callback = NULL;
|
||||
obst->data = NULL;
|
||||
obst->bitmap = &(data->owl);
|
||||
data->dodger->obstacles = obst;
|
||||
}
|
||||
|
||||
void Gamestate_Reload(struct Game *game, struct Level1Resources* data) {}
|
||||
|
||||
void Gamestate_Stop(struct Game *game, struct Level1Resources* data) {
|
||||
|
||||
}
|
||||
|
||||
void Gamestate_Unload(struct Game *game, struct Level1Resources* data) {
|
||||
Dodger_Unload(game, data->dodger);
|
||||
}
|
||||
|
||||
void Gamestate_UnloadBitmaps(struct Game *game, struct Level1Resources* data) {
|
||||
Dodger_UnloadBitmaps(game, data->dodger);
|
||||
al_destroy_font(data->letter_font);
|
||||
al_destroy_bitmap(data->letter);
|
||||
al_destroy_bitmap(data->owl);
|
||||
}
|
||||
|
||||
|
||||
void Gamestate_PreloadBitmaps(struct Game *game, struct Level1Resources* data) {
|
||||
data->welcome = al_create_bitmap(game->viewport.width, game->viewport.height/2);
|
||||
|
||||
data->font_title = al_load_ttf_font(GetDataFilePath(game, "fonts/ShadowsIntoLight.ttf"),game->viewport.height*0.16,0 );
|
||||
data->font_subtitle = al_load_ttf_font(GetDataFilePath(game, "fonts/ShadowsIntoLight.ttf"),game->viewport.height*0.08,0 );
|
||||
data->font = al_load_ttf_font(GetDataFilePath(game, "fonts/ShadowsIntoLight.ttf"),game->viewport.height*0.05,0 );
|
||||
|
||||
data->owl = LoadScaledBitmap(game, "levels/1/owl.png", game->viewport.height*0.1275, game->viewport.height*0.1275);
|
||||
data->letter_font = al_load_ttf_font(GetDataFilePath(game, "fonts/DejaVuSans.ttf"),game->viewport.height*0.0225,0 );
|
||||
data->letter = LoadScaledBitmap(game, "levels/1/letter.png", game->viewport.height*1.3, game->viewport.height*1.2);
|
||||
al_set_target_bitmap(data->letter);
|
||||
float y = 0.20;
|
||||
float x = 0.19;
|
||||
void draw_text(char* text) {
|
||||
al_draw_text(data->letter_font, al_map_rgb(0,0,0), al_get_bitmap_width(data->letter)*x, game->viewport.height*y, ALLEGRO_ALIGN_LEFT, text);
|
||||
y+=0.028;
|
||||
}
|
||||
draw_text("Dear Derpy,");
|
||||
draw_text("");
|
||||
x = 0.20;
|
||||
draw_text("I'm glad you decided to help us! I found a few tips");
|
||||
draw_text("in my library that might be useful on your mission.");
|
||||
draw_text("I would like to share them with you.");
|
||||
draw_text("");
|
||||
x = 0.21;
|
||||
draw_text("Muffins regenerate your energy, so collect as many");
|
||||
draw_text("as you can. Cherries can help you as well. But be");
|
||||
draw_text("careful and avoid the muffinzombies - they can");
|
||||
draw_text("harm you!");
|
||||
draw_text("");
|
||||
x = 0.22;
|
||||
draw_text("Discord is not fully awake yet, but he's already");
|
||||
draw_text("causing chaos all over Equestria and his strange");
|
||||
draw_text("creatures may try to stop you. Don't let them!");
|
||||
draw_text("");
|
||||
x = 0.23;
|
||||
draw_text("Last but not least - You should be able to see the");
|
||||
draw_text("constellation Orion in the sky tonight. Be sure to");
|
||||
draw_text("take a moment to look for it if you have one to");
|
||||
draw_text("spare. It's beautiful!");
|
||||
draw_text("");
|
||||
x = 0.25;
|
||||
draw_text("The fate of Equestria rests in your hooves.");
|
||||
draw_text("Be safe and good luck!");
|
||||
draw_text("");
|
||||
x = 0.26;
|
||||
draw_text("Yours,");
|
||||
draw_text("Twilight Sparkle");
|
||||
DrawTextWithShadow(data->font, al_map_rgb(255,255,255), al_get_bitmap_width(data->letter)*0.5, al_get_bitmap_height(data->letter)*0.8, ALLEGRO_ALIGN_CENTRE, "Press enter to continue...");
|
||||
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||
|
||||
al_set_target_bitmap(data->welcome);
|
||||
al_clear_to_color(al_map_rgba(0,0,0,0));
|
||||
DrawTextWithShadow(data->font_title, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.1, ALLEGRO_ALIGN_CENTRE, "Level 1");
|
||||
DrawTextWithShadow(data->font_subtitle, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.275, ALLEGRO_ALIGN_CENTRE, "Fluttershy");
|
||||
|
||||
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||
|
||||
Dodger_PreloadBitmaps(game, data->dodger);
|
||||
}
|
||||
|
||||
struct Level1Resources* Gamestate_Load(struct Game *game) {
|
||||
struct Level1Resources *data = malloc(sizeof(struct Level1Resources));
|
||||
|
||||
struct Character *character = CreateCharacter(game, "derpy");
|
||||
RegisterSpritesheet(game, character, "walk");
|
||||
RegisterSpritesheet(game, character, "stand");
|
||||
RegisterSpritesheet(game, character, "fly");
|
||||
RegisterSpritesheet(game, character, "run");
|
||||
SelectSpritesheet(game, character, "run");
|
||||
SetCharacterPosition(game, character, 0.1, 0.7, 0);
|
||||
data->dodger = Dodger_Load(game, character);
|
||||
data->dodger->timeline = TM_Init(game, "main");
|
||||
|
||||
data->failed=false;
|
||||
data->cl_pos=0;
|
||||
data->bg_pos=0;
|
||||
data->fg_pos=0.2;
|
||||
data->st_pos=0.1;
|
||||
data->handle_input = false;
|
||||
data->meter_alpha=0;
|
||||
|
||||
Gamestate_PreloadBitmaps(game, data);
|
||||
LoadSpritesheets(game, character);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
void Gamestate_Draw(struct Game *game, struct Level1Resources* data) {
|
||||
Dodger_Draw(game, data->dodger);
|
||||
}
|
||||
|
||||
void Gamestate_Logic(struct Game *game, struct Level1Resources* data) {
|
||||
TM_Process(data->dodger->timeline);
|
||||
Dodger_Logic(game, data->dodger);
|
||||
}
|
||||
|
||||
void Gamestate_ProcessEvent(struct Game *game, struct Level1Resources* data, ALLEGRO_EVENT *ev) {
|
||||
TM_HandleEvent(data->dodger->timeline, ev);
|
||||
Dodger_ProcessEvent(game, data->dodger, ev);
|
||||
if (ev->type == ALLEGRO_EVENT_KEY_DOWN) {
|
||||
if (ev->keyboard.keycode == ALLEGRO_KEY_ESCAPE) {
|
||||
SwitchGamestate(game, "level1", "map");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Gamestate_Resume(struct Game *game, struct Level1Resources* data) {
|
||||
Dodger_Resume(game, data->dodger);
|
||||
}
|
||||
|
||||
void Gamestate_Pause(struct Game *game, struct Level1Resources* data) {
|
||||
Dodger_Pause(game, data->dodger);
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
/*! \file level1.h
|
||||
* \brief Level 1 headers.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#include "../main.h"
|
||||
|
||||
struct Dodger;
|
||||
struct Level1Resources {
|
||||
struct Dodger *dodger;
|
||||
|
||||
ALLEGRO_FONT *letter_font; /*!< Font used in letter from Twilight on first level. */
|
||||
ALLEGRO_SAMPLE *sample; /*!< Sample with background music. */
|
||||
ALLEGRO_SAMPLE_INSTANCE *music; /*!< Sample instance with background music. */
|
||||
unsigned int music_pos; /*!< Position of sample instance. Used when pausing game. */
|
||||
ALLEGRO_BITMAP *background; /*!< Bitmap of the background layer of the scene. */
|
||||
ALLEGRO_BITMAP *stage; /*!< Bitmap of the stage layer of the scene. */
|
||||
ALLEGRO_BITMAP *foreground; /*!< Bitmap of the foreground layer of the scene. */
|
||||
ALLEGRO_BITMAP *clouds; /*!< Bitmap of the clouds layer of the scene. */
|
||||
ALLEGRO_BITMAP *welcome; /*!< Bitmap of the welcome text (for instance "Level 1: Fluttershy"). */
|
||||
ALLEGRO_BITMAP **derpy_sheet; /*!< Pointer to active Derpy sprite sheet. */
|
||||
ALLEGRO_BITMAP *derpy_bmp; /*!< Derpy sprite. */
|
||||
ALLEGRO_BITMAP *meter_bmp; /*!< Bitmap of the HP meter. */
|
||||
ALLEGRO_BITMAP *meter_image; /*!< Derpy image used in the HP meter. */
|
||||
ALLEGRO_BITMAP *letter; /*!< Bitmap with letter from Twilight. */
|
||||
struct Character *derpy;
|
||||
struct {
|
||||
ALLEGRO_BITMAP *pie1; /*!< Pie bitmap. */
|
||||
ALLEGRO_BITMAP *pie2; /*!< Pie bitmap (crossed). */
|
||||
ALLEGRO_BITMAP *muffin; /*!< Good muffin bitmap. */
|
||||
ALLEGRO_BITMAP *badmuffin; /*!< Bad muffin bitmap. */
|
||||
ALLEGRO_BITMAP *cherry; /*!< Cherry bitmap. */
|
||||
ALLEGRO_BITMAP *pig; /*!< Pig spritesheet bitmap. */
|
||||
ALLEGRO_BITMAP *screwball; /*!< Screwball spritesheet bitmap. */
|
||||
} obst_bmps; /*!< Obstacle bitmaps. */
|
||||
|
||||
float bg_pos; /*!< Position of the background layer of the scene. */
|
||||
float st_pos; /*!< Position of the stage layer of the scene. */
|
||||
float fg_pos; /*!< Position of the foreground layer of the scene. */
|
||||
float cl_pos; /*!< Position of the clouds layer of the scene. */
|
||||
|
||||
ALLEGRO_FONT *font;
|
||||
ALLEGRO_FONT *font_title;
|
||||
ALLEGRO_FONT *font_subtitle;
|
||||
|
||||
bool handle_input; /*!< When false, player looses control over Derpy. */
|
||||
|
||||
bool failed; /*!< Indicates if player failed level. */
|
||||
bool unloading; /*!< Indicated if level is already being unloaded. */
|
||||
|
||||
float meter_alpha; /*!< Alpha level of HP meter. */
|
||||
//int sheet_rows; /*!< Number of rows in current spritesheet. */
|
||||
//int sheet_cols; /*!< Number of cols in current spritesheet. */
|
||||
//int sheet_pos; /*!< Frame position in current spritesheet. */
|
||||
//int sheet_blanks; /*!< Number of blank frames at the end of current spritesheet. */
|
||||
//char* sheet_successor; /*!< Successor of current animation. If blank, then it's looped. */
|
||||
//float sheet_tmp; /*!< Temporary counter used to slow down spritesheet animation. */
|
||||
//float sheet_speed; /*!< Current speed of Derpy animation. */
|
||||
//float sheet_speed_modifier; /*!< Modifier of speed, specified by current spritesheet. */
|
||||
//float sheet_scale; /*!< Scale modifier of current spritesheet. */
|
||||
|
||||
//struct Spritesheet* derpy_sheets; /*!< List of spritesheets of Derpy character. */
|
||||
//struct Spritesheet* pony_sheets; /*!< List of spritesheets of character rescued by Derpy. */
|
||||
ALLEGRO_BITMAP *owl; /*!< Owlicious bitmap. */
|
||||
|
||||
};
|
|
@ -1,24 +0,0 @@
|
|||
/*! \file level2.c
|
||||
* \brief Level placeholder code.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#define LEVEL 2
|
||||
|
||||
#include "level_placeholder.c"
|
|
@ -1,27 +0,0 @@
|
|||
/*! \file level2.h
|
||||
* \brief Level 2 headers.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#include "../main.h"
|
||||
|
||||
struct Moonwalk;
|
||||
struct Level2Resources {
|
||||
struct Moonwalk *moonwalk;
|
||||
ALLEGRO_FONT *font;
|
||||
};
|
|
@ -1,24 +0,0 @@
|
|||
/*! \file level3.c
|
||||
* \brief Level placeholder code.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#define LEVEL 3
|
||||
|
||||
#include "level_placeholder.c"
|
|
@ -1,27 +0,0 @@
|
|||
/*! \file level3.h
|
||||
* \brief Level 3 headers.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#include "../main.h"
|
||||
|
||||
struct Moonwalk;
|
||||
struct Level3Resources {
|
||||
struct Moonwalk *moonwalk;
|
||||
ALLEGRO_FONT *font;
|
||||
};
|
|
@ -1,24 +0,0 @@
|
|||
/*! \file level4.c
|
||||
* \brief Level placeholder code.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#define LEVEL 4
|
||||
|
||||
#include "level_placeholder.c"
|
|
@ -1,27 +0,0 @@
|
|||
/*! \file level4.h
|
||||
* \brief Level 4 headers.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#include "../main.h"
|
||||
|
||||
struct Moonwalk;
|
||||
struct Level4Resources {
|
||||
struct Moonwalk *moonwalk;
|
||||
ALLEGRO_FONT *font;
|
||||
};
|
|
@ -1,24 +0,0 @@
|
|||
/*! \file level5.c
|
||||
* \brief Level placeholder code.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#define LEVEL 5
|
||||
|
||||
#include "level_placeholder.c"
|
|
@ -1,27 +0,0 @@
|
|||
/*! \file level5.h
|
||||
* \brief Level 5 headers.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#include "../main.h"
|
||||
|
||||
struct Moonwalk;
|
||||
struct Level5Resources {
|
||||
struct Moonwalk *moonwalk;
|
||||
ALLEGRO_FONT *font;
|
||||
};
|
|
@ -1,24 +0,0 @@
|
|||
/*! \file level6.c
|
||||
* \brief Level placeholder code.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#define LEVEL 6
|
||||
|
||||
#include "level_placeholder.c"
|
|
@ -1,27 +0,0 @@
|
|||
/*! \file level6.h
|
||||
* \brief Level 6 headers.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#include "../main.h"
|
||||
|
||||
struct Moonwalk;
|
||||
struct Level6Resources {
|
||||
struct Moonwalk *moonwalk;
|
||||
ALLEGRO_FONT *font;
|
||||
};
|
|
@ -1,103 +0,0 @@
|
|||
/*! \file level_placeholder.c
|
||||
* \brief Level placeholder code to be included by levelX.c files
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
//macro magic
|
||||
#define CONCAT_REAL(a,b) a ## b
|
||||
#define STRINGIZE_REAL(A) #A
|
||||
#define CONCAT(a,b) CONCAT_REAL(a,b)
|
||||
#define STRINGIZE(A) STRINGIZE_REAL(A)
|
||||
|
||||
#define LevelXResources CONCAT(CONCAT(Level,LEVEL),Resources)
|
||||
#define levelx STRINGIZE(CONCAT(level,LEVEL))
|
||||
#define levelxh STRINGIZE(CONCAT(level,LEVEL).h)
|
||||
|
||||
#include <stdio.h>
|
||||
#include "allegro5/allegro_ttf.h"
|
||||
#include "../gamestates/level.h"
|
||||
#include "modules/moonwalk.h"
|
||||
#include "../timeline.h"
|
||||
#include "actions.h"
|
||||
#include "../utils.h"
|
||||
#include levelxh
|
||||
|
||||
|
||||
void* Gamestate_Load(struct Game *game, void (*progress)(struct Game*)) {
|
||||
|
||||
struct LevelXResources *data = malloc(sizeof(struct LevelXResources));
|
||||
data->moonwalk = Moonwalk_Load(game, LEVEL);
|
||||
(*progress)(game);
|
||||
|
||||
TM_WrapArg(int, level, LEVEL);
|
||||
TM_AddAction(data->moonwalk->timeline, &PassLevel, TM_AddToArgs(NULL, 2, strdup(levelx), level), "passlevel");
|
||||
(*progress)(game);
|
||||
|
||||
data->font = al_load_ttf_font(GetDataFilePath(game, "fonts/ShadowsIntoLight.ttf"),game->viewport.height*0.09,0 );
|
||||
(*progress)(game);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void Gamestate_Unload(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Unload(game, data->moonwalk);
|
||||
al_destroy_font(data->font);
|
||||
free(data);
|
||||
}
|
||||
|
||||
void Gamestate_Start(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Start(game, data->moonwalk);
|
||||
}
|
||||
|
||||
void Gamestate_Stop(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Stop(game, data->moonwalk);
|
||||
}
|
||||
|
||||
void Gamestate_Draw(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Draw(game, data->moonwalk);
|
||||
|
||||
al_draw_textf(data->font, al_map_rgb(255,255,255), game->viewport.width/2, game->viewport.height/2.2, ALLEGRO_ALIGN_CENTRE, "Level %d: Not implemented yet!", LEVEL);
|
||||
al_draw_text(data->font, al_map_rgb(255,255,255), game->viewport.width/2, game->viewport.height/1.8, ALLEGRO_ALIGN_CENTRE, "Have some moonwalk instead.");
|
||||
}
|
||||
|
||||
void Gamestate_Logic(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Logic(game, data->moonwalk);
|
||||
}
|
||||
|
||||
void Gamestate_ProcessEvent(struct Game *game, struct LevelXResources* data, ALLEGRO_EVENT *ev) {
|
||||
TM_HandleEvent(data->moonwalk->timeline, ev);
|
||||
Moonwalk_ProcessEvent(game, data->moonwalk, ev);
|
||||
if (ev->type == ALLEGRO_EVENT_KEY_DOWN) {
|
||||
if (ev->keyboard.keycode == ALLEGRO_KEY_ESCAPE) {
|
||||
SwitchGamestate(game, levelx, "map");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Gamestate_Resume(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Resume(game, data->moonwalk);
|
||||
}
|
||||
|
||||
void Gamestate_Pause(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Pause(game, data->moonwalk);
|
||||
}
|
||||
|
||||
void Gamestate_Reload(struct Game *game, struct LevelXResources* data) {}
|
||||
|
||||
int Gamestate_ProgressCount = 3;
|
|
@ -1,273 +0,0 @@
|
|||
/*! \file dodger.c
|
||||
* \brief Dodger Level module code.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <allegro5/allegro_primitives.h>
|
||||
#include "../../gamestates/level.h"
|
||||
#include "../../utils.h"
|
||||
#include "../actions.h"
|
||||
#include "dodger.h"
|
||||
#include "dodger/actions.h"
|
||||
|
||||
int Dodger_ProgressCount = 0;
|
||||
|
||||
void Dodger_Logic(struct Game *game, struct Dodger* data) {
|
||||
struct ALLEGRO_KEYBOARD_STATE keyboard;
|
||||
al_get_keyboard_state(&keyboard);
|
||||
if (data->handle_input) {
|
||||
if (data->character->angle > 0) { data->character->angle -= 0.02; if (data->character->angle < 0) data->character->angle = 0; }
|
||||
if (data->character->angle < 0) { data->character->angle += 0.02; if (data->character->angle > 0) data->character->angle = 0; }
|
||||
if (al_key_down(&keyboard, ALLEGRO_KEY_UP)) {
|
||||
MoveCharacter(game, data->character, 0, -0.005, -0.03);
|
||||
if (data->character->angle < -0.15) data->character->angle = -0.15;
|
||||
/*PrintConsole(game, "Derpy Y position: %f", data->derpy_y);*/
|
||||
}
|
||||
if (al_key_down(&keyboard, ALLEGRO_KEY_DOWN)) {
|
||||
MoveCharacter(game, data->character, 0, 0.005, 0.03);
|
||||
if (data->character->angle > 0.15) data->character->angle = 0.15;
|
||||
/*PrintConsole(game, "Derpy Y position: %f", data->derpy_y);*/
|
||||
}
|
||||
/*if ((data->derpy_y > 0.6) && (data->flying)) {
|
||||
SelectDerpySpritesheet(game, "run");
|
||||
data->flying = false;
|
||||
data->sheet_speed = tps(game, 60*0.0020/data->speed);
|
||||
}
|
||||
else if ((data->derpy_y <= 0.6) && (!data->flying)) {
|
||||
SelectDerpySpritesheet(game, "fly");
|
||||
data->flying = true;
|
||||
data->sheet_speed = tps(game, 60*2.4);
|
||||
}
|
||||
if (!data->flying) data->sheet_speed = tps(game, 60*0.0020/data->speed); */
|
||||
if ( data->character->y < 0) data->character->y=0;
|
||||
else if ( data->character->y > 0.8) data->character->y=0.8;
|
||||
|
||||
MoveCharacter(game, data->character, 0, data->character->angle / 30, 0);
|
||||
}
|
||||
|
||||
int derpyx = data->character->x*game->viewport.width;
|
||||
int derpyy = data->character->y*game->viewport.height;
|
||||
int derpyw = al_get_bitmap_width(data->character->bitmap);
|
||||
int derpyh = al_get_bitmap_height(data->character->bitmap);
|
||||
int derpyo = game->viewport.height*1.6*0.1953125-al_get_bitmap_width(data->character->bitmap); /* offset */
|
||||
struct Obstacle *tmp = data->obstacles;
|
||||
while (tmp) {
|
||||
/*PrintConsole(game, "DRAWING %f %f", tmp->x, tmp->y);*/
|
||||
int x = (tmp->x/100.0)*game->viewport.width;
|
||||
int y = (tmp->y/100.0)*game->viewport.height;
|
||||
int w = 0, h = 0;
|
||||
if (tmp->bitmap) {
|
||||
w = al_get_bitmap_width(*(tmp->bitmap))/tmp->cols;
|
||||
h = al_get_bitmap_height(*(tmp->bitmap))/tmp->rows;
|
||||
}
|
||||
if (x > -w) {
|
||||
/*if (!tmp->hit)*/
|
||||
if ((((x>=derpyx+0.38*derpyw+derpyo) && (x<=derpyx+0.94*derpyw+derpyo)) || ((x+w>=derpyx+0.38*derpyw+derpyo) && (x+w<=derpyx+0.94*derpyw+derpyo)) || ((x<=derpyx+0.38*derpyw+derpyo) && (x+w>=derpyx+0.94*derpyw+derpyo))) &&
|
||||
(((y>=derpyy+0.26*derpyh) && (y<=derpyy+0.76*derpyh)) || ((y+h>=derpyy+0.26*derpyh) && (y+h<=derpyy+0.76*derpyh)) || ((y<=derpyy+0.26*derpyh) && (y+h>=derpyy+0.76*derpyh)))) {
|
||||
tmp->hit=true;
|
||||
}
|
||||
|
||||
if (tmp->anim_speed) {
|
||||
tmp->tmp_pos+=1;
|
||||
if (tmp->tmp_pos >= tmp->anim_speed) {
|
||||
tmp->pos++;
|
||||
tmp->tmp_pos = 0;
|
||||
}
|
||||
if (tmp->pos>=tmp->cols*tmp->rows-tmp->blanks) tmp->pos=0;
|
||||
}
|
||||
|
||||
if (tmp->hit) {
|
||||
if (tmp->points>0) tmp->bitmap = NULL;
|
||||
data->hp+=0.0002*tmp->points*(((1-data->speed_modifier)/2.0)+1);
|
||||
if (data->hp>1) data->hp=1;
|
||||
//PrintConsole(game, "POINTS: %d, %f", tmp->points, tps(game, 60*0.0002*tmp->points*data->speed_modifier));
|
||||
if ((data->hp<=0) && (!data->failed)) {
|
||||
data->failed = true;
|
||||
data->handle_input = false;
|
||||
data->speed_modifier = 1;
|
||||
TM_AddBackgroundAction(data->timeline, &LevelFailed, NULL, 0, "levelfailed");
|
||||
}
|
||||
}
|
||||
tmp->x -= data->speed*data->speed_modifier*tmp->speed*100*al_get_display_width(game->display)/(float)game->viewport.width;
|
||||
if (tmp->callback) tmp->callback(game, tmp);
|
||||
tmp = tmp->next;
|
||||
} else {
|
||||
if (tmp->next)
|
||||
tmp->next->prev = tmp->prev;
|
||||
if (tmp->prev)
|
||||
tmp->prev->next = tmp->next;
|
||||
else
|
||||
data->obstacles = tmp->next;
|
||||
struct Obstacle *t = tmp;
|
||||
tmp = tmp->next;
|
||||
free(t);
|
||||
}
|
||||
}
|
||||
/*if (colision) data->hp-=tps(game, 60*0.002);*/
|
||||
AnimateCharacter(game, data->character, data->speed_modifier);
|
||||
|
||||
}
|
||||
|
||||
void Dodger_Draw(struct Game *game, struct Dodger* data) {
|
||||
int derpyx = data->character->x*game->viewport.width;
|
||||
int derpyy = data->character->y*game->viewport.height;
|
||||
int derpyw = al_get_bitmap_width(data->character->bitmap);
|
||||
int derpyh = al_get_bitmap_height(data->character->bitmap);
|
||||
int derpyo = 0;//game->viewport.height*1.6*0.1953125-al_get_bitmap_width(data->character->bitmap); /* offset */
|
||||
bool colision = false;
|
||||
struct Obstacle *tmp = data->obstacles;
|
||||
while (tmp) {
|
||||
/*PrintConsole(game, "DRAWING %f %f", tmp->x, tmp->y);*/
|
||||
int x = (tmp->x/100.0)*game->viewport.width;
|
||||
int y = (tmp->y/100.0)*game->viewport.height;
|
||||
int w = 0, h = 0;
|
||||
if (tmp->bitmap) {
|
||||
w = al_get_bitmap_width(*(tmp->bitmap))/tmp->cols;
|
||||
h = al_get_bitmap_height(*(tmp->bitmap))/tmp->rows;
|
||||
}
|
||||
if (x > -w) {
|
||||
if ((tmp->hit) && (tmp->points<0)) {
|
||||
colision = true;
|
||||
}
|
||||
|
||||
if (tmp->bitmap) {
|
||||
ALLEGRO_BITMAP* subbitmap = al_create_sub_bitmap(*(tmp->bitmap),w*(tmp->pos%tmp->cols), h*(tmp->pos/tmp->cols),w,h);
|
||||
al_draw_rotated_bitmap(subbitmap,w/2.0, h/2.0, x+w/2.0,y+h/2.0, tmp->angle, 0);
|
||||
al_destroy_bitmap(subbitmap);
|
||||
}
|
||||
|
||||
/*al_draw_bitmap(*(tmp->bitmap), x, y, 0);*/
|
||||
if (data->debug_show_sprite_frames) al_draw_rectangle(x, y, x+w, y+h, al_map_rgba(255,0,0,255), 3);
|
||||
|
||||
tmp = tmp->next;
|
||||
} else {
|
||||
if (tmp->next)
|
||||
tmp->next->prev = tmp->prev;
|
||||
if (tmp->prev)
|
||||
tmp->prev->next = tmp->next;
|
||||
else
|
||||
data->obstacles = tmp->next;
|
||||
struct Obstacle *t = tmp;
|
||||
tmp = tmp->next;
|
||||
free(t);
|
||||
}
|
||||
}
|
||||
/*if (colision) data->hp-=tps(game, 60*0.002);*/
|
||||
|
||||
/* al_set_target_bitmap(data->character->bitmap);
|
||||
al_clear_to_color(al_map_rgba(0,0,0,0));
|
||||
al_draw_bitmap_region(data->character->spritesheet->bitmap,al_get_bitmap_width(data->character->bitmap)*(data->character->pos%data->character->spritesheet->cols),al_get_bitmap_height(data->character->bitmap)*(data->character->pos/data->character->spritesheet->cols),al_get_bitmap_width(data->character->bitmap), al_get_bitmap_height(data->character->bitmap),0,0,0);
|
||||
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||
|
||||
al_draw_tinted_rotated_bitmap(data->character->bitmap, al_map_rgba(255,255-colision*255,255-colision*255,255), al_get_bitmap_width(data->character->bitmap), al_get_bitmap_height(data->character->bitmap)/2, derpyx+game->viewport.height*1.6*0.1953125, derpyy + al_get_bitmap_height(data->character->bitmap)/2, data->character->angle, 0);*/
|
||||
DrawCharacter(game, data->character, al_map_rgba(255,255-colision*255,255-colision*255,255), 0);
|
||||
|
||||
/* if ((((x>=derpyx+0.36*derpyw) && (x<=derpyx+0.94*derpyw)) || ((x+w>=derpyx+0.36*derpyw) && (x+w<=derpyx+0.94*derpyw))) &&
|
||||
(((y>=derpyy+0.26*derpyh) && (y<=derpyy+0.76*derpyh)) || ((y+h>=derpyy+0.26*derpyh) && (y+h<=derpyy+0.76*derpyh)))) {
|
||||
*/
|
||||
if (data->debug_show_sprite_frames) {
|
||||
al_draw_rectangle(derpyx+derpyo, derpyy, derpyx+derpyw+derpyo, derpyy+derpyh, al_map_rgba(0,255,0,255), 3);
|
||||
al_draw_rectangle(derpyx+0.38*derpyw+derpyo, derpyy+0.26*derpyh, derpyx+0.94*derpyw+derpyo, derpyy+0.76*derpyh, al_map_rgba(0,0,255,255), 3);
|
||||
}
|
||||
}
|
||||
|
||||
struct Dodger* Dodger_Load(struct Game *game, struct Character *character) {
|
||||
struct Dodger *data = malloc(sizeof(struct Dodger));
|
||||
data->obstacles = NULL;
|
||||
data->character = character;
|
||||
|
||||
data->failed=false;
|
||||
data->hp=1;
|
||||
data->speed = 0;
|
||||
data->speed_modifier = 1;
|
||||
data->handle_input = true;
|
||||
data->debug_show_sprite_frames=true;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void Dodger_ProcessEvent(struct Game *game, struct Dodger* data, ALLEGRO_EVENT *ev) {
|
||||
if (data->handle_input) {
|
||||
if ((ev->type==ALLEGRO_EVENT_KEY_UP) && (ev->keyboard.keycode==ALLEGRO_KEY_LEFT)) {
|
||||
data->speed_modifier = 1;
|
||||
struct ALLEGRO_KEYBOARD_STATE keyboard;
|
||||
al_get_keyboard_state(&keyboard);
|
||||
if (al_key_down(&keyboard, ALLEGRO_KEY_RIGHT)) {
|
||||
data->speed_modifier = 1.3;
|
||||
}
|
||||
} else if ((ev->type==ALLEGRO_EVENT_KEY_UP) && (ev->keyboard.keycode==ALLEGRO_KEY_RIGHT)) {
|
||||
data->speed_modifier = 1;
|
||||
struct ALLEGRO_KEYBOARD_STATE keyboard;
|
||||
al_get_keyboard_state(&keyboard);
|
||||
if (al_key_down(&keyboard, ALLEGRO_KEY_LEFT)) {
|
||||
data->speed_modifier = 0.75;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline int Dodger_PreloadSteps(void) {
|
||||
return 7;
|
||||
}
|
||||
|
||||
void Dodger_PreloadBitmaps(struct Game *game, struct Dodger* data) {
|
||||
//PROGRESS_INIT(Dodger_PreloadSteps());
|
||||
data->obst_bmps.pie1 = LoadScaledBitmap(game, "levels/dodger/pie1.png", game->viewport.height*1.6*0.1, game->viewport.height*0.08);
|
||||
|
||||
data->obst_bmps.pie2 = LoadScaledBitmap(game, "levels/dodger/pie2.png", game->viewport.height*1.6*0.1, game->viewport.height*0.08);
|
||||
|
||||
data->obst_bmps.pig = LoadScaledBitmap(game, "levels/dodger/pig.png", (int)(game->viewport.height*1.6*0.15)*3, (int)(game->viewport.height*0.2)*3);
|
||||
|
||||
data->obst_bmps.screwball = LoadScaledBitmap(game, "levels/dodger/screwball.png", (int)(game->viewport.height*0.2)*4*1.4, (int)(game->viewport.height*0.2)*4);
|
||||
|
||||
data->obst_bmps.muffin = LoadScaledBitmap(game, "levels/dodger/muffin.png", game->viewport.height*1.6*0.07, game->viewport.height*0.1);
|
||||
|
||||
data->obst_bmps.cherry = LoadScaledBitmap(game, "levels/dodger/cherry.png", game->viewport.height*1.6*0.03, game->viewport.height*0.08);
|
||||
|
||||
data->obst_bmps.badmuffin = LoadScaledBitmap(game, "levels/dodger/badmuffin.png", game->viewport.height*1.6*0.07, game->viewport.height*0.1);
|
||||
|
||||
}
|
||||
|
||||
void Dodger_UnloadBitmaps(struct Game *game, struct Dodger* data) {
|
||||
al_destroy_bitmap(data->obst_bmps.pie1);
|
||||
al_destroy_bitmap(data->obst_bmps.pie2);
|
||||
al_destroy_bitmap(data->obst_bmps.pig);
|
||||
al_destroy_bitmap(data->obst_bmps.cherry);
|
||||
al_destroy_bitmap(data->obst_bmps.muffin);
|
||||
al_destroy_bitmap(data->obst_bmps.badmuffin);
|
||||
al_destroy_bitmap(data->obst_bmps.screwball);
|
||||
}
|
||||
|
||||
void Dodger_Unload(struct Game *game, struct Dodger* data) {
|
||||
struct Obstacle *t = data->obstacles;
|
||||
if (t) {
|
||||
while (t->next) {
|
||||
if (t->prev) free(t->prev);
|
||||
t = t->next;
|
||||
}
|
||||
free(t);
|
||||
}
|
||||
|
||||
DestroyCharacter(game, data->character);
|
||||
free(data);
|
||||
}
|
||||
|
||||
void Dodger_Resume(struct Game *game, struct Dodger* data) {}
|
||||
void Dodger_Pause(struct Game *game, struct Dodger* data) {}
|
|
@ -1,85 +0,0 @@
|
|||
/*! \file dodger.h
|
||||
* \brief Dodger Level module headers.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#include "../../main.h"
|
||||
|
||||
|
||||
/*! \brief Structure representing obstacles and power-ups flying through the level. */
|
||||
struct Obstacle {
|
||||
ALLEGRO_BITMAP **bitmap; /*!< Pointer to bitmap used by obstacle. */
|
||||
float x; /*!< Horizontal position on the screen, in range 0-100. */
|
||||
float y; /*!< Vertical position on the screen, in range 0-100. */
|
||||
float speed; /*!< Horizontal speed of obstracle. */
|
||||
float angle; /*!< Angle of bitmap rotation in radians. */
|
||||
int points; /*!< Number of points given when hit by player. Positive gives HP to power, negative takes it. */
|
||||
bool hit; /*!< Indicates if this obstacle was already hit by the player or not. */
|
||||
|
||||
int cols; /*!< Number of columns in spritesheet. */
|
||||
int rows; /*!< Number of rows in spritesheet. */
|
||||
int pos; /*!< Current position in spritesheet. */
|
||||
int blanks; /*!< Number of blank frames at the end of the spritesheet. */
|
||||
float tmp_pos; /*!< Temporary counter used to slow down spritesheet animation. */
|
||||
float anim_speed; /*!< Speed of spritesheet animation. */
|
||||
|
||||
void (*callback)(struct Game*, struct Obstacle*); /*!< Pointer to function called to update obstacle position, animate it, etc. */
|
||||
void *data; /*!< Pointer passed to callback function. */
|
||||
struct Obstacle *prev; /*!< Previous obstacle on the list. */
|
||||
struct Obstacle *next; /*!< Next obstacle on the list. */
|
||||
};
|
||||
|
||||
struct Dodger {
|
||||
|
||||
|
||||
struct Obstacle *obstacles; /*!< List of obstacles being currently rendered. */
|
||||
struct Obstacle *possible_obstacles; /* TODO: make list of used obstacles dynamic */
|
||||
float speed; /*!< Speed of the player. */
|
||||
float speed_modifier; /*!< Modifier of the speed of the player. */
|
||||
float hp; /*!< Player health points (0-1). */
|
||||
bool debug_show_sprite_frames; /*!< When true, displays colorful borders around spritesheets and their active areas. */
|
||||
struct Character *character;
|
||||
bool failed;
|
||||
bool handle_input; /*!< When false, player looses control over Derpy. */
|
||||
|
||||
struct {
|
||||
ALLEGRO_BITMAP *pie1; /*!< Pie bitmap. */
|
||||
ALLEGRO_BITMAP *pie2; /*!< Pie bitmap (crossed). */
|
||||
ALLEGRO_BITMAP *muffin; /*!< Good muffin bitmap. */
|
||||
ALLEGRO_BITMAP *badmuffin; /*!< Bad muffin bitmap. */
|
||||
ALLEGRO_BITMAP *cherry; /*!< Cherry bitmap. */
|
||||
ALLEGRO_BITMAP *pig; /*!< Pig spritesheet bitmap. */
|
||||
ALLEGRO_BITMAP *screwball; /*!< Screwball spritesheet bitmap. */
|
||||
} obst_bmps; /*!< Obstacle bitmaps. */
|
||||
|
||||
struct Timeline *timeline;
|
||||
|
||||
};
|
||||
|
||||
void Dodger_PreloadBitmaps(struct Game *game, struct Dodger* data);
|
||||
void Dodger_Keydown(struct Game *game, struct Dodger* data, ALLEGRO_EVENT *ev);
|
||||
|
||||
void Dodger_Draw(struct Game *game, struct Dodger *data);
|
||||
void Dodger_Logic(struct Game *game, struct Dodger *data);
|
||||
void Dodger_Unload(struct Game *game, struct Dodger *data);
|
||||
struct Dodger* Dodger_Load(struct Game *game, struct Character *character);
|
||||
void Dodger_UnloadBitmaps(struct Game *game, struct Dodger *data);
|
||||
void Dodger_LoadBitmaps(struct Game *game, struct Dodger *data, void (*progress)(struct Game*, float));
|
||||
void Dodger_ProcessEvent(struct Game *game, struct Dodger *data, ALLEGRO_EVENT *ev);
|
||||
void Dodger_Resume(struct Game *game, struct Dodger *data);
|
||||
void Dodger_Pause(struct Game *game, struct Dodger *data);
|
|
@ -1,186 +0,0 @@
|
|||
/*! \file dodger/actions.c
|
||||
* \brief Dodger Level module actions for Timeline Manager.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "actions.h"
|
||||
#include "callbacks.h"
|
||||
#include "../../actions.h"
|
||||
#include "../../../gamestates/level.h"
|
||||
|
||||
// TODO: make it configurable and move to generic actions
|
||||
// args: struct Character* character
|
||||
bool Walk(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||
if (state == TM_ACTIONSTATE_START) return false; //SelectDerpySpritesheet(game, "walk");
|
||||
else if (state != TM_ACTIONSTATE_RUNNING) return false;
|
||||
//game->level.derpy_x+=(0.00125*1280)/(float)game->viewportWidth;
|
||||
//if (game->level.derpy_x>=(0.05*1280)/(float)game->viewportWidth) return true;
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: make it configurable
|
||||
// args: struct Dodger* data
|
||||
bool Accelerate(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||
if (state != TM_ACTIONSTATE_RUNNING) return false;
|
||||
//game->level.speed+=0.000015;
|
||||
//if (game->level.speed>=0.0025) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// args: struct Dodger* data
|
||||
bool Move(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||
if (state != TM_ACTIONSTATE_RUNNING) return false;
|
||||
// game->level.speed=0.000345;
|
||||
// if (game->level.st_pos>=0.275) return true;
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// args: struct Dodger* data
|
||||
bool Fly(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||
if (state == TM_ACTIONSTATE_START) {
|
||||
// SelectDerpySpritesheet(game, "fly");
|
||||
// game->level.derpy_angle = -0.15;
|
||||
// TM_AddBackgroundAction(&ShowMeter, NULL, 0, "showmeter");
|
||||
}
|
||||
else if (state == TM_ACTIONSTATE_DESTROY) {
|
||||
// game->level.handle_input = true;
|
||||
}
|
||||
else if (state != TM_ACTIONSTATE_RUNNING) return false;
|
||||
// game->level.derpy_y-=0.004;
|
||||
// if (game->level.derpy_y<=0.2) return true;
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// args: struct Dodger* data
|
||||
bool Run(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||
if (state == TM_ACTIONSTATE_START) {
|
||||
// game->level.handle_input=false;
|
||||
// game->level.speed_modifier=1;
|
||||
}
|
||||
else if (state == TM_ACTIONSTATE_DESTROY) {
|
||||
// game->level.derpy_angle = 0;
|
||||
// SelectDerpySpritesheet(game, "run");
|
||||
}
|
||||
else if (state != TM_ACTIONSTATE_RUNNING) return false;
|
||||
// game->level.derpy_y+=0.0042;
|
||||
// if (game->level.derpy_angle > 0) { game->level.derpy_angle -= 0.02; if (game->level.derpy_angle < 0) game->level.derpy_angle = 0; }
|
||||
// if (game->level.derpy_angle < 0) { game->level.derpy_angle += 0.02; if (game->level.derpy_angle > 0) game->level.derpy_angle = 0; }
|
||||
// if (game->level.derpy_y>=0.65) return true;
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// args: struct Dodger* data
|
||||
bool GenerateObstacles(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||
int* count;
|
||||
if (!action->arguments) {
|
||||
action->arguments = TM_AddToArgs(action->arguments, 1, malloc(sizeof(int)));
|
||||
}
|
||||
count = (int*)action->arguments->value;
|
||||
if (state == TM_ACTIONSTATE_INIT) {
|
||||
*count = 0;
|
||||
}
|
||||
else if (state == TM_ACTIONSTATE_RUNNING) {
|
||||
/* if (rand()%(10000/(int)(85*game->level.speed_modifier))<=3) {
|
||||
PrintConsole(game, "OBSTACLE %d", *count);
|
||||
(*count)++;
|
||||
struct Obstacle *obst = malloc(sizeof(struct Obstacle));
|
||||
obst->prev = NULL;
|
||||
obst->x = 100;
|
||||
obst->y = (rand()%91)-1;
|
||||
obst->speed = 1.05;
|
||||
obst->points = -10;
|
||||
obst->hit = false;
|
||||
obst->rows = 1;
|
||||
obst->cols = 1;
|
||||
obst->pos = 0;
|
||||
obst->blanks = 0;
|
||||
obst->anim_speed = 0;
|
||||
obst->tmp_pos = 0;
|
||||
obst->angle = 0;
|
||||
if (rand()%100<=50) {
|
||||
obst->callback= NULL;
|
||||
obst->data = NULL;
|
||||
obst->points = -5;
|
||||
obst->bitmap = &(game->level.dodger.obst_bmps.badmuffin);
|
||||
obst->speed += (rand()%100) / 1000.0 - 0.05;
|
||||
} else if (rand()%100<=12) {
|
||||
obst->callback= &Obst_RotateSin;
|
||||
obst->data = malloc(sizeof(float));
|
||||
*((float*)obst->data) = 0;
|
||||
obst->points = 8;
|
||||
obst->bitmap = &(game->level.dodger.obst_bmps.muffin);
|
||||
} else if (rand()%100<=12) {
|
||||
obst->callback= &Obst_RotateSin;
|
||||
obst->data = malloc(sizeof(float));
|
||||
*((float*)obst->data) = 0;
|
||||
obst->points = 4;
|
||||
obst->bitmap = &(game->level.dodger.obst_bmps.cherry);
|
||||
} else if (rand()%100<=65) {
|
||||
obst->callback= &Obst_MoveUp;
|
||||
if (rand()%100<=80) obst->bitmap = &(game->level.dodger.obst_bmps.pie1);
|
||||
else {
|
||||
obst->bitmap = &(game->level.dodger.obst_bmps.pie2);
|
||||
obst->points = -12;
|
||||
}
|
||||
obst->data = malloc(sizeof(float));
|
||||
*((float*)obst->data) = 0.25+(rand()%50/100.0);
|
||||
obst->y*=1.8;
|
||||
obst->angle = ((rand()%50)/100.0)-0.25;
|
||||
} else if (rand()%100<=80) {
|
||||
obst->callback = &Obst_MoveSin;
|
||||
obst->data = malloc(sizeof(float));
|
||||
*((float*)obst->data) = 0;
|
||||
obst->bitmap = &(game->level.dodger.obst_bmps.pig);
|
||||
obst->rows = 3;
|
||||
obst->cols = 3;
|
||||
obst->speed = 1.2;
|
||||
obst->anim_speed = 2;
|
||||
obst->points = -20;
|
||||
} else {
|
||||
obst->callback = &Obst_MoveUpDown;
|
||||
obst->bitmap = &(game->level.dodger.obst_bmps.screwball);
|
||||
obst->data = malloc(sizeof(bool));
|
||||
*((bool*)obst->data) = rand()%2;
|
||||
obst->rows = 4;
|
||||
obst->cols = 4;
|
||||
obst->speed = 1.1;
|
||||
obst->anim_speed = 2;
|
||||
obst->points = -25;
|
||||
}
|
||||
if (game->level.dodger.obstacles) {
|
||||
game->level.dodger.obstacles->prev = obst;
|
||||
obst->next = game->level.dodger.obstacles;
|
||||
} else {
|
||||
obst->next = NULL;
|
||||
}
|
||||
game->level.dodger.obstacles = obst;
|
||||
if (*count > 128) return true;
|
||||
}*/
|
||||
} else if (state == TM_ACTIONSTATE_DESTROY) {
|
||||
free(action->arguments->value);
|
||||
TM_DestroyArgs(action->arguments);
|
||||
action->arguments = NULL;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
/*! \file dodger/actions.h
|
||||
* \brief Header file with Dodger Level module actions for Timeline Manager.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "../../../main.h"
|
||||
#include "../../../timeline.h"
|
||||
|
||||
/*! \brief Accelerate current speed game until threshold is reached */
|
||||
bool Accelerate(struct Game *game, struct TM_Action *action, enum TM_ActionState state);
|
||||
|
||||
/*! \brief Set Derpy to walk and move her position on screen. */
|
||||
bool Walk(struct Game *game, struct TM_Action *action, enum TM_ActionState state);
|
||||
|
||||
/*! \brief Move screen until some position is reached. */
|
||||
bool Move(struct Game *game, struct TM_Action *action, enum TM_ActionState state);
|
||||
|
||||
/*! \brief Fly Derpy, fly! */
|
||||
bool Fly(struct Game *game, struct TM_Action *action, enum TM_ActionState state);
|
||||
|
||||
/*! \brief Run Derpy, run! */
|
||||
bool Run(struct Game *game, struct TM_Action *action, enum TM_ActionState state);
|
||||
|
||||
/*! \brief Generates obstacles. */
|
||||
bool GenerateObstacles(struct Game *game, struct TM_Action *action, enum TM_ActionState state);
|
|
@ -1,57 +0,0 @@
|
|||
/*! \file callbacks.c
|
||||
* \brief Obstacle callbacks for Dodger Level module.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include "callbacks.h"
|
||||
|
||||
void Obst_MoveUpDown(struct Game *game, struct Obstacle *obstacle) {
|
||||
if (*((bool*)obstacle->data)) {
|
||||
obstacle->y -= 0.5;
|
||||
if (obstacle->y<=0) {
|
||||
*((bool*)obstacle->data)=false;
|
||||
}
|
||||
} else {
|
||||
obstacle->y += 0.5;
|
||||
if (obstacle->y>=((game->viewport.height-al_get_bitmap_height(*(obstacle->bitmap))/obstacle->rows)/(float)game->viewport.height)*100) {
|
||||
*((bool*)obstacle->data)=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Obst_MoveUp(struct Game *game, struct Obstacle *obstacle) {
|
||||
float* a = (float*)obstacle->data;
|
||||
obstacle->y -= *a;
|
||||
}
|
||||
|
||||
void Obst_RotateSin(struct Game *game, struct Obstacle *obstacle) {
|
||||
float* a = (float*)obstacle->data;
|
||||
/*PrintConsole(game, "%p - %f", obstacle, obstacle->y);*/
|
||||
obstacle->angle = sin(*a)/2.0;
|
||||
*a+=4.5/60.0;
|
||||
}
|
||||
|
||||
void Obst_MoveSin(struct Game *game, struct Obstacle *obstacle) {
|
||||
float* a = (float*)obstacle->data;
|
||||
/*PrintConsole(game, "%p - %f", obstacle, obstacle->y);*/
|
||||
obstacle->y -= sin(*a)*4;
|
||||
*a+=4.5/60.0;
|
||||
obstacle->y += sin(*a)*4;
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
/*! \file callbacks.h
|
||||
* \brief Headers with Obstacle callbacks for Dodger Level module.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "../dodger.h"
|
||||
#include "../../../main.h"
|
||||
|
||||
/*! \brief Move up or down until reaching the edge of the screen. After that - change direction. */
|
||||
void Obst_MoveUpDown(struct Game *game, struct Obstacle *obstacle);
|
||||
|
||||
/*! \brief Move up at constant speed. */
|
||||
void Obst_MoveUp(struct Game *game, struct Obstacle *obstacle);
|
||||
|
||||
/*! \brief Move in sinusoidal way in Y-axis relative to position at beginning. */
|
||||
void Obst_MoveSin(struct Game *game, struct Obstacle *obstacle);
|
||||
|
||||
/*! \brief Rotate in sinusoidal way. */
|
||||
void Obst_RotateSin(struct Game *game, struct Obstacle *obstacle);
|
|
@ -1,123 +0,0 @@
|
|||
/*! \file moonwalk.c
|
||||
* \brief Moonwalk Level module code.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include "../../gamestates/level.h"
|
||||
#include "../../utils.h"
|
||||
#include "moonwalk.h"
|
||||
|
||||
// TODO: maybe use Walk action instead
|
||||
bool DoMoonwalk(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
|
||||
struct Character *derpy = action->arguments->value;
|
||||
if (state == TM_ACTIONSTATE_START) {
|
||||
SelectSpritesheet(game, derpy, "walk");
|
||||
SetCharacterPosition(game, derpy, -(al_get_bitmap_width(derpy->bitmap)/(float)game->viewport.width)*1.1, 0.71, 0);
|
||||
}
|
||||
else if (state == TM_ACTIONSTATE_RUNNING) {
|
||||
MoveCharacter(game, derpy, 0.0009 , 0, 0);
|
||||
AnimateCharacter(game, derpy, 0.97);
|
||||
if (derpy->x > 1) { // FIXME: getter
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Moonwalk_Logic(struct Game *game, struct Moonwalk *data) {
|
||||
TM_Process(data->timeline);
|
||||
}
|
||||
|
||||
void Moonwalk_Draw(struct Game *game, struct Moonwalk *data) {
|
||||
al_draw_scaled_bitmap(data->background,0,0,al_get_bitmap_width(data->background),al_get_bitmap_height(data->background),0,0,game->viewport.width, game->viewport.height, 0);
|
||||
DrawCharacter(game, data->derpy, al_map_rgba(255,255,255,255), ALLEGRO_FLIP_HORIZONTAL);
|
||||
}
|
||||
|
||||
void Moonwalk_Start(struct Game *game, struct Moonwalk *data) {
|
||||
SelectSpritesheet(game, data->derpy, "stand");
|
||||
al_play_sample_instance(data->music);
|
||||
// TODO: find some way to restart Timeline
|
||||
}
|
||||
|
||||
|
||||
void load_bitmaps(struct Game *game, struct Moonwalk *data) {
|
||||
data->background = LoadScaledBitmap(game, "levels/moonwalk/disco.jpg", game->viewport.width, game->viewport.height);
|
||||
LoadSpritesheets(game, data->derpy);
|
||||
}
|
||||
|
||||
|
||||
void unload_bitmaps(struct Game *game, struct Moonwalk *data) {
|
||||
UnloadSpritesheets(game, data->derpy);
|
||||
al_destroy_bitmap(data->background);
|
||||
}
|
||||
|
||||
struct Moonwalk* Moonwalk_Load(struct Game *game, int current_level) {
|
||||
struct Moonwalk *data = malloc(sizeof(struct Moonwalk));
|
||||
|
||||
data->derpy = CreateCharacter(game, "derpy");
|
||||
|
||||
RegisterSpritesheet(game, data->derpy, "stand");
|
||||
RegisterSpritesheet(game, data->derpy, "walk");
|
||||
|
||||
data->current_level = current_level;
|
||||
|
||||
load_bitmaps(game, data);
|
||||
|
||||
data->sample = al_load_sample( GetDataFilePath(game, "levels/moonwalk/moonwalk.flac") );
|
||||
|
||||
data->music = al_create_sample_instance(data->sample);
|
||||
al_attach_sample_instance_to_mixer(data->music, game->audio.music);
|
||||
al_set_sample_instance_playmode(data->music, ALLEGRO_PLAYMODE_LOOP);
|
||||
|
||||
data->timeline = TM_Init(game, "main");
|
||||
TM_AddAction(data->timeline, &DoMoonwalk, TM_AddToArgs(NULL, 1, data->derpy), "moonwalk");
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void Moonwalk_Stop(struct Game *game, struct Moonwalk *data) {
|
||||
al_set_sample_instance_playing(data->music, false);
|
||||
}
|
||||
|
||||
void Moonwalk_Unload(struct Game *game, struct Moonwalk *data) {
|
||||
unload_bitmaps(game, data);
|
||||
DestroyCharacter(game, data->derpy);
|
||||
free(data);
|
||||
TM_Destroy(data->timeline);
|
||||
}
|
||||
|
||||
void Moonwalk_ProcessEvent(struct Game *game, struct Moonwalk *data, ALLEGRO_EVENT *ev) {}
|
||||
|
||||
void Moonwalk_Pause(struct Game *game, struct Moonwalk *data) {
|
||||
data->music_pos = al_get_sample_instance_position(data->music);
|
||||
al_set_sample_instance_playing(data->music, false);
|
||||
TM_Pause(data->timeline);
|
||||
}
|
||||
|
||||
void Moonwalk_Resume(struct Game *game, struct Moonwalk *data) {
|
||||
al_set_sample_instance_position(data->music, data->music_pos);
|
||||
al_set_sample_instance_playing(data->music, true);
|
||||
TM_Resume(data->timeline);
|
||||
}
|
||||
|
||||
void Moonwalk_Reload(struct Game *game, struct Moonwalk *data) {
|
||||
unload_bitmaps(game, data);
|
||||
load_bitmaps(game, data);
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
/*! \file moonwalk.h
|
||||
* \brief Moonwalk Level module headers.
|
||||
*/
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#include "../../main.h"
|
||||
#include "../../timeline.h"
|
||||
|
||||
struct Moonwalk {
|
||||
struct Character *derpy;
|
||||
int current_level;
|
||||
ALLEGRO_BITMAP *background;
|
||||
ALLEGRO_SAMPLE *sample;
|
||||
ALLEGRO_SAMPLE_INSTANCE *music;
|
||||
int music_pos;
|
||||
struct Timeline *timeline;
|
||||
};
|
||||
|
||||
bool DoMoonwalk(struct Game *game, struct TM_Action *action, enum TM_ActionState state);
|
||||
void Moonwalk_Draw(struct Game *game, struct Moonwalk *data);
|
||||
void Moonwalk_Logic(struct Game *game, struct Moonwalk *data);
|
||||
void Moonwalk_Start(struct Game *game, struct Moonwalk *data);
|
||||
void Moonwalk_Stop(struct Game *game, struct Moonwalk *data);
|
||||
void Moonwalk_Unload(struct Game *game, struct Moonwalk *data);
|
||||
struct Moonwalk* Moonwalk_Load(struct Game *game, int current_level);
|
||||
void Moonwalk_UnloadBitmaps(struct Game *game, struct Moonwalk *data);
|
||||
void Moonwalk_LoadBitmaps(struct Game *game, struct Moonwalk *data, void (*progress)(struct Game*, float));
|
||||
void Moonwalk_ProcessEvent(struct Game *game, struct Moonwalk *data, ALLEGRO_EVENT *ev);
|
||||
void Moonwalk_Resume(struct Game *game, struct Moonwalk *data);
|
||||
void Moonwalk_Pause(struct Game *game, struct Moonwalk *data);
|
54
src/main.c
54
src/main.c
|
@ -45,16 +45,9 @@ void DrawGamestates(struct Game *game) {
|
|||
}
|
||||
tmp = tmp->next;
|
||||
}
|
||||
|
||||
if (game->mediator.pause) {
|
||||
al_draw_filled_rectangle(0, 0, 320, 180, al_map_rgba(0,0,0,192));
|
||||
DrawTextWithShadow(game->_priv.font, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.5 - 25, ALLEGRO_ALIGN_CENTRE, "Game paused!");
|
||||
DrawTextWithShadow(game->_priv.font, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.5 + 5, ALLEGRO_ALIGN_CENTRE, "SPACE to resume");
|
||||
}
|
||||
}
|
||||
|
||||
void LogicGamestates(struct Game *game) {
|
||||
if (game->mediator.pause) return;
|
||||
struct Gamestate *tmp = game->_priv.gamestates;
|
||||
while (tmp) {
|
||||
if ((tmp->loaded) && (tmp->started) && (!tmp->paused)) {
|
||||
|
@ -101,13 +94,14 @@ void derp(int sig) {
|
|||
abort();
|
||||
}
|
||||
|
||||
// TODO: let's break it up and move the binary out of libsuperderpy!
|
||||
int main(int argc, char **argv){
|
||||
signal(SIGSEGV, derp);
|
||||
|
||||
srand(time(NULL));
|
||||
|
||||
al_set_org_name("Super Derpy");
|
||||
al_set_app_name("Mediator");
|
||||
al_set_org_name("dosowisko.net");
|
||||
al_set_app_name(LIBSUPERDERPY_GAMENAME);
|
||||
|
||||
if(!al_init()) {
|
||||
fprintf(stderr, "failed to initialize allegro!\n");
|
||||
|
@ -192,8 +186,8 @@ int main(int argc, char **argv){
|
|||
|
||||
PrintConsole(&game, "Viewport %dx%d", game.viewport.width, game.viewport.height);
|
||||
|
||||
ALLEGRO_BITMAP *icon = al_load_bitmap(GetDataFilePath(&game, "icons/mediator.png"));
|
||||
al_set_window_title(game.display, "Mediator");
|
||||
ALLEGRO_BITMAP *icon = al_load_bitmap(GetDataFilePath(&game, "icons/" LIBSUPERDERPY_GAMENAME ".png"));
|
||||
al_set_window_title(game.display, LIBSUPERDERPY_GAMENAME_PRETTY);
|
||||
al_set_display_icon(game.display, icon);
|
||||
al_destroy_bitmap(icon);
|
||||
|
||||
|
@ -246,20 +240,7 @@ int main(int argc, char **argv){
|
|||
game.shuttingdown = false;
|
||||
game.restart = false;
|
||||
|
||||
game.mediator.lives = 3;
|
||||
game.mediator.score = 0;
|
||||
game.mediator.modificator = 1;
|
||||
game.mediator.strike = 0;
|
||||
game.mediator.next = "lollipop";
|
||||
game.mediator.pause = false;
|
||||
|
||||
game.mediator.heart = CreateCharacter(&game, "heart");
|
||||
RegisterSpritesheet(&game, game.mediator.heart, "heart");
|
||||
RegisterSpritesheet(&game, game.mediator.heart, "blank");
|
||||
LoadSpritesheets(&game, game.mediator.heart);
|
||||
SelectSpritesheet(&game, game.mediator.heart, "heart");
|
||||
|
||||
char* gamestate = strdup("dosowisko"); // FIXME: don't hardcore gamestate
|
||||
char* gamestate = strdup(LIBSUPERDERPY_INITIAL_GAMESTATE); // FIXME: don't hardcore gamestate
|
||||
|
||||
int c;
|
||||
while ((c = getopt (argc, argv, "l:s:")) != -1)
|
||||
|
@ -276,14 +257,12 @@ int main(int argc, char **argv){
|
|||
}
|
||||
|
||||
LoadGamestate(&game, gamestate);
|
||||
LoadGamestate(&game, "burndt");
|
||||
game._priv.gamestates->showLoading = false; // we have only one gamestate right now
|
||||
game._priv.gamestates->next->showLoading = false; // well, now two
|
||||
StartGamestate(&game, gamestate);
|
||||
free(gamestate);
|
||||
|
||||
char libname[1024] = {};
|
||||
snprintf(libname, 1024, "libsuperderpy-%s-loading" LIBRARY_EXTENTION, "mediator");
|
||||
snprintf(libname, 1024, "libsuperderpy-%s-loading" LIBRARY_EXTENSION, LIBSUPERDERPY_GAMENAME);
|
||||
void *handle = dlopen(libname, RTLD_NOW);
|
||||
if (!handle) {
|
||||
FatalError(&game, true, "Error while initializing loading screen %s", dlerror());
|
||||
|
@ -345,7 +324,7 @@ int main(int argc, char **argv){
|
|||
al_stop_timer(game._priv.timer);
|
||||
// TODO: take proper game name
|
||||
char libname[1024];
|
||||
snprintf(libname, 1024, "libsuperderpy-%s-%s" LIBRARY_EXTENTION, "mediator", tmp->name);
|
||||
snprintf(libname, 1024, "libsuperderpy-%s-%s" LIBRARY_EXTENSION, LIBSUPERDERPY_GAMENAME, tmp->name);
|
||||
tmp->handle = dlopen(libname,RTLD_NOW);
|
||||
if (!tmp->handle) {
|
||||
//PrintConsole(&game, "Error while loading gamestate \"%s\": %s", tmp->name, dlerror());
|
||||
|
@ -484,23 +463,14 @@ int main(int argc, char **argv){
|
|||
} else if ((ev.type == ALLEGRO_EVENT_KEY_DOWN) && (game.config.debug) && (ev.keyboard.keycode == ALLEGRO_KEY_F12)) {
|
||||
ALLEGRO_PATH *path = al_get_standard_path(ALLEGRO_USER_DOCUMENTS_PATH);
|
||||
char filename[255] = { };
|
||||
snprintf(filename, 255, "Mediator_%ld_%ld.png", time(NULL), clock());
|
||||
snprintf(filename, 255, LIBSUPERDERPY_GAMENAME_PRETTY "_%ld_%ld.png", time(NULL), clock());
|
||||
al_set_path_filename(path, filename);
|
||||
al_save_bitmap(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP), al_get_backbuffer(game.display));
|
||||
PrintConsole(&game, "Screenshot stored in %s", al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP));
|
||||
al_destroy_path(path);
|
||||
} else if ((ev.type == ALLEGRO_EVENT_KEY_DOWN) && (ev.keyboard.keycode == ALLEGRO_KEY_SPACE)) {
|
||||
game.mediator.pause = !game.mediator.pause;
|
||||
if (game.mediator.pause) {
|
||||
PauseGamestates(&game);
|
||||
} else {
|
||||
ResumeGamestates(&game);
|
||||
}
|
||||
} else {
|
||||
if (!game.mediator.pause) {
|
||||
EventGamestates(&game, &ev);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
EventGamestates(&game, &ev);
|
||||
}
|
||||
}
|
||||
}
|
||||
game.shuttingdown = true;
|
||||
|
|
|
@ -135,7 +135,7 @@ void PauseTimers(struct Timeline* timeline, bool pause) {
|
|||
}
|
||||
}
|
||||
|
||||
void Propagate(struct Timeline* timeline, enum TM_ActionState action) {
|
||||
void TM_Propagate(struct Timeline* timeline, enum TM_ActionState action) {
|
||||
if (timeline->queue) {
|
||||
if ((*timeline->queue->function) && (timeline->queue->active)) {
|
||||
(*timeline->queue->function)(timeline->game, timeline->queue, action);
|
||||
|
@ -154,18 +154,18 @@ void Propagate(struct Timeline* timeline, enum TM_ActionState action) {
|
|||
}
|
||||
|
||||
void TM_Draw(struct Timeline* timeline) {
|
||||
Propagate(timeline, TM_ACTIONSTATE_DRAW);
|
||||
TM_Propagate(timeline, TM_ACTIONSTATE_DRAW);
|
||||
}
|
||||
|
||||
void TM_Pause(struct Timeline* timeline) {
|
||||
PrintConsole(timeline->game, "Timeline Manager[%s]: Pause.", timeline->name);
|
||||
PauseTimers(timeline, true);
|
||||
Propagate(timeline, TM_ACTIONSTATE_PAUSE);
|
||||
TM_Propagate(timeline, TM_ACTIONSTATE_PAUSE);
|
||||
}
|
||||
|
||||
void TM_Resume(struct Timeline* timeline) {
|
||||
PrintConsole(timeline->game, "Timeline Manager[%s]: Resume.", timeline->name);
|
||||
Propagate(timeline, TM_ACTIONSTATE_RESUME);
|
||||
TM_Propagate(timeline, TM_ACTIONSTATE_RESUME);
|
||||
PauseTimers(timeline, false);
|
||||
}
|
||||
|
||||
|
|
69
src/utils.c
69
src/utils.c
|
@ -239,7 +239,7 @@ void FatalError(struct Game *game, bool fatal, char* format, ...) {
|
|||
al_set_target_backbuffer(game->display);
|
||||
al_clear_to_color(al_map_rgb(0,0,170));
|
||||
|
||||
char *header = "MEDIATOR";
|
||||
char *header = LIBSUPERDERPY_GAMENAME_PRETTY;
|
||||
|
||||
al_draw_filled_rectangle(al_get_display_width(game->display)/2 - al_get_text_width(game->_priv.font_bsod, header)/2 - 4, (int)(al_get_display_height(game->display) * 0.32), 4 + al_get_display_width(game->display)/2 + al_get_text_width(game->_priv.font_bsod, header)/2, (int)(al_get_display_height(game->display) * 0.32) + al_get_font_line_height(game->_priv.font_bsod), al_map_rgb(170,170,170));
|
||||
|
||||
|
@ -311,16 +311,29 @@ char* GetDataFilePath(struct Game *game, char* filename) {
|
|||
return strdup(filename);
|
||||
}
|
||||
|
||||
char origfn[255] = "data/";
|
||||
strcat(origfn, filename);
|
||||
{
|
||||
char origfn[255] = "data/";
|
||||
strcat(origfn, filename);
|
||||
|
||||
if (al_filename_exists(origfn)) {
|
||||
return strdup(origfn);
|
||||
if (al_filename_exists(origfn)) {
|
||||
return strdup(origfn);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
char origfn[255] = "libsuperderpy/data/";
|
||||
strcat(origfn, filename);
|
||||
|
||||
if (al_filename_exists(origfn)) {
|
||||
return strdup(origfn);
|
||||
}
|
||||
}
|
||||
|
||||
TestPath(filename, "data/", &result);
|
||||
TestPath(filename, "../share/mediator/data/", &result);
|
||||
TestPath(filename, "../share/" LIBSUPERDERPY_GAMENAME "/data/", &result);
|
||||
|
||||
TestPath(filename, "../data/", &result);
|
||||
TestPath(filename, "libsuperderpy/data/", &result);
|
||||
#ifdef ALLEGRO_MACOSX
|
||||
TestPath(filename, "../Resources/data/", &result);
|
||||
TestPath(filename, "../Resources/gamestates/", &result);
|
||||
|
@ -526,53 +539,9 @@ void SetCharacterPosition(struct Game *game, struct Character *character, int x,
|
|||
character->angle = angle;
|
||||
}
|
||||
|
||||
bool GetAbstractIsItBonusLevelTimeNowFactoryProvider(struct Game *game) {
|
||||
return game->mediator.strike && (game->mediator.strike % 5 == 0);
|
||||
}
|
||||
|
||||
void DrawCharacter(struct Game *game, struct Character *character, ALLEGRO_COLOR tint, int flags) {
|
||||
if (character->dead) return;
|
||||
int spritesheetX = al_get_bitmap_width(character->bitmap)*(character->pos%character->spritesheet->cols);
|
||||
int spritesheetY = al_get_bitmap_height(character->bitmap)*(character->pos/character->spritesheet->cols);
|
||||
al_draw_tinted_scaled_rotated_bitmap_region(character->spritesheet->bitmap, spritesheetX, spritesheetY, al_get_bitmap_width(character->bitmap), al_get_bitmap_height(character->bitmap), tint, al_get_bitmap_width(character->bitmap)/2, al_get_bitmap_height(character->bitmap)/2, character->x + al_get_bitmap_width(character->bitmap)/2, character->y + al_get_bitmap_height(character->bitmap)/2, 1, 1, character->angle, flags);
|
||||
}
|
||||
|
||||
void AdvanceLevel(struct Game *game, bool won) {
|
||||
if (won) {
|
||||
game->mediator.score++;
|
||||
game->mediator.strike++;
|
||||
} else {
|
||||
game->mediator.lives--;
|
||||
game->mediator.strike = 0;
|
||||
}
|
||||
game->mediator.modificator *= 1.025;
|
||||
SelectSpritesheet(game, game->mediator.heart, "heart");
|
||||
}
|
||||
|
||||
void ShowLevelStatistics(struct Game *game) {
|
||||
// show as many bitmaps as there are lives
|
||||
// show additional one as a animated character
|
||||
|
||||
al_draw_filled_rectangle(0, 0, 320, 240, al_map_rgba(0, 0, 0, 192));
|
||||
|
||||
int x = 75;
|
||||
|
||||
int pos = game->mediator.heart->pos;
|
||||
struct Spritesheet *a = game->mediator.heart->spritesheet;
|
||||
|
||||
for (int i = 0; i < game->mediator.lives; i++) {
|
||||
SetCharacterPosition(game, game->mediator.heart, x, 50, 0);
|
||||
SelectSpritesheet(game, game->mediator.heart, "heart");
|
||||
DrawCharacter(game, game->mediator.heart, al_map_rgb(255, 255, 255), 0);
|
||||
x += 48;
|
||||
}
|
||||
game->mediator.heart->pos = pos;
|
||||
game->mediator.heart->spritesheet = a;
|
||||
|
||||
if (game->mediator.lives >= 0) {
|
||||
SetCharacterPosition(game, game->mediator.heart, x, 50, 0);
|
||||
DrawCharacter(game, game->mediator.heart, al_map_rgb(255, 255, 255), 0);
|
||||
}
|
||||
|
||||
//DrawTextWithShadow(game->_priv.font, al_map_rgb(255,255,255), 50, 50, 0, text);
|
||||
}
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
#include "main.h"
|
||||
|
||||
#ifdef ALLEGRO_WINDOWS
|
||||
#define LIBRARY_EXTENTION ".dll"
|
||||
#define LIBRARY_EXTENSION ".dll"
|
||||
#else
|
||||
#define LIBRARY_EXTENTION ".so"
|
||||
#define LIBRARY_EXTENSION ".so"
|
||||
#endif
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue