Repository navigation
Expand file tree
/
Copy pathBindingOfObjects.cpp
More file actions
125 lines (104 loc) · 3.19 KB
/
Copy pathBindingOfObjects.cpp
File metadata and controls
125 lines (104 loc) · 3.19 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
/**
* @file BindingOfObjects.cpp
* @date 30-Nov-2025
*/
#define __SCROLL_IMPL__
#include "BindingOfObjects.h"
#undef __SCROLL_IMPL__
#include "Object.h"
#include "EnemyBug.h"
#include "Hero.h"
#include "orxExtensions.h"
#ifdef __orxMSVC__
/* Requesting high performance dedicated GPU on hybrid laptops */
__declspec(dllexport) unsigned long NvOptimusEnablement = 1;
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
#endif // __orxMSVC__
/** Update function, it has been registered to be called every tick of the core clock
*/
void BindingOfObjects::Update(const orxCLOCK_INFO &_rstClockInfo)
{
// Should quit?
if (orxInput_HasBeenActivated("Quit"))
{
// Send close event
orxEvent_SendShort(orxEVENT_TYPE_SYSTEM, orxSYSTEM_EVENT_CLOSE);
}
}
/** Camera Update function, it has been registered to be called every tick of the core clock, after physics & objects have been updated
*/
void BindingOfObjects::CameraUpdate(const orxCLOCK_INFO &_rstClockInfo)
{
// Get MainCamera proxy object
ScrollObject *poMainCamera = BindingOfObjects::GetInstance().GetObject("MainCamera");
if (poMainCamera)
{
// Update & move the camera here
// [...]
// Round its position
orxVECTOR vPosition;
poMainCamera->SetPosition(*orxVector_Round(&vPosition, &poMainCamera->GetPosition(vPosition)));
}
}
/** Init function, it is called when all orx's modules have been initialized
*/
orxSTATUS BindingOfObjects::Init()
{
// Init extensions
InitExtensions();
// Push [Main] as the default config section
orxConfig_PushSection("Main");
// Create the viewports
for (orxS32 i = 0, iCount = orxConfig_GetListCount("ViewportList"); i < iCount; i++)
{
orxViewport_CreateFromConfig(orxConfig_GetListString("ViewportList", i));
}
// Create the scene
CreateObject("Scene");
// Done!
return orxSTATUS_SUCCESS;
}
/** Run function, it should not contain any game logic
*/
orxSTATUS BindingOfObjects::Run()
{
// Return orxSTATUS_FAILURE to instruct orx to quit
return orxSTATUS_SUCCESS;
}
/** Exit function, it is called before exiting from orx
*/
void BindingOfObjects::Exit()
{
// Exit from extensions
ExitExtensions();
// Let orx clean all our mess automatically. :)
}
/** BindObjects function, ScrollObject-derived classes are bound to config sections here
*/
void BindingOfObjects::BindObjects()
{
// Bind the Object class
BindObject(Object);
// Bind the EnemyBug class to the O-EnemyBug config section
ScrollBindObject<EnemyBug>("O-EnemyBug");
// Bind the Hero class to the O-Hero config section
ScrollBindObject<Hero>("O-Hero");
}
/** Bootstrap function, it is called before config is initialized, allowing for early resource storage definitions
*/
orxSTATUS BindingOfObjects::Bootstrap() const
{
// Bootstrap extensions
BootstrapExtensions();
// Return orxSTATUS_FAILURE to prevent orx from loading the default config file
return orxSTATUS_SUCCESS;
}
/** Main function
*/
int main(int argc, char **argv)
{
// Execute our game
BindingOfObjects::GetInstance().Execute(argc, argv);
// Done!
return EXIT_SUCCESS;
}