-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathPlayer.cpp
More file actions
22 lines (21 loc) · 788 Bytes
/
Copy pathPlayer.cpp
File metadata and controls
22 lines (21 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "Player.h"
#include "Application.h"
#include "Missile.h"
#include "utilities.h"
Player::Player(Tank *val,const std::string& name) :
myTank(val),
playerName(name),
life(maxlife),
power(0.4)
{}
void Player::fire()
{
double phi = TO_RAD(myTank->turret.getRotation());
double sin = std::sin(phi) , cos = std::cos(phi);
double TankVelocity = power*500;
Missile *m=new Missile(myTank->turret.getPosition().x + myTank->turret.getLocalBounds().width * cos,
myTank->turret.getPosition().y + myTank->turret.getLocalBounds().width * sin);
m->setVelocity(TankVelocity * cos, TankVelocity * sin);
Application::getGame().addWorldObj(m);
Application::getMsgStream().sendMessage(Message("PlayerTurnOver"),"GameState");
}