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
Сулимов Игорь Андреевич
Pac-Man
Commits
a8f3995d
Commit
a8f3995d
authored
1 week ago
by
Сулимов Игорь Андреевич
Browse files
Options
Download
Patches
Plain Diff
Done main lab work
parent
06c0f077
main
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
include/Config.h
+5
-1
include/Config.h
include/IWindowKeeper.h
+1
-1
include/IWindowKeeper.h
include/States/GameState.h
+3
-3
include/States/GameState.h
source/Draw/Menu.cpp
+2
-2
source/Draw/Menu.cpp
source/States/GameState.cpp
+13
-0
source/States/GameState.cpp
with
24 additions
and
7 deletions
+24
-7
include/Config.h
+
5
−
1
View file @
a8f3995d
...
...
@@ -14,15 +14,19 @@ namespace config {
const
char
BUTTON_TEXT_EASY
[]
=
"Easy"
;
const
char
BUTTON_TEXT_MEDIUM
[]
=
"Medium"
;
const
char
BUTTON_TEXT_HARD
[]
=
"Hard"
;
const
char
BUTTON_TEXT_BONUS
[]
=
"Bonus"
;
const
char
BUTTON_TEXT_EXIT
[]
=
"Exit"
;
// Игра:
const
sf
::
VideoMode
GAME_VIDEO_MODE
{
1080
,
720
};
const
char
EASY_GAME_TITLE
[]
=
"Level: Easy"
;
const
char
MEDIUM_GAME_TITLE
[]
=
"Level: Medium"
;
const
char
HARD_GAME_TITLE
[]
=
"Level: Hard"
;
const
char
BONUS_GAME_TITLE
[]
=
"Level: Hard"
;
const
float
EASY_GAME_ENEMY_RATIO
=
0.0
f
;
const
float
MEDIUM_GAME_ENEMY_RATIO
=
0.03
f
;
const
float
HARD_GAME_ENEMY_RATIO
=
0.07
f
;
const
float
HARD_GAME_ENEMY_RATIO
=
0.05
f
;
const
float
ROOM_SIZE_EASY
=
140
;
const
float
ROOM_SIZE_MEADIUM
=
70
;
const
float
ROOM_SIZE
=
50
;
const
float
GAME_ENEMY_SIZE
=
ROOM_SIZE
*
0.7
;
const
float
GAME_FOOD_SIZE
=
ROOM_SIZE
*
0.2
;
...
...
This diff is collapsed.
Click to expand it.
include/IWindowKeeper.h
+
1
−
1
View file @
a8f3995d
...
...
@@ -12,7 +12,7 @@ public:
IWindowKeeper
(
const
sf
::
VideoMode
&
video_mode
,
const
std
::
string
&
window_title
)
:
m_window
(
video_mode
,
window_title
)
{
m_window
.
setFramerateLimit
(
config
::
FRAME_RATE_LIMIT
);
m_window
.
setKeyRepeatEnabled
(
false
);
//
m_window.setKeyRepeatEnabled(false);
}
protected
:
sf
::
RenderWindow
m_window
;
...
...
This diff is collapsed.
Click to expand it.
include/States/GameState.h
+
3
−
3
View file @
a8f3995d
...
...
@@ -12,9 +12,9 @@ public:
bool
do_step
()
override
;
protected:
void
process_key_pressed
(
sf
::
Keyboard
::
Key
key
);
void
event_handling
()
override
;
///@todo
void
update
()
override
{};
///@todo
void
render
()
override
;
///@todo
void
event_handling
()
override
;
void
update
()
override
;
void
render
()
override
;
void
process_entities_interactions
(
IVisitor
*
entity
);
public:
GameState
(
IStateManager
&
state_manager
,
...
...
This diff is collapsed.
Click to expand it.
source/Draw/Menu.cpp
+
2
−
2
View file @
a8f3995d
...
...
@@ -12,7 +12,7 @@ Menu::Menu(IStateManager& state_manager) {
auto
easy_director
=
std
::
make_unique
<
GameBuilderDirector
>
(
std
::
make_unique
<
SimpleBuilder
>
(
config
::
GAME_VIDEO_MODE
.
width
,
config
::
GAME_VIDEO_MODE
.
height
,
config
::
ROOM_SIZE
),
config
::
ROOM_SIZE
_EASY
),
config
::
GAME_VIDEO_MODE
,
config
::
EASY_GAME_TITLE
,
config
::
EASY_GAME_ENEMY_RATIO
);
...
...
@@ -20,7 +20,7 @@ Menu::Menu(IStateManager& state_manager) {
auto
medium_director
=
std
::
make_unique
<
GameBuilderDirector
>
(
std
::
make_unique
<
SimpleBuilder
>
(
config
::
GAME_VIDEO_MODE
.
width
,
config
::
GAME_VIDEO_MODE
.
height
,
config
::
ROOM_SIZE
),
config
::
ROOM_SIZE
_MEADIUM
),
config
::
GAME_VIDEO_MODE
,
config
::
MEDIUM_GAME_TITLE
,
config
::
MEDIUM_GAME_ENEMY_RATIO
);
...
...
This diff is collapsed.
Click to expand it.
source/States/GameState.cpp
+
13
−
0
View file @
a8f3995d
...
...
@@ -86,6 +86,19 @@ void GameState::event_handling() {
}
}
void
GameState
::
update
()
{
if
(
m_context_manager
.
get_current_context
().
state
==
GameContext
::
LOST
||
m_context_manager
.
get_current_context
().
state
==
GameContext
::
WIN
)
{
return
;
}
for
(
auto
&
obj
:
m_context_manager
.
get_current_context
().
dynamic_objects
)
{
obj
->
action
();
}
process_entities_interactions
(
&
m_context_manager
.
get_current_context
().
pacman
);
if
(
!
m_context_manager
.
get_current_context
().
static_objects
.
size
())
m_context_manager
.
get_current_context
().
state
=
GameContext
::
WIN
;
}
void
GameState
::
render
()
{
if
(
m_context_manager
.
get_current_context
().
state
==
GameContext
::
INGAME
)
{
m_window
.
clear
(
config
::
GAME_COLOR_BACKGROUND_INGAME
);
...
...
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