Converted Alien Blaster data to .png and .ogg format, saves 4 Mb
This commit is contained in:
@@ -22,7 +22,7 @@ LOCAL_SRC_FILES := $(foreach F, $(APP_SUBDIRS), $(addprefix $(F)/,$(notdir $(wil
|
||||
# Uncomment to also add C sources
|
||||
LOCAL_SRC_FILES += $(foreach F, $(APP_SUBDIRS), $(addprefix $(F)/,$(notdir $(wildcard $(LOCAL_PATH)/$(F)/*.c))))
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := sdl sdl_mixer tremor sdl_ttf
|
||||
LOCAL_SHARED_LIBRARIES := sdl sdl_mixer sdl_image tremor sdl_ttf
|
||||
|
||||
LOCAL_STATIC_LIBRARIES := stlport
|
||||
|
||||
|
||||
@@ -21,6 +21,10 @@ using namespace std;
|
||||
|
||||
#include "soundDB.h"
|
||||
#include "SDL_mixer.h"
|
||||
#ifdef ANDROID
|
||||
#include <android/log.h>
|
||||
#endif
|
||||
#include <iostream>
|
||||
|
||||
SoundDB::SoundDB() {}
|
||||
|
||||
@@ -37,9 +41,33 @@ Mix_Chunk *SoundDB::loadWav( string fn ) {
|
||||
if ( searchResult ) {
|
||||
return searchResult;
|
||||
}
|
||||
|
||||
|
||||
// Check if file exist
|
||||
FILE * inputFile = fopen( fn.c_str(), "rb");
|
||||
if (!inputFile) {
|
||||
if( fn.size() > 4 && fn.find(".wav") != string::npos ) {
|
||||
fn = fn.substr( 0, fn.size() - 4 ) + ".ogg";
|
||||
inputFile = fopen( fn.c_str(), "rb");
|
||||
}
|
||||
if (!inputFile) {
|
||||
cout << "ERROR: file " << fn << " does not exist!" << endl;
|
||||
#ifdef ANDROID
|
||||
__android_log_print(ANDROID_LOG_ERROR, "Alien Blaster", (string( "Cannot load sound " ) + fn).c_str() );
|
||||
#endif
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
fclose(inputFile);
|
||||
|
||||
// TODO: error-handling
|
||||
Mix_Chunk *newSound = Mix_LoadWAV( fn.c_str() );
|
||||
if( !newSound ) {
|
||||
cout << "ERROR: file " << fn << " cannot be loaded!" << endl;
|
||||
#ifdef ANDROID
|
||||
__android_log_print(ANDROID_LOG_ERROR, "Alien Blaster", (string( "Cannot load sound " ) + fn).c_str() );
|
||||
#endif
|
||||
exit(1);
|
||||
}
|
||||
soundDB[ fn ] = newSound;
|
||||
return newSound;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ using namespace std;
|
||||
#include "surfaceDB.h"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <SDL_image.h>
|
||||
#ifdef ANDROID
|
||||
#include <android/log.h>
|
||||
#endif
|
||||
@@ -51,17 +52,26 @@ SDL_Surface *SurfaceDB::loadSurface( string fn, bool alpha ) {
|
||||
return searchResult;
|
||||
}
|
||||
|
||||
// open the file for reading
|
||||
ifstream inputFile ( fn.c_str(), ios::in);
|
||||
if (!inputFile.good()) {
|
||||
cout << "ERROR: file " << fn << " does not exist!" << endl;
|
||||
bool isPNG = false;
|
||||
// Check if file exist
|
||||
FILE * inputFile = fopen( fn.c_str(), "rb");
|
||||
if (!inputFile) {
|
||||
if( fn.size() > 4 && fn.find(".bmp") != string::npos ) {
|
||||
isPNG = true;
|
||||
fn = fn.substr( 0, fn.size() - 4 ) + ".png";
|
||||
inputFile = fopen( fn.c_str(), "rb");
|
||||
}
|
||||
if (!inputFile) {
|
||||
cout << "ERROR: file " << fn << " does not exist!" << endl;
|
||||
#ifdef ANDROID
|
||||
__android_log_print(ANDROID_LOG_ERROR, "Alien Blaster", (string( "Cannot load image " ) + fn).c_str() );
|
||||
__android_log_print(ANDROID_LOG_ERROR, "Alien Blaster", (string( "Cannot load image " ) + fn).c_str() );
|
||||
#endif
|
||||
exit(1);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_Surface *newSurface = SDL_LoadBMP( fn.c_str() );
|
||||
fclose(inputFile);
|
||||
|
||||
SDL_Surface *newSurface = isPNG ? IMG_Load( fn.c_str() ) : SDL_LoadBMP( fn.c_str() );
|
||||
if( newSurface == NULL )
|
||||
{
|
||||
cout << "ERROR: Cannot load image " << fn << endl;
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user