This repository has been archived on 2019-12-07. You can view files and clone it, but cannot push or open issues or pull requests.
dungeon-gunner/source/items/Weapon.cpp
Felix Ableitner 45f0b31d57 Initial commit after git corruption, old repo deleted.
Working:
Rendering
Resources
Physics
Player movement with mouse
Shooting with mouse
Tiles
2012-09-10 17:26:37 +02:00

38 lines
832 B
C++
Executable file

/*
* Weapon.cpp
*
* Created on: 12.08.2012
* Author: Felix
*/
#include "Weapon.h"
#include "../util/Collection.h"
#include "../effects/Bullet.h"
#include "../util/Loader.h"
#include "../util/ResourceManager.h"
Weapon::Weapon(Physical& holder, Collection& collection, b2World& world) :
Emitter(collection),
mHolder(holder),
mBulletTexture(ResourceManager::i().acquire(Loader::i().fromFile<sf::Texture>("bullet.png"))),
mWorld(world) {
}
Weapon::~Weapon() {
}
/**
* Call on any button press/refire.
*/
void
Weapon::fire() {
// Only call if has ammo, consider firing rate etc.
emit();
}
std::shared_ptr<Particle>
Weapon::createParticle() {
return std::shared_ptr<Particle>(new Bullet(mHolder.getPosition(), mWorld, mBulletTexture,
mHolder, mHolder.getAngle()));
}