From a85e6c544912b9ebd261b5da29b26e3232284173 Mon Sep 17 00:00:00 2001 From: Eugenio Favalli Date: Mon, 11 Apr 2005 12:10:36 +0000 Subject: - First step toward syncing attack animation with attack speed - Added a nice sample when attacking to stress test sound engine/ loading samples through resource manager. --- src/being.cpp | 2 +- src/being.h | 1 + src/engine.cpp | 27 ++++++++++++++++++--------- src/game.cpp | 19 +++++++++++-------- 4 files changed, 31 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/being.cpp b/src/being.cpp index d2bf85d5..3411d5c7 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -121,7 +121,7 @@ void sort() { } Being::Being(): - speech_time(0), + speech_time(0), aspd(350), damage(""), damage_time(0), id(0), job(0), x(0), y(0), destX(0), destY(0), direction(0), diff --git a/src/being.h b/src/being.h index 6748732e..173b1d3c 100644 --- a/src/being.h +++ b/src/being.h @@ -64,6 +64,7 @@ class Being { unsigned int speech_time; unsigned int damage_time; bool showSpeech, showDamage; + unsigned short aspd; // attack speed /** * Constructor. diff --git a/src/engine.cpp b/src/engine.cpp index 940bac79..2dca09e2 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -265,14 +265,23 @@ void Engine::logic() Being *being = (*beingIterator); if (being->job < 10) { // A player - if (being->action != STAND && being->action != SIT - && being->action != DEAD) { - being->frame = - (get_elapsed_time(being->walk_time) * 4) / (being->speed); - - if (being->frame >= 4) { - being->nextStep(); - } + switch (being->action) { + case WALK: + being->frame = (get_elapsed_time(being->walk_time) * 4) / + (being->speed); + if (being->frame >= 4) { + being->nextStep(); + } + break; + case ATTACK: + being->frame = (get_elapsed_time(being->walk_time) * 4) / + (being->aspd); + if (being->frame >= 4) { + being->nextStep(); + } + break; + default: + break; } } @@ -493,7 +502,7 @@ void Engine::draw() std::stringstream debugStream; debugStream << "[" << fps << " fps] " << (mouseX / 32 + camera_x) << ", " << (mouseY / 32 + camera_y) << " " - << (int)player_node->frame; + << player_node->aspd; debugInfo->setCaption(debugStream.str()); debugInfo->adjustSize(); } diff --git a/src/game.cpp b/src/game.cpp index fdd8899e..30eb5f29 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -224,12 +224,8 @@ void do_input() } else if ((keysym.sym == SDLK_F7)) { - /*SOUND_SID id = sound.loadItem("data/sfx/fist-swish.ogg"); - sound.startItem(id, 120);*/ - ResourceManager *resman = ResourceManager::getInstance(); - SoundEffect *sample = resman->getSoundEffect( - "sfx/fist-swish.ogg"); - sample->play(0, 120); + SOUND_SID id = sound.loadItem("data/sfx/fist-swish.ogg"); + sound.startItem(id, 120); } // Emotions, Skill dialog @@ -365,7 +361,7 @@ void do_input() } else { // Search for player character to trade with - /* + id = find_pc(mx, my); if (id != 0) { // Begin a trade @@ -373,7 +369,6 @@ void do_input() WFIFOL(2) = net_l_value(id); WFIFOSET(6); } - */ } @@ -537,6 +532,11 @@ void do_input() player_node->y, player_node->direction); player_node->walk_time = tick_time; + + ResourceManager *resman = ResourceManager::getInstance(); + SoundEffect *sample = resman->getSoundEffect( + "sfx/fist-swish.ogg"); + sample->play(0, 120); } } @@ -1017,6 +1017,9 @@ void do_parse() { sprintf(points, "b0 0x0009 %i", RFIFOL(4)); chatWindow->chat_log(points, BY_SERVER);*/ break; + case 0x0035: + player_node->aspd = RFIFOW(4); + break; default: /*char unknown[20]; sprintf(unknown, "b0 %x %i", RFIFOW(2),RFIFOL(4)); -- cgit v1.2.3-70-g09d2