JNR
entry_win.cpp
1 /*
2 
3 Jump'n'Run Engine
4 http://www.atanaslaskov.com/jnr/
5 
6 BSD LICENSE
7 Copyright (c) 2007-2013, Atanas Laskov
8 All rights reserved.
9 
10 Redistribution and use in source and binary forms, with or without
11 modification, are permitted provided that the following conditions are met:
12 1. Redistributions of source code must retain the above copyright notice,
13 this list of conditions and the following disclaimer.
14 2. Redistributions in binary form must reproduce the above copyright notice,
15 this list of conditions and the following disclaimer in the documentation
16 and/or other materials provided with the distribution.
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL ATANAS LASKOV BE LIABLE FOR ANY
21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 */
29 
30 #define _CRT_SECURE_NO_DEPRECATE
31 
32 #include <jnr.h>
33 
34 int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR lpCmdLine, int )
35 {
36  laSystemIntegrator Integrator;
37 
38  //Load Game Settings
39  Integrator.createSettings(new laSettings());
40 
41  //Create OS Environment
42  Integrator.createEnvironment(new laEnvironment_win32());
43  Integrator.getEnvironment()->setTitle("Loading...");
44  Integrator.getEnvironment()->message(M_TRUE, "Environment initialized");
45 
46  try
47  {
48  //Create Renderer
49  Integrator.createRenderer(new laRenderer_GL());
50  Integrator.getEnvironment()->message(M_TRUE, "Renderer initialized");
51 
52  //Create Input Subsystem
53  Integrator.createInput(new laInputManager);
54  Integrator.getEnvironment()->message(M_TRUE, "Input devices initialized");
55 
56  //Create Sound Subsystem
57  Integrator.createSound(new laSoundManager);
58  Integrator.getEnvironment()->message(M_TRUE, "Sound device initialized");
59 
60  //Create a Game Object
61  laGame* pGame = new laGame();
62 
63  pGame->addStage(new stageJRMenu());
64  pGame->addStage(new stageLoad());
65  pGame->addStage(new stageJRGame());
66  pGame->addStage(new stageEdit());
67  pGame->addStage(new stageIntro());
68 
69  pGame->addStage(new stageModelViewer());
70  pGame->addStage(new stageCollisionTests());
71 
72  pGame->setStage((unsigned)1);
73  //pGame->setStage((unsigned)7);
74 
75  Integrator.createGame(pGame);
76  Integrator.getEnvironment()->message(M_TRUE, "Game initialized");
77 
78  //Run game loop
79  Integrator.getEnvironment()->message(M_TRUE, "Entering game loop");
80  Integrator.getEnvironment()->loop();
81 
82  //Terminate Game
83  Integrator.getEnvironment()->message(M_TRUE, "Game terminated, starting cleanup");
84  Integrator.discard();
85  Integrator.getEnvironment()->message(M_TRUE, "Bye.");
86 
87  return 0;
88 
89  }catch(laError& error)
90  {
91  //Report error
92  Integrator.getEnvironment()->message(M_FALSE,
93  "The following error has occured:\n\n %s",
94  error.getText());
95  return 1;
96  }
97 }
Collection of laStage objects.
Definition: laGame.h:47
virtual void message(M_BOOL bSilent, const char *strText,...)=0
Display message box.
JR Gameplay Stage.
Definition: stageJRGame.h:41
Level Editor Stage.
Definition: stageEdit.h:120
Game Settings.
Definition: laSettings.h:38
Level Loading Stage.
Definition: stageLoad.h:38
Main Menu Stage.
Definition: stageJRMenu.h:63
Engine Sub-systems Integrator.
Error handling class.
Definition: laError.h:46