summaryrefslogtreecommitdiff
path: root/src/rifle.cpp
blob: 355d42fcb496d874d56a9ce61c2d6b66c25a5be5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*************************************************************
 * File: rifle.cpp
 * Author: Br. Burton
 *
 * Description: Contains the function bodies for the rifle class.
 *
 * Please DO NOT share this code with other students from
 *  other sections or other semesters. They may not receive
 *  the same code that you are receiving.
 *************************************************************/

#include "rifle.h"
#include "point.h"
#include "uiDraw.h"

#include <cassert>

void Rifle :: draw() const
{
   assert(angle >= ANGLE_MIN);
   assert(angle <= ANGLE_MAX);
   
   drawRect(point, RIFLE_WIDTH, RIFLE_HEIGHT, 90 - angle);
}

void Rifle :: moveLeft()
{
   angle -= RIFLE_MOVE_AMOUNT;

   if (angle < ANGLE_MIN)
   {
      angle = ANGLE_MIN;
   }
}


void Rifle :: moveRight()
{
   angle += RIFLE_MOVE_AMOUNT;
   
   if (angle > ANGLE_MAX)
   {
      angle = ANGLE_MAX;
   }
}