-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomescreen.cpp
More file actions
95 lines (79 loc) · 2.47 KB
/
Copy pathHomescreen.cpp
File metadata and controls
95 lines (79 loc) · 2.47 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
#include <fstream>
#include <iostream>
#include <stdlib.h>
#include <GL/glut.h> // GLUT, include glu.h and gl.h
#include <stdio.h>
#include <cwchar>
using namespace std;
//INIT function
void init()
{
// glClearColor(0.0, 0.0, 0.0, 0.0);
//glMatrixMode(GLUT_SINGLE | GLUT_RGB);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glOrtho(-90.0, 100.0, -15.0, 100.0, 0.0, 1.0);
}
void renderbitmap(float x, float y, void *font, char *string){
// glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
//glClear(GL_COLOR_BUFFER_BIT);
char *c;
glRasterPos2f(x,y);
for(c=string; *c !='\0';c++){
glutBitmapCharacter(font,*c);
}
}
//display function
void display()
{
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
char buf1[]="Hello! Welcome to Maze Runner!.";
renderbitmap(-80,40,GLUT_BITMAP_HELVETICA_18,buf1);
char buf2[]="Instructions: Use the arrow keys to move the player!";
renderbitmap(-80,30,GLUT_BITMAP_HELVETICA_18,buf2);
char buf3[]="Press Enter to start the game!. All the best!";
renderbitmap(-80,20,GLUT_BITMAP_HELVETICA_18,buf3);
glFlush();
// glutPostRedisplay();
}
//setting up intro introscreen
void specialkey(unsigned char key, int x, int y) {
//this part is a bit messy. the others need to contribute here. It's the enter key handler function.
switch(key) {
case 13:
//Insert CODE FOR STARTING THE GAME
glutIdleFunc(display);
//glBegin(GL_QUADS);
// Each set of 4 vertices form a quad
printf("\n");
glFlush();
//printf("up %f %f\n", xr, yr);
break;
default:
glFlush();
break;
}
//glutPostRedisplay();
//glFlush();
}
//Now we make renderbitmap
int width = 1024;
int height = 768;
int main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitWindowSize(400, 400);
glutInitWindowPosition(50, 50);
glutCreateWindow("Welcome to Maze Runner!"); // Create window with the given title
init();
glutDisplayFunc(display); // Register callback handler for window re-paint event
//initGL(); // Our own OpenGL initialization
//initGL();
glutIdleFunc(display); // on screen idle
glutKeyboardFunc(specialkey); // Our own OpenGL initialization
glutMainLoop(); // Enter the event-processing loop
return 0;
}