beta 2 + editor for the windows version
parent
5359374304
commit
2cb35eab1f
|
@ -69,8 +69,6 @@ int Model::OnInit (int argc, char* argv[]) {
|
|||
mLevelAuthor = "";
|
||||
mLevelTitle = "";
|
||||
|
||||
Engine::PlayMusic (Engine::GetResourceFullPath("/data/sounds/intro_music.ogg"));
|
||||
|
||||
Engine::RegisterListener (this, EventAccelerateStart);
|
||||
Engine::RegisterListener (this, EventAccelerateStop);
|
||||
|
||||
|
@ -427,6 +425,8 @@ void Model::OnNewGame() {
|
|||
}
|
||||
|
||||
void Model::OnShipExplode () {
|
||||
Engine::PlaySound(Engine::GetResourceFullPath("/data/sounds/rock_destroyed.wav"));
|
||||
|
||||
mPlayerLives --;
|
||||
|
||||
if (mPlayerLives == 0) {
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
|
||||
namespace asteroids {
|
||||
|
||||
Engine::Variable RocketEntity::VarTimeToLive ("rocket_timetolive", "1.0");
|
||||
Engine::Variable RocketEntity::VarSpeed ("rocket_speed", "15");
|
||||
|
||||
void RocketEntity::Update (float delta_sec) {
|
||||
mSecToLive -= delta_sec;
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ struct RocketEntityPhysicState : public Engine::EntityPhysicState {
|
|||
mType = GameEntityTypeRocket;
|
||||
}
|
||||
virtual ~RocketEntityPhysicState() {};
|
||||
|
||||
};
|
||||
|
||||
struct RocketEntity: public Engine::EntityBase {
|
||||
|
@ -31,6 +32,9 @@ struct RocketEntity: public Engine::EntityBase {
|
|||
}
|
||||
|
||||
float mSecToLive;
|
||||
|
||||
static Engine::Variable VarTimeToLive;
|
||||
static Engine::Variable VarSpeed;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ void ShipEntity::Attack () {
|
|||
|
||||
RocketEntity *rocket_entity = (RocketEntity*) Engine::CreateEntity (GameEntityTypeRocket);
|
||||
|
||||
rocket_entity->mSecToLive = 1.5;
|
||||
rocket_entity->mSecToLive = RocketEntity::VarTimeToLive.GetFloatValue();
|
||||
|
||||
RocketEntityPhysicState *rocket_physics = (RocketEntityPhysicState*) rocket_entity->mPhysicState;
|
||||
rocket_physics->mPosition = attack_dir;
|
||||
|
@ -115,7 +115,7 @@ void ShipEntity::Attack () {
|
|||
rocket_physics->mPosition += entity_physic->mPosition;
|
||||
rocket_physics->mOrientation = entity_physic->mOrientation;
|
||||
rocket_physics->mVelocity = attack_dir.normalize();
|
||||
rocket_physics->mVelocity *= ShipEntity::VarMaxSpeed.GetFloatValue() + 0.5;
|
||||
rocket_physics->mVelocity *= RocketEntity::VarSpeed.GetFloatValue();
|
||||
|
||||
Engine::PlaySound (Engine::GetResourceFullPath("/data/sounds/laser.wav"));
|
||||
}
|
||||
|
|
|
@ -476,6 +476,11 @@ void View::DrawPageTitle (const std::string& title) {
|
|||
void View::DrawUiMainMenu() {
|
||||
DrawPageTitle ("Asteroids");
|
||||
|
||||
SelectFont("console.ttf size=23 color=#444444");
|
||||
DrawGLString( screen_right - 272, screen_bottom - 16, "http://www.fysx.org");
|
||||
SelectFont("console.ttf size=23 color=#cccccc");
|
||||
DrawGLString( screen_right - 270, screen_bottom - 18, "http://www.fysx.org");
|
||||
|
||||
SelectFont("console.ttf size=23");
|
||||
if (Engine::GUI::Button (1, "New Game", screen_right * 0.5 - 100, 200, button_width, button_height)) {
|
||||
PushViewState(ViewStateEnterPlayername);
|
||||
|
@ -489,10 +494,12 @@ void View::DrawUiMainMenu() {
|
|||
PushViewState(ViewStateShowHighscore);
|
||||
}
|
||||
|
||||
/*
|
||||
if (Engine::GUI::Button (6, "E", screen_right - 48, 20, 32, button_height)) {
|
||||
PushViewState(ViewStateEditor);
|
||||
GetController()->ResetLevel();
|
||||
}
|
||||
*/
|
||||
|
||||
if (Engine::GUI::Button (4, "Quit", screen_right * 0.5 - 100, 380, button_width, button_height)) {
|
||||
Engine::RunCommand("quit");
|
||||
|
@ -574,7 +581,7 @@ void View::DrawUiLevelComplete() {
|
|||
GetModel()->SetGameState(GameStatePaused);
|
||||
|
||||
if (mEditorState == EditorStateTest) {
|
||||
GetModel()->DoLoadLevel("level_edit_temp.txt");
|
||||
GetModel()->DoLoadLevel("level_edit_temp.map");
|
||||
mEditorState = EditorStateUnknown;
|
||||
}
|
||||
} else {
|
||||
|
@ -624,7 +631,7 @@ void View::DrawUiPlayerDied() {
|
|||
GetModel()->SetGameState(GameStatePaused);
|
||||
|
||||
if (mEditorState == EditorStateTest) {
|
||||
GetModel()->DoLoadLevel("level_edit_temp.txt");
|
||||
GetModel()->DoLoadLevel("level_edit_temp.map");
|
||||
mEditorState = EditorStateUnknown;
|
||||
}
|
||||
} else {
|
||||
|
@ -777,7 +784,7 @@ void View::DrawUiEditor() {
|
|||
if (mEditorState == EditorStateTest) {
|
||||
mEditorState = EditorStateUnknown;
|
||||
|
||||
GetModel()->DoLoadLevel("level_edit_temp.txt");
|
||||
GetModel()->DoLoadLevel("level_edit_temp.map");
|
||||
GetModel()->SetGameState(GameStatePaused);
|
||||
return;
|
||||
} else if (!Engine::GUI::CheckKeyPressed(SDLK_ESCAPE)){
|
||||
|
@ -835,7 +842,7 @@ void View::DrawUiEditor() {
|
|||
if (Engine::GUI::Button (9, "Test", 475, 20, 64, button_height)) {
|
||||
mEditorState = EditorStateTest;
|
||||
|
||||
GetModel()->DoSaveLevel("level_edit_temp.txt");
|
||||
GetModel()->DoSaveLevel("level_edit_temp.map");
|
||||
GetModel()->SetGameState(GameStateRunning);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,6 +58,11 @@ class View : public Engine::ViewBase {
|
|||
|
||||
Engine::LogDebug("Popped ViewState: %s current %s remaining: %u", popped_name.c_str(), current_name.c_str(), mViewStateStack.size());
|
||||
|
||||
if (mViewStateStack.size() == 0) {
|
||||
Engine::LogDebug ("No ViewState on the stack! Quitting.");
|
||||
Engine::RunCommand("quit");
|
||||
}
|
||||
|
||||
// Fire the view state change event to properly clear the IMGUI state
|
||||
Engine::EventBasePtr changeviewstate_event (new Engine::EventBase());
|
||||
changeviewstate_event->mEventType = EventChangeViewState;
|
||||
|
|
|
@ -27,10 +27,22 @@ std::string create_user_path () {
|
|||
std::string test_file_path = result_dir;
|
||||
|
||||
// first we check in $HOME/.fysxasteroids
|
||||
#ifdef WIN32
|
||||
size_t env_retval;
|
||||
char env_home_dir[255];
|
||||
getenv_s (&env_retval, env_home_dir, 255, "HOME");
|
||||
if (env_retval == 0) {
|
||||
env_home_dir[0] = '\0';
|
||||
}
|
||||
#else
|
||||
char* env_home_dir = getenv("HOME");
|
||||
#endif
|
||||
cout << "Yo4 " << env_home_dir << endl;
|
||||
|
||||
result_dir = env_home_dir;
|
||||
result_dir += "/.fysxasteroids";
|
||||
|
||||
cout << "Path = " << result_dir << endl;
|
||||
boost::filesystem::path result_dir_path(result_dir);
|
||||
if(!boost::filesystem::is_directory (result_dir_path)) {
|
||||
if (!boost::filesystem::create_directory(result_dir_path)) {
|
||||
|
@ -118,7 +130,14 @@ int main (int argc, char* argv[]) {
|
|||
SetLogPrintLevel (Engine::LogLevelMessage);
|
||||
|
||||
// we assume the user path to be local folder
|
||||
std::string user_path = create_user_path();
|
||||
std::string user_path;
|
||||
|
||||
#ifdef WIN32
|
||||
user_path = ".";
|
||||
#else
|
||||
user_path = create_user_path();
|
||||
#endif
|
||||
|
||||
std::string log_file_path = user_path;
|
||||
log_file_path += "/editor.log";
|
||||
|
||||
|
@ -146,7 +165,7 @@ int main (int argc, char* argv[]) {
|
|||
else
|
||||
SDL_WM_SetIcon(image,NULL);
|
||||
|
||||
SDL_WM_SetCaption("Asteroids -BETA1-","Asteroids -BETA 1-");
|
||||
SDL_WM_SetCaption("fysxasteroids -Editor-","fysxasteroids -Editor-");
|
||||
|
||||
engine.GetView()->SetGridSize (8,8);
|
||||
|
||||
|
@ -159,6 +178,7 @@ int main (int argc, char* argv[]) {
|
|||
// run the default commands and load the configuration
|
||||
Engine::RunCommand ("exec asteroids.rc");
|
||||
Engine::RunCommand ("exec config.rc");
|
||||
Engine::SetMusicVolume (0.);
|
||||
|
||||
asteroids::GetView()->PopViewState();
|
||||
asteroids::GetView()->PushViewState(asteroids::ViewStateEditor);
|
||||
|
|
|
@ -115,8 +115,15 @@ int main (int argc, char* argv[]) {
|
|||
|
||||
SetLogPrintLevel (Engine::LogLevelMessage);
|
||||
|
||||
std::string user_path = ".";
|
||||
std::string game_data_path = ".";
|
||||
|
||||
#ifndef WIN32
|
||||
user_path = create_user_path();
|
||||
game_data_path = find_game_data_dir();
|
||||
#endif
|
||||
|
||||
// we assume the user path to be local folder
|
||||
std::string user_path = create_user_path();
|
||||
std::string log_file_path = user_path;
|
||||
log_file_path += "/game.log";
|
||||
|
||||
|
@ -124,7 +131,6 @@ int main (int argc, char* argv[]) {
|
|||
engine.SetUserDataPath (user_path);
|
||||
Engine::SetLogFilename (log_file_path.c_str());
|
||||
|
||||
std::string game_data_path = find_game_data_dir();
|
||||
engine.SetGameDataPath (game_data_path);
|
||||
cout << "Game Data Dir = " << game_data_path << endl;
|
||||
|
||||
|
@ -142,7 +148,7 @@ int main (int argc, char* argv[]) {
|
|||
else
|
||||
SDL_WM_SetIcon(image,NULL);
|
||||
|
||||
SDL_WM_SetCaption("Asteroids -BETA1-","Asteroids -BETA 1-");
|
||||
SDL_WM_SetCaption("fysxasteroids -BETA 2-","fysxasteroids -BETA 2-");
|
||||
|
||||
engine.GetView()->SetGridSize (8,8);
|
||||
|
||||
|
@ -156,6 +162,8 @@ int main (int argc, char* argv[]) {
|
|||
Engine::RunCommand ("exec asteroids.rc");
|
||||
Engine::RunCommand ("exec config.rc");
|
||||
|
||||
Engine::PlayMusic (Engine::GetResourceFullPath("/data/sounds/intro_music.ogg"));
|
||||
|
||||
engine.MainLoop ();
|
||||
|
||||
// save the configuration
|
||||
|
|
Loading…
Reference in New Issue