-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbitUser.cpp
More file actions
115 lines (95 loc) · 2.84 KB
/
Copy pathbitUser.cpp
File metadata and controls
115 lines (95 loc) · 2.84 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
//
// Created by Filip Skulimowski on 12/8/22.
//
#include "bitUser.h"
#include <fstream>
#include <iostream>
#include "graphics.h"
#include "shape.h"
const int SIDE_LENGTH = 10;
/********************* Shape Class *********************/
bitUser::bitUser() : Shape(), startingPoint({0, 0}) {
}
bitUser::bitUser(point2D start) : Shape(start), startingPoint(start) {
}
point2D bitUser::getStartingPoint() const {
return startingPoint;
}
double bitUser::getStartingX() const {
return startingPoint.x;
}
double bitUser::getStartingY() const {
return startingPoint.y;
}
double bitUser::getLeftX() const {
return startingPoint.x;
}
double bitUser::getRightX() const {
return startingPoint.x;
}
double bitUser::getTopY() const {
return startingPoint.y;
}
double bitUser::getBottomY() const {
return startingPoint.y;
}
void bitUser::setStartingPoint(point2D startingPoint) {
this->startingPoint = startingPoint;
}
void bitUser::setStartingPoint(double x, double y) {
startingPoint = {x, y};
}
void bitUser::setStartingX(double x) {
startingPoint.x = x;
}
void bitUser::setStartingY(double y) {
startingPoint.y = y;
}
void bitUser::move(double deltaX, double deltaY) {
startingPoint.x += deltaX;
startingPoint.y += deltaY;
}
void bitUser::moveX(double deltaX) {
startingPoint.x += deltaX;
}
void bitUser::moveY(double deltaY) {
startingPoint.y += deltaY;
}
void bitUser::draw() const {
double xCoord = getStartingX();
double yCoord = getStartingY();
ifstream inFile(fileName);
inFile >> noskipws;
char letter;
bool draw;
while (inFile >> letter) {
draw = true;
switch(letter) {
case 'r': glColor3f(1, 0, 0); break;
case 'g': glColor3f(0.00392157, 0.670588, 0); break;
case 'l': glColor3f(0.772549, 0.960784, 0.321568); break;
case 'b': glColor3f(0, 0, 1); break;
case 'y': glColor3f(0.9254902, 0.81960784, 0.70980392); break; // YELLOWISH/BROWN
case 'm': glColor3f(1, 0, 1); break; // MAGENTA
case 'c': glColor3f(0, 1, 1); break;
case 'o': glColor3f(0.9, 0.8, 0.3); break;
case 'w': glColor3f(0.84313725, 0.40784314, 0.18039216); break; // BROWN
case 'x': glColor3f(0.35, 0.51176, 0.94705); break; // LIGHT BLUE (SKY)
case ' ': glColor3f(0, 0, 0); break;
default: // newline
draw = false;
xCoord = getStartingX();
yCoord += SIDE_LENGTH;
}
if (draw) {
glBegin(GL_QUADS);
glVertex2i(xCoord, yCoord);
glVertex2i(xCoord+SIDE_LENGTH, yCoord);
glVertex2i(xCoord+SIDE_LENGTH, yCoord+SIDE_LENGTH);
glVertex2i(xCoord, yCoord+SIDE_LENGTH);
glEnd();
xCoord += SIDE_LENGTH;
}
}
inFile.close();
}