-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlock.cpp
More file actions
54 lines (42 loc) · 873 Bytes
/
Block.cpp
File metadata and controls
54 lines (42 loc) · 873 Bytes
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
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include "Block.h"
#include "Rectangle.h"
#include "Color.h"
#include <iostream>
#include <ctime>
#include <random>
Block::Block(float x, float y, float width, float height, Color c, bool destr, int _hp): GameObject(x, y),
Rectangle(x, y, width, height), Point(x, y), color(c), destructible(destr), hp(_hp)
{
}
void Block::Tick()
{
}
void Block::Render()
{
glColor3ub(color.r, color.g, color.b);
color.r = (color.r+rand()%40)%255;
color.g = (color.g+rand()%40)%255;
color.b = (color.b+rand()%40)%255;
glRectf(x*SCALE, y*SCALE, (x+width)*SCALE, (y+height)*SCALE);
}
void Block::Keyboard(int key)
{
}
void Block::SpecialKeyboard(int key)
{
}
bool Block::IsDestructible() const
{
return destructible;
}
int Block::GetHp() const
{
return hp;
}
void Block::SetHp(int _hp)
{
hp = _hp;
}