forked from rtpHarry/Sokoban
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_Main_File.cpp
More file actions
133 lines (100 loc) · 3.28 KB
/
Copy path_Main_File.cpp
File metadata and controls
133 lines (100 loc) · 3.28 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// 跨平台的头文件包含
#include <stdio.h> // Header File For Standard Input / Output
#include <stdarg.h> // Header File For Variable Argument Routines
#include <math.h> // Header File For Math Operations
// OpenGL 相关头文件
#include "GLee.h"
// DevIL 图像库头文件
#ifdef _WIN32
#include <il\il.h>
#include <il\ilu.h>
#include <il\ilut.h>
#else
#include <IL/il.h>
#include <IL/ilu.h>
#include <IL/ilut.h>
#endif
// OpenAL 音频库头文件
#ifdef _WIN32
#include <al\alut.h>
#else
#include <AL/alut.h>
#endif
#include "NeHeGL.h" // Header File For NeHeGL
#ifdef _DEBUG
#define IL_DEBUG
#endif //_DEBUG
GL_Window* g_window;
Keys* g_keys;
CCamera* g_camera;
char appTitle[] = "Sokoban by rtp|software"; //stores the window title
int screenInfo[3] = {1024,768,32}; //stores resolution and color bits (w,h,bpp)
// User Defined Variables
//#include "FontGL.h"
#include "SokobanApp.h"
SokobanApp Sokoban;
BOOL Initialize (GL_Window* window, Keys* keys, CCamera* camera) // Any OpenGL Initialization Goes Here
{
g_window = window;
g_keys = keys;
g_camera = camera;
// setup the sokoban application
//////////////////////////////////////////////////////////////////////////
Sokoban.Setup();
//////////////////////////////////////////////////////////////////////////
return TRUE; // Return TRUE (Initialization Successful)
}
void Deinitialize (void) // Any User DeInitialization Goes Here
{
// shut down the sokoban application
//////////////////////////////////////////////////////////////////////////
Sokoban.Destroy();
}
//handles keyboard processing
void ProcessKeys(void)
{
// debug keys
//////////////////////////////////////////////////////////////////////////
if (g_keys->keyDown[VK_F4]) { ToggleFullscreen (g_window); }
if (g_keys->keyDown[VK_F11]) { g_camera->ToggleMouseControl(); g_keys->keyDown[VK_F11] = FALSE; }
if (g_keys->keyDown[VK_F12]) { g_camera->DEBUG_WritePositionToFile(); g_keys->keyDown[VK_F12] = FALSE; }
// pass all pressed keys into the
for(int index = 0; index <= 256; index++)
{
if(g_keys->keyDown[index])
{
Sokoban.KeyPressed((char) index);
g_keys->keyDown[index] = false;
}
}
}
void Update(void) // Perform Motion Updates Here
{
// Color fading background
//////////////////////////////////////////////////////////////////////////
/*
static float color = 0.0f;
static float color2 = 0.3f;
color += 0.0005f;
color2 += 0.00005f;
if (color > 0.5f) {color = 0.0f; color2 = 0.3f; }
//if (color2 > 0.7f) color = 0.3f;
glClearColor(0.0f, color, color2, 0.0f);
*/
//////////////////////////////////////////////////////////////////////////
ProcessKeys();
// update sound
//////////////////////////////////////////////////////////////////////////
SokobanSoundManager::Instance().Update();
g_camera->Update();
}
void DrawScene(void) // Draw Our Scene
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
glLoadIdentity(); // Reset The Modelview Matrix
g_camera->Look();
//////////////////////////////////////////////////////////////////////////
Sokoban.Render();
//////////////////////////////////////////////////////////////////////////
glFlush(); // Flush The GL Rendering Pipeline
}