Skip to content

Commit

Permalink
weapon without shell animation
Browse files Browse the repository at this point in the history
  • Loading branch information
5253450@gmail.com committed Jun 11, 2011
1 parent e6d852f commit 9641ad1
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/game/Powerup.cpp
Expand Up @@ -88,11 +88,11 @@ const std::string violetland::NukePowerup::getHudInfo() const {
void addExplosion(float x, float y, float damage, float range);
bool violetland::NukePowerup::modify(Game* game, Player* player) {
game->hud->addMessage(_("Boom!"));
addExplosion(player->X, player->Y, 12.0f, 400.0f);
addExplosion(X, Y, 12.0f, 400.0f);

game->resources->ExplSounds[1]->play(8, 0, 0);

Explosion * expl = new Explosion(true, player->X, player->Y,
Explosion * expl = new Explosion(true, X, Y,
400.0f, game->resources->ExplTex[0], game->resources->ExplTex[1]);
game->particleSystems.push_back(expl);

Expand Down
1 change: 1 addition & 0 deletions src/game/Weapon.cpp
Expand Up @@ -21,6 +21,7 @@ Weapon::Weapon(Texture* droppedTex, Texture* playerTex, Sound* shotSound,
m_reload = 0;
m_reloadSndCh = -1;
m_bulletTex = NULL;
ShellSprite = NULL;
}

void Weapon::process(int deltaTime) {
Expand Down
43 changes: 25 additions & 18 deletions src/game/WeaponManager.cpp
Expand Up @@ -83,32 +83,39 @@ WeaponManager::WeaponManager(FileUtility* fileUtility, SoundManager* sndManager)

in.close();

std::vector<SDL_Surface*> animSurfaces;
if (shellName != "no")
loadShellSprite(weapon, shellName);

boost::filesystem::path shellDir =
fileUtility->getFullPath(FileUtility::anima, "shells");
shellDir /= shellName;
unsigned framesCount =
fileUtility->getFilesCountFromDir(shellDir);
Weapons.push_back(weapon);
}

std::cout << "Shell animation of " << weapons[j] << " - " << shellName
<< ", frames count: " << framesCount << '.' << std::endl;
std::cout << "Loading of weapons is completed." << std::endl;
}

for (unsigned i = 0; i < framesCount; i++) {
std::ostringstream filename;
filename << i << ".png";
void WeaponManager::loadShellSprite(Weapon* _weapon, std::string& _shellName)
{
std::vector<SDL_Surface*> animSurfaces;

SDL_Surface *surface =
ImageUtility::loadImage(boost::filesystem::path(shellDir) /= filename.str());
boost::filesystem::path shellDir =
m_fileUtility->getFullPath(FileUtility::anima, "shells");
shellDir /= _shellName;
unsigned framesCount =
m_fileUtility->getFilesCountFromDir(shellDir);

animSurfaces.push_back(surface);
}
weapon->ShellSprite = new Sprite(animSurfaces);
std::cout << "Shell animation of " << _weapon->Name << " - " << _shellName
<< ", frames count: " << framesCount << '.' << std::endl;

Weapons.push_back(weapon);
for (unsigned i = 0; i < framesCount; i++) {
std::ostringstream filename;
filename << i << ".png";

SDL_Surface *surface =
ImageUtility::loadImage(boost::filesystem::path(shellDir) /= filename.str());

animSurfaces.push_back(surface);
}

std::cout << "Loading of weapons is completed." << std::endl;
_weapon->ShellSprite = new Sprite(animSurfaces);
}

Weapon* WeaponManager::getWeaponByName(std::string name) {
Expand Down
7 changes: 5 additions & 2 deletions src/game/WeaponManager.h
Expand Up @@ -9,12 +9,15 @@
namespace violetland {

class WeaponManager {
public:
private:
FileUtility* m_fileUtility;
SoundManager* m_sndManager;
public:
std::vector<Weapon*> Weapons;

WeaponManager(FileUtility* fileUtility, SoundManager* sndManager);
~WeaponManager();
std::vector<Weapon*> Weapons;
void loadShellSprite(Weapon* _weapon, std::string& _shellName);
Weapon* getWeaponByName(std::string name);
};

Expand Down
9 changes: 6 additions & 3 deletions src/game/lifeforms/Player.cpp
Expand Up @@ -116,9 +116,12 @@ std::vector<Bullet*>* Player::fire() {
if (m_weapon->BulletsAtOnce > 1)
AccuracyDeviation = 0;

DynamicObject* shell = new DynamicObject(X, Y, m_weapon->ShellSprite);
shell->Angle = m_arms->Angle;
m_shells.push_back(shell);
if (m_weapon->ShellSprite)
{
DynamicObject* shell = new DynamicObject(X, Y, m_weapon->ShellSprite);
shell->Angle = m_arms->Angle;
m_shells.push_back(shell);
}
}

return newBullets;
Expand Down
2 changes: 1 addition & 1 deletion weapon/Flamethrower/stats
@@ -1 +1 @@
3 9mm 80 0.005 50 2000 500 1.0 0 1 45 10
3 no 80 0.005 50 2000 500 1.0 0 1 45 10
2 changes: 1 addition & 1 deletion weapon/Laser/stats
@@ -1 +1 @@
1 9mm 5 1.5 500 1500 1500 0 0 1 40 -3
1 no 5 1.5 500 1500 1500 0 0 1 40 -3

0 comments on commit 9641ad1

Please sign in to comment.