Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
labs
Laba_3
pacman
Commits
36f159c3
Commit
36f159c3
authored
2 weeks ago
by
Авдеев Евгений Владимирович
Browse files
Options
Download
Patches
Plain Diff
fireballs have flight direction
parent
392d7a81
main
No related merge requests found
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
source/Builder/Builders.cpp
+51
-51
source/Builder/Builders.cpp
source/Config/Config.h
+3
-1
source/Config/Config.h
source/Draw/Texture.cpp
+21
-2
source/Draw/Texture.cpp
source/Draw/Texture.h
+10
-2
source/Draw/Texture.h
source/Game/IEntity.cpp
+1
-1
source/Game/IEntity.cpp
source/Game/Pacman.cpp
+6
-2
source/Game/Pacman.cpp
source/Game/Pacman.h
+5
-5
source/Game/Pacman.h
source/Maze/Maze.cpp
+5
-5
source/Maze/Maze.cpp
source/Maze/Maze.h
+1
-1
source/Maze/Maze.h
source/State/States.cpp
+4
-4
source/State/States.cpp
source/main.cpp
+10
-41
source/main.cpp
with
117 additions
and
115 deletions
+117
-115
source/Builder/Builders.cpp
+
51
−
51
View file @
36f159c3
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
#include
<iostream>
#include
<iostream>
#include
"../Config/Config.h"
GameBuilderDirector
::
GameBuilderDirector
(
std
::
unique_ptr
<
IGameBuilder
>&&
ptr_builder
,
const
sf
::
VideoMode
&
mode
,
const
std
::
string
&
window_title
,
float
dynamic_objects_ratio
)
:
GameBuilderDirector
::
GameBuilderDirector
(
std
::
unique_ptr
<
IGameBuilder
>&&
ptr_builder
,
const
sf
::
VideoMode
&
mode
,
const
std
::
string
&
window_title
,
float
dynamic_objects_ratio
)
:
m_ptr_builder
(
std
::
move
(
ptr_builder
)),
m_mode
(
mode
),
m_window_title
(
window_title
),
m_dynamic_obj_ratio
(
dynamic_objects_ratio
)
{
m_ptr_builder
(
std
::
move
(
ptr_builder
)),
m_mode
(
mode
),
m_window_title
(
window_title
),
m_dynamic_obj_ratio
(
dynamic_objects_ratio
)
{
}
}
...
@@ -101,42 +101,42 @@ void SimpleBuilder::set_rooms_sides() {
...
@@ -101,42 +101,42 @@ void SimpleBuilder::set_rooms_sides() {
for
(
size_t
j
=
0
;
j
<
m_rooms_in_row
;
++
j
)
{
for
(
size_t
j
=
0
;
j
<
m_rooms_in_row
;
++
j
)
{
if
(
i
==
0
)
{
if
(
i
==
0
)
{
side
=
std
::
make_shared
<
Wall
>
(
*
m_rooms
.
at
(
i
).
at
(
j
));
side
=
std
::
make_shared
<
Wall
>
(
*
m_rooms
.
at
(
i
).
at
(
j
));
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Room
::
Direction
::
UP
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Direction
::
UP
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
get_side
(
Room
::
Direction
::
UP
)
->
prepare_for_drawing
();
m_rooms
.
at
(
i
).
at
(
j
)
->
get_side
(
Direction
::
UP
)
->
prepare_for_drawing
();
}
}
else
{
else
{
side
=
std
::
make_shared
<
Pass
>
(
*
m_rooms
.
at
(
i
).
at
(
j
),
*
m_rooms
.
at
(
i
-
1
).
at
(
j
));
side
=
std
::
make_shared
<
Pass
>
(
*
m_rooms
.
at
(
i
).
at
(
j
),
*
m_rooms
.
at
(
i
-
1
).
at
(
j
));
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Room
::
Direction
::
UP
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Direction
::
UP
,
side
);
}
}
if
(
i
==
m_rooms_in_col
-
1
)
{
if
(
i
==
m_rooms_in_col
-
1
)
{
side
=
std
::
make_shared
<
Wall
>
(
*
m_rooms
.
at
(
i
).
at
(
j
));
side
=
std
::
make_shared
<
Wall
>
(
*
m_rooms
.
at
(
i
).
at
(
j
));
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Room
::
Direction
::
DOWN
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Direction
::
DOWN
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
get_side
(
Room
::
Direction
::
DOWN
)
->
prepare_for_drawing
();
m_rooms
.
at
(
i
).
at
(
j
)
->
get_side
(
Direction
::
DOWN
)
->
prepare_for_drawing
();
}
}
else
{
else
{
side
=
std
::
make_shared
<
Pass
>
(
*
m_rooms
.
at
(
i
).
at
(
j
),
*
m_rooms
.
at
(
i
+
1
).
at
(
j
));
side
=
std
::
make_shared
<
Pass
>
(
*
m_rooms
.
at
(
i
).
at
(
j
),
*
m_rooms
.
at
(
i
+
1
).
at
(
j
));
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Room
::
Direction
::
DOWN
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Direction
::
DOWN
,
side
);
}
}
if
(
j
==
0
)
{
if
(
j
==
0
)
{
if
(
i
==
m_rooms_in_col
/
2
)
{
if
(
i
==
m_rooms_in_col
/
2
)
{
side
=
std
::
make_shared
<
Teleport
>
(
*
m_rooms
.
at
(
i
).
at
(
j
),
*
m_rooms
.
at
(
i
).
at
(
m_rooms_in_row
-
1
));
side
=
std
::
make_shared
<
Teleport
>
(
*
m_rooms
.
at
(
i
).
at
(
j
),
*
m_rooms
.
at
(
i
).
at
(
m_rooms_in_row
-
1
));
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Room
::
Direction
::
LEFT
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Direction
::
LEFT
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
get_side
(
Room
::
Direction
::
LEFT
)
->
prepare_for_drawing
();
m_rooms
.
at
(
i
).
at
(
j
)
->
get_side
(
Direction
::
LEFT
)
->
prepare_for_drawing
();
side
=
std
::
make_shared
<
Teleport
>
(
*
m_rooms
.
at
(
i
).
at
(
j
),
*
m_rooms
.
at
(
i
).
at
(
m_rooms_in_row
-
1
));
side
=
std
::
make_shared
<
Teleport
>
(
*
m_rooms
.
at
(
i
).
at
(
j
),
*
m_rooms
.
at
(
i
).
at
(
m_rooms_in_row
-
1
));
m_rooms
.
at
(
i
).
at
(
m_rooms_in_row
-
1
)
->
set_side
(
Room
::
Direction
::
RIGHT
,
side
);
m_rooms
.
at
(
i
).
at
(
m_rooms_in_row
-
1
)
->
set_side
(
Direction
::
RIGHT
,
side
);
m_rooms
.
at
(
i
).
at
(
m_rooms_in_row
-
1
)
->
get_side
(
Room
::
Direction
::
RIGHT
)
->
prepare_for_drawing
();
m_rooms
.
at
(
i
).
at
(
m_rooms_in_row
-
1
)
->
get_side
(
Direction
::
RIGHT
)
->
prepare_for_drawing
();
}
}
else
{
else
{
side
=
std
::
make_shared
<
Wall
>
(
*
m_rooms
.
at
(
i
).
at
(
j
));
side
=
std
::
make_shared
<
Wall
>
(
*
m_rooms
.
at
(
i
).
at
(
j
));
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Room
::
Direction
::
LEFT
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Direction
::
LEFT
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
get_side
(
Room
::
Direction
::
LEFT
)
->
prepare_for_drawing
();
m_rooms
.
at
(
i
).
at
(
j
)
->
get_side
(
Direction
::
LEFT
)
->
prepare_for_drawing
();
}
}
}
}
else
{
else
{
side
=
std
::
make_shared
<
Pass
>
(
*
m_rooms
.
at
(
i
).
at
(
j
),
*
m_rooms
.
at
(
i
).
at
(
j
-
1
));
side
=
std
::
make_shared
<
Pass
>
(
*
m_rooms
.
at
(
i
).
at
(
j
),
*
m_rooms
.
at
(
i
).
at
(
j
-
1
));
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Room
::
Direction
::
LEFT
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Direction
::
LEFT
,
side
);
}
}
if
(
j
==
m_rooms_in_row
-
1
)
{
if
(
j
==
m_rooms_in_row
-
1
)
{
...
@@ -145,13 +145,13 @@ void SimpleBuilder::set_rooms_sides() {
...
@@ -145,13 +145,13 @@ void SimpleBuilder::set_rooms_sides() {
}
}
else
{
else
{
side
=
std
::
make_shared
<
Wall
>
(
*
m_rooms
.
at
(
i
).
at
(
j
));
side
=
std
::
make_shared
<
Wall
>
(
*
m_rooms
.
at
(
i
).
at
(
j
));
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Room
::
Direction
::
RIGHT
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Direction
::
RIGHT
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
get_side
(
Room
::
Direction
::
RIGHT
)
->
prepare_for_drawing
();
m_rooms
.
at
(
i
).
at
(
j
)
->
get_side
(
Direction
::
RIGHT
)
->
prepare_for_drawing
();
}
}
}
}
else
{
else
{
side
=
std
::
make_shared
<
Pass
>
(
*
m_rooms
.
at
(
i
).
at
(
j
),
*
m_rooms
.
at
(
i
).
at
(
j
+
1
));
side
=
std
::
make_shared
<
Pass
>
(
*
m_rooms
.
at
(
i
).
at
(
j
),
*
m_rooms
.
at
(
i
).
at
(
j
+
1
));
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Room
::
Direction
::
RIGHT
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Direction
::
RIGHT
,
side
);
}
}
}
}
}
}
...
@@ -188,36 +188,36 @@ void ComplexBuilder::set_rooms_sides() {
...
@@ -188,36 +188,36 @@ void ComplexBuilder::set_rooms_sides() {
if
(
i
%
2
==
1
)
{
//
if
(
i
%
2
==
1
)
{
//
if
(
j
%
2
==
0
)
{
if
(
j
%
2
==
0
)
{
side
=
std
::
make_shared
<
Wall
>
(
*
m_rooms
.
at
(
i
).
at
(
j
));
side
=
std
::
make_shared
<
Wall
>
(
*
m_rooms
.
at
(
i
).
at
(
j
));
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Room
::
Direction
::
UP
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Direction
::
UP
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
get_side
(
Room
::
Direction
::
UP
)
->
prepare_for_drawing
();
m_rooms
.
at
(
i
).
at
(
j
)
->
get_side
(
Direction
::
UP
)
->
prepare_for_drawing
();
side
=
std
::
make_shared
<
Wall
>
(
*
m_rooms
.
at
(
i
).
at
(
j
));
side
=
std
::
make_shared
<
Wall
>
(
*
m_rooms
.
at
(
i
).
at
(
j
));
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Room
::
Direction
::
DOWN
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Direction
::
DOWN
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
get_side
(
Room
::
Direction
::
DOWN
)
->
prepare_for_drawing
();
m_rooms
.
at
(
i
).
at
(
j
)
->
get_side
(
Direction
::
DOWN
)
->
prepare_for_drawing
();
}
}
else
{
else
{
side
=
std
::
make_shared
<
Pass
>
(
*
m_rooms
.
at
(
i
).
at
(
j
),
*
m_rooms
.
at
(
i
-
1
).
at
(
j
/
2
));
side
=
std
::
make_shared
<
Pass
>
(
*
m_rooms
.
at
(
i
).
at
(
j
),
*
m_rooms
.
at
(
i
-
1
).
at
(
j
/
2
));
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Room
::
Direction
::
UP
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Direction
::
UP
,
side
);
side
=
std
::
make_shared
<
Pass
>
(
*
m_rooms
.
at
(
i
).
at
(
j
),
*
m_rooms
.
at
(
i
+
1
).
at
(
j
/
2
));
side
=
std
::
make_shared
<
Pass
>
(
*
m_rooms
.
at
(
i
).
at
(
j
),
*
m_rooms
.
at
(
i
+
1
).
at
(
j
/
2
));
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Room
::
Direction
::
DOWN
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Direction
::
DOWN
,
side
);
}
}
if
(
j
==
0
)
{
if
(
j
==
0
)
{
if
(
i
==
m_rooms_in_col
/
2
)
{
if
(
i
==
m_rooms_in_col
/
2
)
{
side
=
std
::
make_shared
<
Teleport
>
(
*
m_rooms
.
at
(
i
).
at
(
j
),
*
m_rooms
.
at
(
i
).
back
());
side
=
std
::
make_shared
<
Teleport
>
(
*
m_rooms
.
at
(
i
).
at
(
j
),
*
m_rooms
.
at
(
i
).
back
());
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Room
::
Direction
::
LEFT
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Direction
::
LEFT
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
get_side
(
Room
::
Direction
::
LEFT
)
->
prepare_for_drawing
();
m_rooms
.
at
(
i
).
at
(
j
)
->
get_side
(
Direction
::
LEFT
)
->
prepare_for_drawing
();
side
=
std
::
make_shared
<
Teleport
>
(
*
m_rooms
.
at
(
i
).
at
(
j
),
*
m_rooms
.
at
(
i
).
back
());
side
=
std
::
make_shared
<
Teleport
>
(
*
m_rooms
.
at
(
i
).
at
(
j
),
*
m_rooms
.
at
(
i
).
back
());
m_rooms
.
at
(
i
).
back
()
->
set_side
(
Room
::
Direction
::
RIGHT
,
side
);
m_rooms
.
at
(
i
).
back
()
->
set_side
(
Direction
::
RIGHT
,
side
);
m_rooms
.
at
(
i
).
back
()
->
get_side
(
Room
::
Direction
::
RIGHT
)
->
prepare_for_drawing
();
m_rooms
.
at
(
i
).
back
()
->
get_side
(
Direction
::
RIGHT
)
->
prepare_for_drawing
();
}
}
else
{
else
{
side
=
std
::
make_shared
<
Wall
>
(
*
m_rooms
.
at
(
i
).
at
(
j
));
side
=
std
::
make_shared
<
Wall
>
(
*
m_rooms
.
at
(
i
).
at
(
j
));
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Room
::
Direction
::
LEFT
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Direction
::
LEFT
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
get_side
(
Room
::
Direction
::
LEFT
)
->
prepare_for_drawing
();
m_rooms
.
at
(
i
).
at
(
j
)
->
get_side
(
Direction
::
LEFT
)
->
prepare_for_drawing
();
}
}
}
}
else
{
else
{
side
=
std
::
make_shared
<
Pass
>
(
*
m_rooms
.
at
(
i
).
at
(
j
),
*
m_rooms
.
at
(
i
).
at
(
j
-
1
));
side
=
std
::
make_shared
<
Pass
>
(
*
m_rooms
.
at
(
i
).
at
(
j
),
*
m_rooms
.
at
(
i
).
at
(
j
-
1
));
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Room
::
Direction
::
LEFT
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Direction
::
LEFT
,
side
);
}
}
if
(
j
==
m_rooms_in_row
-
1
)
{
if
(
j
==
m_rooms_in_row
-
1
)
{
if
(
i
==
m_rooms_in_col
/
2
)
{
if
(
i
==
m_rooms_in_col
/
2
)
{
...
@@ -225,13 +225,13 @@ void ComplexBuilder::set_rooms_sides() {
...
@@ -225,13 +225,13 @@ void ComplexBuilder::set_rooms_sides() {
}
}
else
{
else
{
side
=
std
::
make_shared
<
Wall
>
(
*
m_rooms
.
at
(
i
).
at
(
j
));
side
=
std
::
make_shared
<
Wall
>
(
*
m_rooms
.
at
(
i
).
at
(
j
));
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Room
::
Direction
::
RIGHT
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Direction
::
RIGHT
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
get_side
(
Room
::
Direction
::
RIGHT
)
->
prepare_for_drawing
();
m_rooms
.
at
(
i
).
at
(
j
)
->
get_side
(
Direction
::
RIGHT
)
->
prepare_for_drawing
();
}
}
}
}
else
{
else
{
side
=
std
::
make_shared
<
Pass
>
(
*
m_rooms
.
at
(
i
).
at
(
j
),
*
m_rooms
.
at
(
i
).
at
(
j
+
1
));
side
=
std
::
make_shared
<
Pass
>
(
*
m_rooms
.
at
(
i
).
at
(
j
),
*
m_rooms
.
at
(
i
).
at
(
j
+
1
));
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Room
::
Direction
::
RIGHT
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Direction
::
RIGHT
,
side
);
}
}
}
}
else
{
else
{
...
@@ -242,49 +242,49 @@ void ComplexBuilder::set_rooms_sides() {
...
@@ -242,49 +242,49 @@ void ComplexBuilder::set_rooms_sides() {
else
{
else
{
side
=
std
::
make_shared
<
Teleport
>
(
*
m_rooms
.
at
(
i
).
at
(
j
),
*
m_rooms
.
at
(
i
).
at
(
m_rooms
.
at
(
i
).
size
()
-
1
));
side
=
std
::
make_shared
<
Teleport
>
(
*
m_rooms
.
at
(
i
).
at
(
j
),
*
m_rooms
.
at
(
i
).
at
(
m_rooms
.
at
(
i
).
size
()
-
1
));
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Room
::
Direction
::
LEFT
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Direction
::
LEFT
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
get_side
(
Room
::
Direction
::
LEFT
)
->
prepare_for_drawing
();
m_rooms
.
at
(
i
).
at
(
j
)
->
get_side
(
Direction
::
LEFT
)
->
prepare_for_drawing
();
side
=
std
::
make_shared
<
Wall
>
(
*
m_rooms
.
at
(
i
).
at
(
j
));
side
=
std
::
make_shared
<
Wall
>
(
*
m_rooms
.
at
(
i
).
at
(
j
));
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Room
::
Direction
::
RIGHT
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Direction
::
RIGHT
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
get_side
(
Room
::
Direction
::
RIGHT
)
->
prepare_for_drawing
();
m_rooms
.
at
(
i
).
at
(
j
)
->
get_side
(
Direction
::
RIGHT
)
->
prepare_for_drawing
();
side
=
std
::
make_shared
<
Teleport
>
(
*
m_rooms
.
at
(
i
).
at
(
j
),
*
m_rooms
.
at
(
i
).
at
(
m_rooms
.
at
(
i
).
size
()
-
1
));
side
=
std
::
make_shared
<
Teleport
>
(
*
m_rooms
.
at
(
i
).
at
(
j
),
*
m_rooms
.
at
(
i
).
at
(
m_rooms
.
at
(
i
).
size
()
-
1
));
m_rooms
.
at
(
i
).
at
(
m_rooms
.
at
(
i
).
size
()
-
1
)
->
set_side
(
Room
::
Direction
::
RIGHT
,
side
);
m_rooms
.
at
(
i
).
at
(
m_rooms
.
at
(
i
).
size
()
-
1
)
->
set_side
(
Direction
::
RIGHT
,
side
);
m_rooms
.
at
(
i
).
at
(
m_rooms
.
at
(
i
).
size
()
-
1
)
->
get_side
(
Room
::
Direction
::
RIGHT
)
->
prepare_for_drawing
();
m_rooms
.
at
(
i
).
at
(
m_rooms
.
at
(
i
).
size
()
-
1
)
->
get_side
(
Direction
::
RIGHT
)
->
prepare_for_drawing
();
side
=
std
::
make_shared
<
Wall
>
(
*
m_rooms
.
at
(
i
).
at
(
m_rooms
.
at
(
i
).
size
()
-
1
));
side
=
std
::
make_shared
<
Wall
>
(
*
m_rooms
.
at
(
i
).
at
(
m_rooms
.
at
(
i
).
size
()
-
1
));
m_rooms
.
at
(
i
).
at
(
m_rooms
.
at
(
i
).
size
()
-
1
)
->
set_side
(
Room
::
Direction
::
LEFT
,
side
);
m_rooms
.
at
(
i
).
at
(
m_rooms
.
at
(
i
).
size
()
-
1
)
->
set_side
(
Direction
::
LEFT
,
side
);
m_rooms
.
at
(
i
).
at
(
m_rooms
.
at
(
i
).
size
()
-
1
)
->
get_side
(
Room
::
Direction
::
LEFT
)
->
prepare_for_drawing
();
m_rooms
.
at
(
i
).
at
(
m_rooms
.
at
(
i
).
size
()
-
1
)
->
get_side
(
Direction
::
LEFT
)
->
prepare_for_drawing
();
++
counter
;
++
counter
;
}
}
}
}
else
{
else
{
side
=
std
::
make_shared
<
Wall
>
(
*
m_rooms
.
at
(
i
).
at
(
j
));
side
=
std
::
make_shared
<
Wall
>
(
*
m_rooms
.
at
(
i
).
at
(
j
));
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Room
::
Direction
::
RIGHT
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Direction
::
RIGHT
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
get_side
(
Room
::
Direction
::
RIGHT
)
->
prepare_for_drawing
();
m_rooms
.
at
(
i
).
at
(
j
)
->
get_side
(
Direction
::
RIGHT
)
->
prepare_for_drawing
();
side
=
std
::
make_shared
<
Wall
>
(
*
m_rooms
.
at
(
i
).
at
(
j
));
side
=
std
::
make_shared
<
Wall
>
(
*
m_rooms
.
at
(
i
).
at
(
j
));
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Room
::
Direction
::
LEFT
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Direction
::
LEFT
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
get_side
(
Room
::
Direction
::
LEFT
)
->
prepare_for_drawing
();
m_rooms
.
at
(
i
).
at
(
j
)
->
get_side
(
Direction
::
LEFT
)
->
prepare_for_drawing
();
}
}
if
(
i
==
0
)
{
if
(
i
==
0
)
{
side
=
std
::
make_shared
<
Wall
>
(
*
m_rooms
.
at
(
i
).
at
(
j
));
side
=
std
::
make_shared
<
Wall
>
(
*
m_rooms
.
at
(
i
).
at
(
j
));
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Room
::
Direction
::
UP
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Direction
::
UP
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
get_side
(
Room
::
Direction
::
UP
)
->
prepare_for_drawing
();
m_rooms
.
at
(
i
).
at
(
j
)
->
get_side
(
Direction
::
UP
)
->
prepare_for_drawing
();
}
}
else
{
else
{
side
=
std
::
make_shared
<
Pass
>
(
*
m_rooms
.
at
(
i
).
at
(
j
),
*
m_rooms
.
at
(
i
-
1
).
at
(
j
*
2
+
1
));
side
=
std
::
make_shared
<
Pass
>
(
*
m_rooms
.
at
(
i
).
at
(
j
),
*
m_rooms
.
at
(
i
-
1
).
at
(
j
*
2
+
1
));
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Room
::
Direction
::
UP
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Direction
::
UP
,
side
);
}
}
if
(
i
==
m_rooms_in_col
-
1
)
{
if
(
i
==
m_rooms_in_col
-
1
)
{
side
=
std
::
make_shared
<
Wall
>
(
*
m_rooms
.
at
(
i
).
at
(
j
));
side
=
std
::
make_shared
<
Wall
>
(
*
m_rooms
.
at
(
i
).
at
(
j
));
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Room
::
Direction
::
DOWN
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Direction
::
DOWN
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
get_side
(
Room
::
Direction
::
DOWN
)
->
prepare_for_drawing
();
m_rooms
.
at
(
i
).
at
(
j
)
->
get_side
(
Direction
::
DOWN
)
->
prepare_for_drawing
();
}
}
else
{
else
{
side
=
std
::
make_shared
<
Pass
>
(
*
m_rooms
.
at
(
i
).
at
(
j
),
*
m_rooms
.
at
(
i
+
1
).
at
(
j
*
2
+
1
));
side
=
std
::
make_shared
<
Pass
>
(
*
m_rooms
.
at
(
i
).
at
(
j
),
*
m_rooms
.
at
(
i
+
1
).
at
(
j
*
2
+
1
));
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Room
::
Direction
::
DOWN
,
side
);
m_rooms
.
at
(
i
).
at
(
j
)
->
set_side
(
Direction
::
DOWN
,
side
);
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
source/Config/Config.h
+
3
−
1
View file @
36f159c3
...
@@ -49,4 +49,6 @@ namespace config {
...
@@ -49,4 +49,6 @@ namespace config {
const
sf
::
Color
GAME_COLOR_TELEPORT
{
255
,
0
,
0
};
const
sf
::
Color
GAME_COLOR_TELEPORT
{
255
,
0
,
0
};
const
sf
::
Color
GAME_FOOD_COLOR
{
0
,
200
,
100
};
const
sf
::
Color
GAME_FOOD_COLOR
{
0
,
200
,
100
};
const
sf
::
Color
GAME_ENEMY_COLOR
{
255
,
50
,
0
};
const
sf
::
Color
GAME_ENEMY_COLOR
{
255
,
50
,
0
};
}
}
\ No newline at end of file
enum
Direction
{
INVALID
=
-
1
,
LEFT
,
RIGHT
,
UP
,
DOWN
};
\ No newline at end of file
This diff is collapsed.
Click to expand it.
source/Draw/Texture.cpp
+
21
−
2
View file @
36f159c3
...
@@ -21,8 +21,27 @@ MenuTexture::MenuTexture() {
...
@@ -21,8 +21,27 @@ MenuTexture::MenuTexture() {
m_tex
.
setRepeated
(
true
);
m_tex
.
setRepeated
(
true
);
}
}
sf
::
Texture
&
SpellTexture
::
get_texture
()
{
switch
(
m_dir
)
{
case
Direction
::
UP
:
return
m_up
;
case
Direction
::
DOWN
:
return
m_down
;
case
Direction
::
RIGHT
:
return
m_right
;
case
Direction
::
LEFT
:
return
m_left
;
}
}
SpellTexture
::
SpellTexture
()
{
SpellTexture
::
SpellTexture
()
{
if
(
!
m_tex
.
loadFromFile
(
std
::
string
(
TEXTURE_PATH
)
+
"fireball.png"
))
if
(
!
m_right
.
loadFromFile
(
std
::
string
(
TEXTURE_PATH
)
+
"fireball.png"
))
throw
std
::
runtime_error
(
"Can't added Texture for Fireball"
);
if
(
!
m_down
.
loadFromFile
(
std
::
string
(
TEXTURE_PATH
)
+
"fireball_down.png"
))
throw
std
::
runtime_error
(
"Can't added Texture for Fireball"
);
if
(
!
m_left
.
loadFromFile
(
std
::
string
(
TEXTURE_PATH
)
+
"fireball_left.png"
))
throw
std
::
runtime_error
(
"Can't added Texture for Fireball"
);
if
(
!
m_up
.
loadFromFile
(
std
::
string
(
TEXTURE_PATH
)
+
"fireball_up.png"
))
throw
std
::
runtime_error
(
"Can't added Texture for Fireball"
);
throw
std
::
runtime_error
(
"Can't added Texture for Fireball"
);
m_tex
.
setRepeated
(
true
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
source/Draw/Texture.h
+
10
−
2
View file @
36f159c3
#pragma once
#pragma once
#include
<SFML/Graphics.hpp>
#include
<SFML/Graphics.hpp>
#include
"../Config/Config.h"
class
Texture
{
class
Texture
{
public:
public:
Texture
(
const
Texture
&
tex
)
=
delete
;
Texture
(
const
Texture
&
tex
)
=
delete
;
Texture
&
operator
=
(
const
Texture
&
tex
)
=
delete
;
Texture
&
operator
=
(
const
Texture
&
tex
)
=
delete
;
virtual
sf
::
Texture
&
get_texture
()
=
0
;
virtual
sf
::
Texture
&
get_texture
()
=
0
;
void
set_dir
(
Direction
dir
)
{
m_dir
=
dir
;
}
protected
:
protected
:
sf
::
Texture
m_tex
;
Direction
m_dir
=
Direction
::
RIGHT
;
Texture
()
=
default
;
Texture
()
=
default
;
};
};
...
@@ -17,6 +20,7 @@ public:
...
@@ -17,6 +20,7 @@ public:
static
PacmanTexture
&
Instance
()
{
static
PacmanTexture
tex
;
return
tex
;
}
static
PacmanTexture
&
Instance
()
{
static
PacmanTexture
tex
;
return
tex
;
}
sf
::
Texture
&
get_texture
()
override
{
return
m_tex
;
}
sf
::
Texture
&
get_texture
()
override
{
return
m_tex
;
}
private
:
private
:
sf
::
Texture
m_tex
;
PacmanTexture
();
PacmanTexture
();
};
};
...
@@ -25,6 +29,7 @@ public:
...
@@ -25,6 +29,7 @@ public:
static
EnemyTexture
&
Instance
()
{
static
EnemyTexture
tex
;
return
tex
;
}
static
EnemyTexture
&
Instance
()
{
static
EnemyTexture
tex
;
return
tex
;
}
sf
::
Texture
&
get_texture
()
override
{
return
m_tex
;
}
sf
::
Texture
&
get_texture
()
override
{
return
m_tex
;
}
private
:
private
:
sf
::
Texture
m_tex
;
EnemyTexture
();
EnemyTexture
();
};
};
...
@@ -33,6 +38,7 @@ public:
...
@@ -33,6 +38,7 @@ public:
static
GoldTexture
&
Instance
()
{
static
GoldTexture
tex
;
return
tex
;
}
static
GoldTexture
&
Instance
()
{
static
GoldTexture
tex
;
return
tex
;
}
sf
::
Texture
&
get_texture
()
override
{
return
m_tex
;
}
sf
::
Texture
&
get_texture
()
override
{
return
m_tex
;
}
private
:
private
:
sf
::
Texture
m_tex
;
GoldTexture
();
GoldTexture
();
};
};
...
@@ -42,13 +48,15 @@ public:
...
@@ -42,13 +48,15 @@ public:
static
MenuTexture
&
Instance
()
{
static
MenuTexture
tex
;
return
tex
;
}
static
MenuTexture
&
Instance
()
{
static
MenuTexture
tex
;
return
tex
;
}
sf
::
Texture
&
get_texture
()
override
{
return
m_tex
;
}
sf
::
Texture
&
get_texture
()
override
{
return
m_tex
;
}
private
:
private
:
sf
::
Texture
m_tex
;
MenuTexture
();
MenuTexture
();
};
};
class
SpellTexture
:
public
Texture
{
class
SpellTexture
:
public
Texture
{
public:
public:
static
SpellTexture
&
Instance
()
{
static
SpellTexture
tex
;
return
tex
;
}
static
SpellTexture
&
Instance
()
{
static
SpellTexture
tex
;
return
tex
;
}
sf
::
Texture
&
get_texture
()
override
{
return
m_tex
;
}
sf
::
Texture
&
get_texture
()
override
;
private
:
private
:
sf
::
Texture
m_up
,
m_right
,
m_down
,
m_left
;
SpellTexture
();
SpellTexture
();
};
};
\ No newline at end of file
This diff is collapsed.
Click to expand it.
source/Game/IEntity.cpp
+
1
−
1
View file @
36f159c3
...
@@ -82,7 +82,7 @@ void Enemy::action(Room* room) {
...
@@ -82,7 +82,7 @@ void Enemy::action(Room* room) {
side
=
2
;
side
=
2
;
}
}
}
}
auto
direction
=
static_cast
<
Room
::
Direction
>
(
side
);
auto
direction
=
static_cast
<
Direction
>
(
side
);
m_ptr_room
->
get_side
(
direction
)
->
enter
(
this
);
m_ptr_room
->
get_side
(
direction
)
->
enter
(
this
);
m_stopwatch
.
restart
();
//
m_stopwatch
.
restart
();
//
}
}
...
...
This diff is collapsed.
Click to expand it.
source/Game/Pacman.cpp
+
6
−
2
View file @
36f159c3
...
@@ -5,7 +5,7 @@ Pacman::Pacman() {
...
@@ -5,7 +5,7 @@ Pacman::Pacman() {
set_texture
(
&
PacmanTexture
::
Instance
());
set_texture
(
&
PacmanTexture
::
Instance
());
}
}
void
Pacman
::
move
(
Room
::
Direction
direction
)
{
void
Pacman
::
move
(
Direction
direction
)
{
m_dir
=
direction
;
m_dir
=
direction
;
m_ptr_room
->
get_side
(
direction
)
->
enter
(
this
);
m_ptr_room
->
get_side
(
direction
)
->
enter
(
this
);
}
}
...
@@ -24,6 +24,9 @@ void Pacman::ultimate(){
...
@@ -24,6 +24,9 @@ void Pacman::ultimate(){
}
}
void
Pacman
::
draw_into
(
sf
::
RenderWindow
&
window
)
const
{
void
Pacman
::
draw_into
(
sf
::
RenderWindow
&
window
)
const
{
if
(
m_mp
<
300
)
{
m_mp
+=
1.0
/
60
;
}
for
(
auto
&
spell
:
m_spells
)
{
for
(
auto
&
spell
:
m_spells
)
{
spell
.
draw_into
(
window
);
spell
.
draw_into
(
window
);
}
}
...
@@ -55,7 +58,7 @@ std::unique_ptr<IGameEvent> Pacman::visit(Enemy* ptr_enemy) {
...
@@ -55,7 +58,7 @@ std::unique_ptr<IGameEvent> Pacman::visit(Enemy* ptr_enemy) {
}
}
Fireball
::
Fireball
(
Room
::
Direction
direction
,
Room
*
room
)
{
Fireball
::
Fireball
(
Direction
direction
,
Room
*
room
)
{
m_direct
=
direction
;
m_direct
=
direction
;
m_ptr_room
=
room
;
m_ptr_room
=
room
;
set_texture
(
&
SpellTexture
::
Instance
());
set_texture
(
&
SpellTexture
::
Instance
());
...
@@ -67,6 +70,7 @@ void Fireball::draw_into(sf::RenderWindow& window) const {
...
@@ -67,6 +70,7 @@ void Fireball::draw_into(sf::RenderWindow& window) const {
}
}
void
Fireball
::
prepare_for_drawing
(){
void
Fireball
::
prepare_for_drawing
(){
m_ptr_tex
->
set_dir
(
m_direct
);
m_sprite
.
setTexture
(
m_ptr_tex
->
get_texture
());
m_sprite
.
setTexture
(
m_ptr_tex
->
get_texture
());
m_sprite
.
setScale
(
0.1
,
0.1
);
m_sprite
.
setScale
(
0.1
,
0.1
);
m_sprite
.
setPosition
(
m_ptr_room
->
get_position
()
+
sf
::
Vector2f
(
-
10
,
-
10
));
m_sprite
.
setPosition
(
m_ptr_room
->
get_position
()
+
sf
::
Vector2f
(
-
10
,
-
10
));
...
...
This diff is collapsed.
Click to expand it.
source/Game/Pacman.h
+
5
−
5
View file @
36f159c3
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
class
Fireball
:
public
IEntity
,
public
IVisitor
{
class
Fireball
:
public
IEntity
,
public
IVisitor
{
public:
public:
Fireball
(
Room
::
Direction
direction
,
Room
*
room
);
Fireball
(
Direction
direction
,
Room
*
room
);
void
draw_into
(
sf
::
RenderWindow
&
window
)
const
override
;
void
draw_into
(
sf
::
RenderWindow
&
window
)
const
override
;
void
prepare_for_drawing
()
override
;
void
prepare_for_drawing
()
override
;
void
move
();
void
move
();
...
@@ -14,7 +14,7 @@ public:
...
@@ -14,7 +14,7 @@ public:
void
set_texture
(
Texture
*
ptr_texture
)
{
m_ptr_tex
=
ptr_texture
;
}
void
set_texture
(
Texture
*
ptr_texture
)
{
m_ptr_tex
=
ptr_texture
;
}
private
:
private
:
size_t
m_wall
=
0
;
size_t
m_wall
=
0
;
Room
::
Direction
m_direct
;
Direction
m_direct
;
mutable
sf
::
Sprite
m_sprite
;
mutable
sf
::
Sprite
m_sprite
;
Texture
*
m_ptr_tex
;
Texture
*
m_ptr_tex
;
};
};
...
@@ -22,7 +22,7 @@ private:
...
@@ -22,7 +22,7 @@ private:
class
Pacman
:
public
IEntity
,
public
IVisitor
{
class
Pacman
:
public
IEntity
,
public
IVisitor
{
public:
public:
Pacman
();
Pacman
();
void
move
(
Room
::
Direction
direction
);
void
move
(
Direction
direction
);
void
spell
();
void
spell
();
void
ultimate
();
void
ultimate
();
void
draw_into
(
sf
::
RenderWindow
&
window
)
const
override
;
void
draw_into
(
sf
::
RenderWindow
&
window
)
const
override
;
...
@@ -32,8 +32,8 @@ public:
...
@@ -32,8 +32,8 @@ public:
void
set_texture
(
Texture
*
ptr_texture
)
{
m_ptr_tex
=
ptr_texture
;
}
void
set_texture
(
Texture
*
ptr_texture
)
{
m_ptr_tex
=
ptr_texture
;
}
std
::
vector
<
Fireball
>
m_spells
;
std
::
vector
<
Fireball
>
m_spells
;
private
:
private
:
Room
::
Direction
m_dir
;
Direction
m_dir
;
size_
t
m_mp
=
100
;
mutable
floa
t
m_mp
=
100
;
sf
::
Sprite
m_sprite
;
sf
::
Sprite
m_sprite
;
Texture
*
m_ptr_tex
;
Texture
*
m_ptr_tex
;
};
};
...
...
This diff is collapsed.
Click to expand it.
source/Maze/Maze.cpp
+
5
−
5
View file @
36f159c3
...
@@ -28,7 +28,7 @@ std::shared_ptr<IRoomSide> Room::get_side(Direction side) {
...
@@ -28,7 +28,7 @@ std::shared_ptr<IRoomSide> Room::get_side(Direction side) {
return
m_sides
.
at
(
side
);
return
m_sides
.
at
(
side
);
}
}
Room
::
Direction
Room
::
get_direction
(
IRoomSide
*
ptr_side
)
{
Direction
Room
::
get_direction
(
IRoomSide
*
ptr_side
)
{
if
(
ptr_side
==
m_sides
.
at
(
UP
).
get
())
{
return
UP
;
}
if
(
ptr_side
==
m_sides
.
at
(
UP
).
get
())
{
return
UP
;
}
if
(
ptr_side
==
m_sides
.
at
(
RIGHT
).
get
())
{
return
RIGHT
;
}
if
(
ptr_side
==
m_sides
.
at
(
RIGHT
).
get
())
{
return
RIGHT
;
}
if
(
ptr_side
==
m_sides
.
at
(
DOWN
).
get
())
{
return
DOWN
;
}
if
(
ptr_side
==
m_sides
.
at
(
DOWN
).
get
())
{
return
DOWN
;
}
...
@@ -103,22 +103,22 @@ void Wall::prepare_for_drawing() {
...
@@ -103,22 +103,22 @@ void Wall::prepare_for_drawing() {
float
size
=
config
::
ROOM_SIZE
;
float
size
=
config
::
ROOM_SIZE
;
switch
(
m_room
.
get_direction
(
this
))
{
switch
(
m_room
.
get_direction
(
this
))
{
case
Room
::
UP
:
case
Direction
::
UP
:
m_line
[
0
]
=
sf
::
Vertex
({
pos
.
x
-
size
/
2
,
pos
.
y
-
size
/
2
},
config
::
GAME_COLOR_WALL
);
m_line
[
0
]
=
sf
::
Vertex
({
pos
.
x
-
size
/
2
,
pos
.
y
-
size
/
2
},
config
::
GAME_COLOR_WALL
);
m_line
[
1
]
=
sf
::
Vertex
({
pos
.
x
+
size
/
2
,
pos
.
y
-
size
/
2
},
config
::
GAME_COLOR_WALL
);
m_line
[
1
]
=
sf
::
Vertex
({
pos
.
x
+
size
/
2
,
pos
.
y
-
size
/
2
},
config
::
GAME_COLOR_WALL
);
break
;
break
;
case
Room
::
RIGHT
:
case
Direction
::
RIGHT
:
m_line
[
0
]
=
sf
::
Vertex
({
pos
.
x
+
size
/
2
,
pos
.
y
-
size
/
2
},
config
::
GAME_COLOR_WALL
);
m_line
[
0
]
=
sf
::
Vertex
({
pos
.
x
+
size
/
2
,
pos
.
y
-
size
/
2
},
config
::
GAME_COLOR_WALL
);
m_line
[
1
]
=
sf
::
Vertex
({
pos
.
x
+
size
/
2
,
pos
.
y
+
size
/
2
},
config
::
GAME_COLOR_WALL
);
m_line
[
1
]
=
sf
::
Vertex
({
pos
.
x
+
size
/
2
,
pos
.
y
+
size
/
2
},
config
::
GAME_COLOR_WALL
);
break
;
break
;
case
Room
::
DOWN
:
case
Direction
::
DOWN
:
m_line
[
0
]
=
sf
::
Vertex
({
pos
.
x
+
size
/
2
,
pos
.
y
+
size
/
2
},
config
::
GAME_COLOR_WALL
);
m_line
[
0
]
=
sf
::
Vertex
({
pos
.
x
+
size
/
2
,
pos
.
y
+
size
/
2
},
config
::
GAME_COLOR_WALL
);
m_line
[
1
]
=
sf
::
Vertex
({
pos
.
x
-
size
/
2
,
pos
.
y
+
size
/
2
},
config
::
GAME_COLOR_WALL
);
m_line
[
1
]
=
sf
::
Vertex
({
pos
.
x
-
size
/
2
,
pos
.
y
+
size
/
2
},
config
::
GAME_COLOR_WALL
);
break
;
break
;
case
Room
::
LEFT
:
case
Direction
::
LEFT
:
m_line
[
0
]
=
sf
::
Vertex
({
pos
.
x
-
size
/
2
,
pos
.
y
+
size
/
2
},
config
::
GAME_COLOR_WALL
);
m_line
[
0
]
=
sf
::
Vertex
({
pos
.
x
-
size
/
2
,
pos
.
y
+
size
/
2
},
config
::
GAME_COLOR_WALL
);
m_line
[
1
]
=
sf
::
Vertex
({
pos
.
x
-
size
/
2
,
pos
.
y
-
size
/
2
},
config
::
GAME_COLOR_WALL
);
m_line
[
1
]
=
sf
::
Vertex
({
pos
.
x
-
size
/
2
,
pos
.
y
-
size
/
2
},
config
::
GAME_COLOR_WALL
);
break
;
break
;
...
...
This diff is collapsed.
Click to expand it.
source/Maze/Maze.h
+
1
−
1
View file @
36f159c3
...
@@ -27,7 +27,7 @@ private:
...
@@ -27,7 +27,7 @@ private:
sf
::
RectangleShape
m_rectangle
;
sf
::
RectangleShape
m_rectangle
;
public:
public:
std
::
array
<
std
::
shared_ptr
<
IRoomSide
>
,
4
>
m_sides
;
std
::
array
<
std
::
shared_ptr
<
IRoomSide
>
,
4
>
m_sides
;
enum
Direction
{
INVALID
=
-
1
,
LEFT
,
RIGHT
,
UP
,
DOWN
};
//
enum Direction { INVALID = -1, LEFT, RIGHT, UP, DOWN };
public:
public:
Room
(
float
size
);
Room
(
float
size
);
float
get_size
();
float
get_size
();
...
...
This diff is collapsed.
Click to expand it.
source/State/States.cpp
+
4
−
4
View file @
36f159c3
...
@@ -153,21 +153,21 @@ void GameState::process_key_pressed(sf::Keyboard::Key code) {
...
@@ -153,21 +153,21 @@ void GameState::process_key_pressed(sf::Keyboard::Key code) {
switch
(
code
)
{
switch
(
code
)
{
case
sf
::
Keyboard
::
W
:
case
sf
::
Keyboard
::
W
:
m_context_manager
.
save_context
();
m_context_manager
.
save_context
();
m_context_manager
.
get_context
().
pacman
.
move
(
Room
::
UP
);
m_context_manager
.
get_context
().
pacman
.
move
(
Direction
::
UP
);
break
;
break
;
case
sf
::
Keyboard
::
S
:
case
sf
::
Keyboard
::
S
:
m_context_manager
.
save_context
();
m_context_manager
.
save_context
();
m_context_manager
.
get_context
().
pacman
.
move
(
Room
::
DOWN
);
m_context_manager
.
get_context
().
pacman
.
move
(
Direction
::
DOWN
);
break
;
break
;
case
sf
::
Keyboard
::
A
:
case
sf
::
Keyboard
::
A
:
m_context_manager
.
save_context
();
m_context_manager
.
save_context
();
m_context_manager
.
get_context
().
pacman
.
move
(
Room
::
LEFT
);
m_context_manager
.
get_context
().
pacman
.
move
(
Direction
::
LEFT
);
break
;
break
;
case
sf
::
Keyboard
::
D
:
case
sf
::
Keyboard
::
D
:
m_context_manager
.
save_context
();
m_context_manager
.
save_context
();
m_context_manager
.
get_context
().
pacman
.
move
(
Room
::
RIGHT
);
m_context_manager
.
get_context
().
pacman
.
move
(
Direction
::
RIGHT
);
break
;
break
;
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
source/main.cpp
+
10
−
41
View file @
36f159c3
...
@@ -5,48 +5,17 @@ int main() {
...
@@ -5,48 +5,17 @@ int main() {
return
app
.
run
();
return
app
.
run
();
}
}
//#include <
SFML/Graphics.hpp
>
//#include <
iostream
>
//
//
//int main() {
//struct MyStruct {
// sf::RenderWindow window(sf::VideoMode(800, 600), "Seamless Scrolling Background");
// char c;
//
// int i_1;
// //
// int i_2;
// sf::Texture texture;
//};
// if (!texture.loadFromFile(std::string(TEXTURE_PATH) + "menu.png")) {
// return -1;
// }
//
// texture.setRepeated(true); //
//
// //
// sf::Sprite sprite(texture);
// sprite.setTextureRect(sf::IntRect(0, 0, 1600, 600)); //
//
// float offset = 0;
// float scrollSpeed = 100.f; //
// sf::Clock clock;
//
//
// while (window.isOpen()) {
//int main() {
// sf::Event event;
// MyStruct a;
// while (window.pollEvent(event)) {
// std::cout << sizeof(a);
// if (event.type == sf::Event::Closed)
// window.close();
// }
//
// float deltaTime = clock.restart().asSeconds();
// offset += scrollSpeed * deltaTime;
//
// //
// if (offset >= 800) { // ,
// offset -= 800;
// }
//
// sprite.setTextureRect(sf::IntRect(offset, 0, 800, 600));
//
// window.clear();
// window.draw(sprite);
// window.display();
// }
//
//
//
return 0;
//
return 0;
//}
//}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets