The tutorial assumes you've installed/compiled SFML2 and M.A.R.S. successfully:
Indiedb.com
First, navigate to the /src/ folder (it contains workable C++ files).
Then we'll head straight into the Weapons folder, and then open AFK47.cpp file.
Let's take a loot at this file. At the beginning there's a GPL licence, then files referenced/included by this particular weapon file.
Then we have AFK47::draw() function. It basically draws/shows the spaceship gun barrels in-game.
Farther down, we have another important function, AFK47::fire(), that spawns specific weapon's ammo (particles of the ammo, to be exact). We'll modify this weapon part a bit. ;-)
particles::spawn(particles::pAmmoAFK47, Vector2f(parent_->location().x_+(faceDirection.x_*parent_->radius()*0.9 - faceDirection.y_*parent_->radius()*0.9), parent_->location().y_+( faceDirection.x_*parent_->radius()*0.7 + faceDirection.y_*parent_->radius()*0.7)), faceDirection, parent_->velocity(), Color3f(), parent_->getOwner());
particles::spawn(particles::pAmmoAFK47, Vector2f(parent_->location().x_+(faceDirection.x_*parent_->radius()*0.9 + faceDirection.y_*parent_->radius()*0.9), parent_->location().y_+(-faceDirection.x_*parent_->radius()*0.7 + faceDirection.y_*parent_->radius()*0.7)), faceDirection, parent_->velocity(), Color3f(), parent_->getOwner());
You don't see a difference between the two lines? How about this tiny fragment:
parent_->location().y_+( faceDirection.x_*parent_->radius()*0.7 + faceDirection.y_*parent_->radius()*0.7))
parent_->location().y_+(-faceDirection.x_*parent_->radius()*0.7 + faceDirection.y_*parent_->radius()*0.7))
faceDirection.x
-faceDirection.x
(the second one is a negative value, -faceDirection.x)
So what will we do? We'll simply double the trouble AFK47 weapon does to opponents. Before:
particles::spawn(particles::pAmmoAFK47, Vector2f(parent_->location().x_+(faceDirection.x_*parent_->radius()*0.9 - faceDirection.y_*parent_->radius()*0.9), parent_->location().y_+( faceDirection.x_*parent_->radius()*0.7 + faceDirection.y_*parent_->radius()*0.7)), faceDirection, parent_->velocity(), Color3f(), parent_->getOwner());
Paste:
particles::spawn(particles::pAmmoAFK47, Vector2f(parent_->location().x_+(faceDirection.x_*parent_->radius()*0.7 - faceDirection.y_*parent_->radius()*0.7), parent_->location().y_+( faceDirection.x_*parent_->radius()*0.5 + faceDirection.y_*parent_->radius()*0.5)), faceDirection, parent_->velocity(), Color3f(), parent_->getOwner());
And before:
particles::spawn(particles::pAmmoAFK47, Vector2f(parent_->location().x_+(faceDirection.x_*parent_->radius()*0.9 + faceDirection.y_*parent_->radius()*0.9), parent_->location().y_+(-faceDirection.x_*parent_->radius()*0.7 + faceDirection.y_*parent_->radius()*0.7)), faceDirection, parent_->velocity(), Color3f(), parent_->getOwner());
Paste the code for the fourth particle spawner:
particles::spawn(particles::pAmmoAFK47, Vector2f(parent_->location().x_+(faceDirection.x_*parent_->radius()*0.7 + faceDirection.y_*parent_->radius()*0.7), parent_->location().y_+(-faceDirection.x_*parent_->radius()*0.5 + faceDirection.y_*parent_->radius()*0.5)), faceDirection, parent_->velocity(), Color3f(), parent_->getOwner());
Now the whole fire() function code should look something like:
void AFK47::fire() const {
float time = timer::totalTime();
if (time - timer_ > 0.1) {
timer_ = time;
float angleRad = parent_->rotation()*M_PI / 180;
Vector2f faceDirection(std::cos(angleRad), std::sin(angleRad));
particles::spawn(particles::pAmmoAFK47, Vector2f(parent_->location().x_+(faceDirection.x_*parent_->radius()*0.7 - faceDirection.y_*parent_->radius()*0.7), parent_->location().y_+( faceDirection.x_*parent_->radius()*0.5 + faceDirection.y_*parent_->radius()*0.5)), faceDirection, parent_->velocity(), Color3f(), parent_->getOwner());
particles::spawn(particles::pAmmoAFK47, Vector2f(parent_->location().x_+(faceDirection.x_*parent_->radius()*0.9 - faceDirection.y_*parent_->radius()*0.9), parent_->location().y_+( faceDirection.x_*parent_->radius()*0.7 + faceDirection.y_*parent_->radius()*0.7)), faceDirection, parent_->velocity(), Color3f(), parent_->getOwner());
particles::spawn(particles::pAmmoAFK47, Vector2f(parent_->location().x_+(faceDirection.x_*parent_->radius()*0.7 + faceDirection.y_*parent_->radius()*0.7), parent_->location().y_+(-faceDirection.x_*parent_->radius()*0.5 + faceDirection.y_*parent_->radius()*0.5)), faceDirection, parent_->velocity(), Color3f(), parent_->getOwner());
particles::spawn(particles::pAmmoAFK47, Vector2f(parent_->location().x_+(faceDirection.x_*parent_->radius()*0.9 + faceDirection.y_*parent_->radius()*0.9), parent_->location().y_+(-faceDirection.x_*parent_->radius()*0.7 + faceDirection.y_*parent_->radius()*0.7)), faceDirection, parent_->velocity(), Color3f(), parent_->getOwner());
sound::playSound(sound::Laser, parent_->location());
}
}
Okay, that's almost all, head to the /build/ folder and open up Terminal there, type:
make
A new version of M.A.R.S. - our own one - should be built. Type
cd .. && ./mars
or simply run the mars binary in the main M.A.R.S. folder.
And now, in-game:
Start Local Game -> DeathMatch (reduce the number of bots to 0) -> Weapon Options -> tick off all the Weapons options except AFK-47. Then Start, and if everything went well, you should see a quadrupled cannon ammo shot out instead of just the double one.