forked from rtpHarry/Sokoban
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_Main_File.cpp
140 lines (105 loc) · 4.26 KB
/
_Main_File.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
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
134
135
136
137
138
139
140
#define WIN32_LEAN_AND_MEAN
#include <windows.h> // Header File For Windows
#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
#include "GLee.h"
//#include <gl\GLee.h> // gl extension loader [gl.h is included with this]
//#include <gl\gl.h> // OpenGL library
//#include <gl\glu.h> // OpenGL utility library
#include <il\il.h> // DevIL Image Library
#include <il\ilu.h>
#include <il\ilut.h>
#include <al\alut.h> // OpenAL wrapper/utility library
#include "NeHeGL.h" // Header File For NeHeGL
#ifdef _MSC_VER
#pragma comment( lib, "opengl32.lib" ) // Search For OpenGL32.lib While Linking
#pragma comment( lib, "glu32.lib" ) // Search For GLu32.lib While Linking
//#pragma comment( lib, "glaux.lib" ) // Search For GLu32.lib While Linking
#pragma comment( lib, "winmm.lib" ) // Search For WinMM Library While Linking
#pragma comment( lib, "devil.lib" ) // DevIL Image Library
#pragma comment( lib, "ilut.lib" ) // DevIL Image Library
#pragma comment( lib, "ilu.lib" ) // DevIL Image Library
#pragma comment( lib, "openal32.lib" ) // OpenAL library
#pragma comment( lib, "alut.lib" ) // OpenAL wrapper/utility library
#endif
#ifdef _DEBUG
#define IL_DEBUG
#endif //_DEBUG
#ifndef CDS_FULLSCREEN // CDS_FULLSCREEN Is Not Defined By Some
#define CDS_FULLSCREEN 4 // Compilers. By Defining It This Way,
#endif // We Can Avoid Errors
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
}