-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game.txt
71 lines (56 loc) · 1.71 KB
/
Game.txt
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
#include<Windows.h>
#include<gl/GL.h>
#include<gl/glut.h>
#include <iostream>
#include <GL/glut.h>
#include <math.h>
using namespace std;
void myInit(void)
{
glClearColor(0.95, 0.94, 0.49, 0.0);
glPointSize(4.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 640, 0.0, 480);
}
void DrawCircle(float cx, float cy, float r, int num_segments , float R,float G,float B)
{
glBegin(GL_POLYGON);
glColor3f(R, G, B);
for (int ii = 0; ii < num_segments; ii++)
{
float theta = 2.0f * 3.1415926f * float(ii) / float(num_segments);//get the current angle
float x = r * cosf(theta);//calculate the x component
float y = r * sinf(theta);//calculate the y component
glVertex2f(x + cx, y + cy);//output vertex
}
glEnd();
}
void DrawRecti(float x1, float y1, float x2, float y2 , float R, float G, float B) {
glColor3f(R, G, B);
glRecti(x1, y1, x2, y2);
}
void Game() {
glClear(GL_COLOR_BUFFER_BIT);
DrawCircle(320, 290, 180, 50 , 0.94, 0.36, 0.37);
DrawRecti(500, 290, 140, 100, 0.94, 0.36, 0.37);
DrawCircle(180, 100, 40, 50, 0.94, 0.36, 0.37);
DrawCircle(320, 100, 40, 50, 0.94, 0.36, 0.37);
DrawCircle(460, 100, 40, 50, 0.94, 0.36, 0.37);
DrawCircle(400, 280, 50, 50, 1.0, 1.0, 1.0);//EyesWhite
DrawCircle(400, 280, 25, 50, 0.20, 0.20, 0.60);//Eyes
DrawCircle(240, 280, 50, 50, 1.0, 1.0, 1.0);//EyesWhite
DrawCircle(240, 280, 25, 50, 0.20, 0.20, 0.60);//Eyes
glFlush();
}
void main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(640, 480);
glutInitWindowPosition(50, 50);
glutCreateWindow("Game");
glutDisplayFunc(Game);
myInit();
glutMainLoop();
}