JNR
stageJR.h
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 #ifndef M_STAGEJR_H
30 #define M_STAGEJR_H
31 
33 
34 
40 
41 // N.Segs on the left and right side of the current one, that are rendered and animated
42 // TODO: this can be calculated based on the zoom
43 //
44 #define M_SEGMENT_RENDER_MARGIN 2
45 #define M_SEGMENT_ANIMATE_MARGIN 1
46 
47 // Default camera properties
48 //
49 #define M_CAMERA_ROT_SPEED 50 // degrees/sec
50 #define M_CAMERA_ROT_MUL 0.8
51 #define M_CAMERA_DIRECTIONAL_ANGLE 25 // angle added in the facing dir
52 #define M_CAMERA_LIMIT 40 // max angle
53 
54 class stageJR: public laStage
55 {
56 protected:
57 
58  // Game objects
59  //
60  JR_Objects *_pGame;
61 
62  // Track the player's current location
63  //
64  int _nCrSeg;
65  laSegment* _pCrSeg;
66  laSegment* _pColFirstSeg, *_pDrawFirstSeg;
67  laCollisionDomain* _pColFirstDomain;
68  unsigned _nColDomains;
69 
70  double _dLeftInvisible;
71  double _dTopInvisible;
72 
73  // Camera properties
74  //
75  double _dCamAngY, _dCamRotSpeed, _dCamRotMul, _dCamDirAngle, _dCamLimit;
76 
77  // GUI
78  //
79  uiDesktop _uiDesktop;
80  uiMenu_JR* _pMenu;
81 
82 
83  // Message handlers
84  //
85  virtual void onInit();
86  virtual void onFini();
87  virtual void onFrame(laRenderer *pr, laInputManager *pi, laTimer *pt);
88 
89  virtual void onActivate();
90  virtual void onDeactivate();
91 
92  // Internal sub-routines
93  //
94  unsigned _update_segment();
95  void _setup_3d_camera(laRenderer *pr, laTimer *pt);
96  void _draw_level(laRenderer *pr, laTimer *pt);
97  void _animate_Dynamics(laInputManager *pi, laTimer *pt);
98 
99  virtual void _init_gui() = 0;
100  virtual void _draw_UI(laRenderer *pr, laTimer *pt) = 0;
101  virtual void _animate(laInputManager *pi, laTimer *pt) = 0;
102 
103 public:
104  stageJR();
105  ~stageJR(void);
106 
107  void setGameObjects(JR_Objects *pobj)
108  {
109  ASSERT(!_pGame, "Old game objects are present, memory not discarded?");
110  _pGame = pobj;
111  MLOG("New game objects provided");
112  }
113 
114 };
116 #endif
JR Main Menu, and in-game Menu.
Definition: uiMenu_JR.h:43
Terrain Semgnet.
Definition: laSegment.h:48
Collision Domain.
Base Class for Stages.
Definition: laStage.h:48
GUI Topmost Window.
Definition: uiDesktop.h:44
Virtual interface for the Engine graphics renderer.
Definition: laRenderer.h:98
Level objects to be created during the Loading stage.
Definition: JR_Objects.h:39