From 70ea8877ace50d2ce609d7d5f721c887b0ea83ec Mon Sep 17 00:00:00 2001 From: Logan Hunt Date: Wed, 12 Aug 2020 14:13:50 -0600 Subject: Added files --- src/rifle.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/rifle.cpp (limited to 'src/rifle.cpp') diff --git a/src/rifle.cpp b/src/rifle.cpp new file mode 100644 index 0000000..355d42f --- /dev/null +++ b/src/rifle.cpp @@ -0,0 +1,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 + +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; + } +} -- cgit v1.2.3-70-g09d2