Id: To index
Original: Legend
Status:
Mutant: Show

Testcases to display

Filter by kind

Filter by status

1:
#
ifndef
 
game_hpp
2:
#
define
 
game_hpp
3:
4:
#
include
 
"entity.h"
5:
#
include
 
"event.h"
6:
#
include
 
"mob.h"
7:
#
include
 
"mobsystem.h"
8:
#
include
 
"physics.h"
9:
#
include
 
"physicssystem.h"
10:
#
include
 
"rendersystem.h"
11:
#
include
 
"system.h"
12:
#
include
 
"util.h"
13:
#
include
 
"window.h"
14:
15:
#
include
 
<
deque
>
16:
#
include
 
<
memory
>
17:
#
include
 
<
string
>
18:
#
include
 
<
utility
>
19:
20:
class
 
Game
 
{
21:
public
:
22:    
Game
(
Window
&
 
window
)
;
23:    
void
 
setup
(
)
;
24:    
void
 
queueEvent
(
const
 
EvAny
&
 
ev
)
;
25:    
bool
 
update
(
)
;
26:    
void
 
render
(
)
;
27:
28:    
vec2i
 
worldCoord
(
vec2i
 
screenCoord
)
 
const
;
 
// Map screen point to world point
29:    
vec2i
 
screenCoord
(
vec2i
 
worldCoord
)
 
const
;
 
// Map world point to screen point
30:    
bool
 
onScreen
(
vec2i
 
worldCoord
)
 
const
;
31:
32:    
char
&
 
groundTile
(
vec2i
 
p
)
 
{
33:        
vec2i
 
q
{
p
.
x
 
-
 
worldBounds
.
left
,
 
worldBounds
.
top
 
-
 
p
.
y
}
;
34:        
return
 
groundTiles_
(
q
)
;
35:    
}
36:
37:
public
:
38:    
Window
&
 
window
;
39:    
recti
 
worldBounds
{
-
64
,
 
24
,
 
128
,
 
48
}
;
40:    
ident
 
player
{
invalid_id
}
;
41:    
vec2i
 
cameraPosition
{
0
,
 
0
}
;
42:    
vec2i
 
cameraTarget
{
0
,
 
0
}
;
43:
44:    
bool
 
cameraShake
 
=
 
false
;
45:    
int
 
cameraShakeTimer
 
=
 
0
;
46:    
int
 
cameraShakeStrength
 
=
 
2
;
47:    
vec2i
 
cameraShakeOffset
{
0
,
 
0
}
;
48:    
int
 
freezeTimer
 
=
 
0
;
49:
50:    
buffered_container
<
Entity
>
 
entities
;
51:    
buffered_container
<
Mob
>
 
mobs
;
52:    
buffered_container
<
Sprite
>
 
sprites
;
53:    
buffered_container
<
Physics
>
 
physics
;
54:
55:
protected
:
56:    
int
 
tick_
 
=
 
0
;
57:    
int
 
subTick_
 
=
 
0
;
58:
59:    
std
:
:
array
<
std
:
:
vector
<
EvAny
>
,
 
2
>
 
events_
{
}
;
60:    
int
 
eventsIndex_
 
=
 
0
;
61:
62:    
std
:
:
deque
<
std
:
:
pair
<
std
:
:
string
,
 
int
>>
 
log_
;
63:
64:    
Array2D
<
char
>
 
groundTiles_
;
65:
66:    
std
:
:
deque
<
WindowEvent
>
 
windowEvents_
;
67:
68:    
MobSystem
 
mobSystem_
;
69:    
PhysicsSystem
 
physicsSystem_
;
70:    
RenderSystem
 
renderSystem_
;
71:    
std
:
:
vector
<
System
*
>
 
systems_
{
72:        
&
mobSystem_
,
73:        
&
physicsSystem_
,
74:        
&
renderSystem_
,
75:    
}
;
76:
77:    
void
 
sync
(
)
;
78:    
void
 
handleInput
(
)
;
79:    
void
 
updatePlayer
(
)
;
80:    
void
 
updateCamera
(
)
;
81:
82:    
void
 
log
(
const
 
std
:
:
string
 
message
)
;
83:
84:    
// Factories
85:    
Sprite
&
 
createSprite
(
std
:
:
string
 
frames
,
 
bool
 
animated
,
 
int
 
frameRate
,
 
uint16_t
 
fg
,
 
uint16_t
 
bg
,
86:                         
vec2i
 
position
,
 
RenderLayer
 
layer
)
;
87:    
Mob
&
 
createMob
(
MobType
 
type
,
 
vec2i
 
position
)
;
88:    
void
 
createBloodSplatter
(
vec2i
 
position
)
;
89:    
void
 
createBones
(
char
 
c
,
 
vec2i
 
position
)
;
90:
}
;
91:
92:
#
endif