-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloud.cpp
66 lines (56 loc) · 1.16 KB
/
cloud.cpp
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
//
// cloud.cpp
// Assignment4
//
// Created by Lawrie Cate on 03/09/2016.
// Copyright © 2016 CarlaAndLawrie. All rights reserved.
//
#include "cloud.hpp"
Cloud::Cloud(float _x, float _y, float _size)
{
x = _x;
y = _y;
size = _size;
}
Cloud::~Cloud( void )
{
}
void Cloud::draw( void )
{
glColor3f(1.0f, 1.0f, 1.0f);
this->drawCircle((x+0.2f),y,0.3f);
this->drawCircle((x+0.5f),y,0.3f);
this->drawCircle((x+0.35f),(y+0.25f),0.25f);
}
void Cloud::drawCircle(float _x,float _y, float _size)
{
float x,y,size;
x=_x;
y=_y;
size = _size;
GLint circleParts = 50;
// draws circle with given number of points
glBegin(GL_POLYGON);
int counter = 0;
for(int i =0; i <= 360; i += 360/circleParts)
{
counter++;
if(counter == 2)
{
counter =0;
i-= 360/circleParts;
glVertex3f(x, y,-0.5f);
}
float rad = 0.017453f * (float)i;
glVertex3f((size*cosf(rad))+x, (size*sinf(rad))+y,-0.5f);
}
glScalef(size,size,size);
glEnd();
}
void Cloud::move(void)
{
x+=0.005f;
if(x>=4.0f) {
x = -4.0f;
}
}