bugfixes less log messages

- fixed sudden acceleration of asteroids (wrong order of collision handling
	and resolving)
main
Martin Felis (berta) 2011-02-12 16:34:47 +01:00
parent 57ea0596b8
commit ce66a791af
7 changed files with 26 additions and 22 deletions

View File

@ -35,20 +35,19 @@ bool Controller::OnReceiveEvent (const Engine::EventBasePtr &event) {
void Controller::ResetPlayerEntity () { void Controller::ResetPlayerEntity () {
Engine::HaltSoundLoop(Engine::GetResourceFullPath("/data/sounds/thrust.wav")); Engine::HaltSoundLoop(Engine::GetResourceFullPath("/data/sounds/thrust.wav"));
// We definitely have to reset the player entity id // Reset the angular velocity of the player entity if one exists
GetModel()->SetPlayerEntityId(Engine::NullEntityId); if (GetModel()->GetPlayerEntityId() != Engine::NullEntityId) {
Engine::EntityBase *player_entity = GetModel()->GetEntity(GetModel()->GetPlayerEntityId()); Engine::EntityBase *player_entity = GetModel()->GetEntity(GetModel()->GetPlayerEntityId());
player_entity->mPhysicState->mAngleVelocity = 0.;
// if we were unable to get the player then there is no need to invalidate
// the state
if (!player_entity)
return;
int i; int i;
for (i = 0; i < EntityControllerMaxKeyStates; i++) for (i = 0; i < EntityControllerMaxKeyStates; i++)
player_entity->UnsetControllerKeyState(i); player_entity->UnsetControllerKeyState(i);
}
// We definitely have to reset the player entity id
GetModel()->SetPlayerEntityId(Engine::NullEntityId);
} }
void Controller::ResetLevel() { void Controller::ResetLevel() {

View File

@ -263,6 +263,8 @@ int Model::DoLoadLevel (const char* filename) {
std::string entity_type_str; std::string entity_type_str;
int entity_count = 0; int entity_count = 0;
SetLevelTitle ("");
SetLevelAuthor ("");
while (level_file >> entity_type_str) { while (level_file >> entity_type_str) {
if (entity_type_str[0] == '#') { if (entity_type_str[0] == '#') {

View File

@ -37,19 +37,19 @@ class Model : public Engine::ModelBase {
std::string GetLevelName() { return mLevelName; }; std::string GetLevelName() { return mLevelName; };
void SetLevelName(const std::string &name) { void SetLevelName(const std::string &name) {
Engine::LogMessage("new level name: %s", name.c_str()); Engine::LogDebug("new level name: %s", name.c_str());
mLevelName = name; mLevelName = name;
} }
std::string GetLevelAuthor() { return mLevelAuthor; }; std::string GetLevelAuthor() { return mLevelAuthor; };
void SetLevelAuthor(const std::string &author) { void SetLevelAuthor(const std::string &author) {
Engine::LogMessage("new level author: %s", author.c_str()); Engine::LogDebug("new level author: %s", author.c_str());
mLevelAuthor = author; mLevelAuthor = author;
} }
std::string GetLevelTitle() { return mLevelTitle; }; std::string GetLevelTitle() { return mLevelTitle; };
void SetLevelTitle(const std::string &title) { void SetLevelTitle(const std::string &title) {
Engine::LogMessage("new level title: %s", title.c_str()); Engine::LogDebug("new level title: %s", title.c_str());
mLevelTitle = title; mLevelTitle = title;
} }

View File

@ -107,7 +107,7 @@ void ShipEntity::Attack () {
RocketEntity *rocket_entity = (RocketEntity*) Engine::CreateEntity (GameEntityTypeRocket); RocketEntity *rocket_entity = (RocketEntity*) Engine::CreateEntity (GameEntityTypeRocket);
rocket_entity->mSecToLive = 1.75; rocket_entity->mSecToLive = 1.5;
RocketEntityPhysicState *rocket_physics = (RocketEntityPhysicState*) rocket_entity->mPhysicState; RocketEntityPhysicState *rocket_physics = (RocketEntityPhysicState*) rocket_entity->mPhysicState;
rocket_physics->mPosition = attack_dir; rocket_physics->mPosition = attack_dir;

View File

@ -999,7 +999,7 @@ void View::DrawUiEditor() {
GetModel()->SetLevelTitle(level_title); GetModel()->SetLevelTitle(level_title);
if (Engine::GUI::Button (55, "Save", 145, 380, button_width, button_height)) { if (Engine::GUI::Button (55, "Save", 145, 380, button_width, button_height)) {
GetModel()->DoSaveLevel((level_name + std::string(".txt")).c_str()); GetModel()->DoSaveLevel((level_name + std::string(".map")).c_str());
Engine::LogMessage ("Save"); Engine::LogMessage ("Save");
mEditorState = EditorStateUnknown; mEditorState = EditorStateUnknown;
} }
@ -1021,9 +1021,9 @@ void View::DrawUiEditor() {
if (Engine::GUI::LineEdit(52, 145, 210, level_name, 32)) if (Engine::GUI::LineEdit(52, 145, 210, level_name, 32))
GetModel()->SetLevelName(level_name); GetModel()->SetLevelName(level_name);
if (Engine::FileExists (level_name + std::string(".txt"))) { if (Engine::FileExists (level_name + std::string(".map"))) {
if (Engine::GUI::Button (54, "Load", 145, 300, button_width, button_height)) { if (Engine::GUI::Button (54, "Load", 145, 300, button_width, button_height)) {
GetModel()->DoLoadLevel((level_name + std::string(".txt")).c_str()); GetModel()->DoLoadLevel((level_name + std::string(".map")).c_str());
Engine::LogMessage ("Load"); Engine::LogMessage ("Load");
mEditorState = EditorStateUnknown; mEditorState = EditorStateUnknown;
} }

View File

@ -105,6 +105,9 @@ int main (int argc, char* argv[]) {
ShowWindow( hWnd, SW_HIDE ); ShowWindow( hWnd, SW_HIDE );
#endif #endif
create_dir ("./root");
create_dir ("./root/blaa");
Engine::Engine engine; Engine::Engine engine;
engine.SetEntityFactory (new asteroids::EntityFactory); engine.SetEntityFactory (new asteroids::EntityFactory);

View File

@ -107,12 +107,12 @@ int PhysicsBase::Simulate (float msec, ModelBase* model) {
// collision_remaining_step -= 1.0e-4; // collision_remaining_step -= 1.0e-4;
} else { } else {
Move (info.time * (1 - alpha)); Move (info.time * (1 - alpha));
LogDebug ("Resolving Step between %u and %u t = %f alpha = %f", entity_a_id, entity_b_id, info.time, alpha);
ResolveCollision (info.time * (1 - alpha), entity_a_id, entity_b_id, info);
// Send the collision event to the Model (if we have one) // Send the collision event to the Model (if we have one)
if (model) { if (model) {
model->SendEntityCollisionEvent (entity_a_id, entity_b_id, info.time, info.point, info.normal); model->SendEntityCollisionEvent (entity_a_id, entity_b_id, info.time, info.point, info.normal);
} }
LogDebug ("Resolving Step between %u and %u t = %f alpha = %f", entity_a_id, entity_b_id, info.time, alpha);
ResolveCollision (info.time * (1 - alpha), entity_a_id, entity_b_id, info);
collision_remaining_step -= info.time * (1 - alpha); collision_remaining_step -= info.time * (1 - alpha);
} }