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
581a115a
Commit
581a115a
authored
2 weeks ago
by
Сулимов Игорь Андреевич
Browse files
Options
Download
Patches
Plain Diff
Completed Room
parent
db89415e
main
No related merge requests found
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
CMakeLists.txt
+1
-0
CMakeLists.txt
include/Commands/ExitCommand.h
+1
-1
include/Commands/ExitCommand.h
include/Config.h
+3
-3
include/Config.h
include/Draw/Button.h
+1
-1
include/Draw/Button.h
include/MazeContent/Maze.h
+1
-1
include/MazeContent/Maze.h
include/MazeContent/Room.h
+7
-7
include/MazeContent/Room.h
include/States/ExitState.h
+1
-1
include/States/ExitState.h
source/Draw/MyFont.cpp
+1
-1
source/Draw/MyFont.cpp
source/Maze_Content/Room.cpp
+38
-0
source/Maze_Content/Room.cpp
source/Maze_Content/Wall.cpp
+59
-0
source/Maze_Content/Wall.cpp
with
113 additions
and
15 deletions
+113
-15
CMakeLists.txt
+
1
−
0
View file @
581a115a
...
...
@@ -17,6 +17,7 @@ add_executable(pac-man
"source/Draw/Button.cpp"
"source/Draw/MyFont.cpp"
"source/Commands/ExitCommand.cpp"
"source/Maze_Content/Room.cpp"
)
...
...
This diff is collapsed.
Click to expand it.
include/Commands/ExitCommand.h
+
1
−
1
View file @
581a115a
...
...
@@ -4,7 +4,7 @@
class
ExitCommand
:
public
ChangeStateCommand
{
public:
void
execute
()
override
;
///@todo
void
execute
()
override
;
public:
ExitCommand
(
IStateManager
&
state_manager
);
};
\ No newline at end of file
This diff is collapsed.
Click to expand it.
include/
c
onfig.h
→
include/
C
onfig.h
+
3
−
3
View file @
581a115a
...
...
@@ -23,7 +23,7 @@ namespace config {
// const float EASY_GAME_ENEMY_RATIO = 0.0f;
// const float MEDIUM_GAME_ENEMY_RATIO = 0.03f;
// const float HARD_GAME_ENEMY_RATIO = 0.07f;
//
const float ROOM_SIZE = 50;
const
float
ROOM_SIZE
=
50
;
// const float GAME_ENEMY_SIZE = ROOM_SIZE * 0.7;
// const float GAME_FOOD_SIZE = ROOM_SIZE * 0.2;
// Пакмэн:
...
...
@@ -42,8 +42,8 @@ namespace config {
// const sf::Color GAME_COLOR_BACKGROUND_WIN{ 0, 255, 0 };
// const sf::Color GAME_COLOR_BACKGROUND_LOST{ 255, 0, 0 };
// const sf::Color GAME_COLOR_PACMAN{ 250, 150, 0 };
//
const sf::Color GAME_COLOR_ROOM{ 255, 255, 255 };
//
const sf::Color GAME_COLOR_WALL{ 0, 0, 0 };
const
sf
::
Color
GAME_COLOR_ROOM
{
255
,
255
,
255
};
const
sf
::
Color
GAME_COLOR_WALL
{
0
,
0
,
0
};
// const sf::Color GAME_FOOD_COLOR{ 0, 200, 100 };
// const sf::Color GAME_ENEMY_COLOR{ 255, 50, 0 };
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
include/Draw/Button.h
+
1
−
1
View file @
581a115a
#pragma once
#include
"
c
onfig.h"
#include
"
C
onfig.h"
#include
"IDrawable.h"
#include
"Commands/ISelectCommand.h"
...
...
This diff is collapsed.
Click to expand it.
include/MazeContent/Maze.h
+
1
−
1
View file @
581a115a
...
...
@@ -4,7 +4,7 @@
class
Maze
:
public
IDrawable
{
public:
void
draw_into
(
sf
::
RenderWindow
&
window
)
const
override
;
///@todo
void
draw_into
(
sf
::
RenderWindow
&
window
)
const
override
;
public:
Maze
(
std
::
vector
<
std
::
unique_ptr
<
Room
>>&&
rooms
)
:
m_rooms
(
std
::
move
(
rooms
))
{}
private
:
...
...
This diff is collapsed.
Click to expand it.
include/MazeContent/Room.h
+
7
−
7
View file @
581a115a
...
...
@@ -5,14 +5,14 @@
class
Room
:
public
IDrawable
{
public:
enum
Direction
{
INVALID
=
-
1
,
LEFT
,
RIGHT
,
UP
,
DOWN
};
float
get_size
()
;
///@todo
void
set_position
(
sf
::
Vector2f
);
///@todo
sf
::
Vector2f
get_position
()
;
///@todo
void
set_side
(
Direction
side
,
IRoomSide
p
r
t_side
)
;
///@todo
IRoomSide
get_side
(
Direction
side
);
///@todo
Direction
get_direction
(
IRoomSide
p
r
t_side
);
///@todo
float
get_size
()
const
noexcept
;
void
set_position
(
const
sf
::
Vector2f
&
pos
)
noexcept
;
sf
::
Vector2f
get_position
()
const
noexcept
;
void
set_side
(
Direction
side
,
std
::
shared_ptr
<
IRoomSide
>
pt
r
_side
)
noexcept
;
std
::
shared_ptr
<
IRoomSide
>
get_side
(
Direction
side
);
Direction
get_direction
(
IRoomSide
*
pt
r
_side
);
public
:
Room
(
float
size
);
///@todo
Room
(
float
size
);
public
:
std
::
array
<
std
::
shared_ptr
<
IRoomSide
>
,
4
>
m_sides
;
private
:
...
...
This diff is collapsed.
Click to expand it.
include/States/ExitState.h
+
1
−
1
View file @
581a115a
...
...
@@ -6,5 +6,5 @@ class ExitState: public IState {
public:
bool
do_step
()
override
{
return
false
;
}
public
:
ExitState
(
IStateManager
&
state_manager
);
ExitState
(
IStateManager
&
state_manager
)
:
IState
(
state_manager
)
{}
;
};
\ No newline at end of file
This diff is collapsed.
Click to expand it.
source/Draw/MyFont.cpp
+
1
−
1
View file @
581a115a
#include
"
c
onfig.h"
#include
"
C
onfig.h"
#include
"Draw/MyFont.h"
MyFont
::
MyFont
()
{
...
...
This diff is collapsed.
Click to expand it.
source/Maze_Content/Room.cpp
0 → 100644
+
38
−
0
View file @
581a115a
#include
"MazeContent/Room.h"
#include
"Config.h"
Room
::
Room
(
float
size
)
:
m_rectangle
{
{
size
,
size
}
}
{
m_rectangle
.
setOrigin
(
m_rectangle
.
getSize
()
/
2.
f
);
m_rectangle
.
setFillColor
(
config
::
GAME_COLOR_ROOM
);
}
float
Room
::
get_size
()
const
noexcept
{
return
m_rectangle
.
getSize
().
x
;
}
void
Room
::
set_position
(
const
sf
::
Vector2f
&
pos
)
noexcept
{
m_rectangle
.
setPosition
(
pos
);
}
sf
::
Vector2f
Room
::
get_position
()
const
noexcept
{
return
m_rectangle
.
getPosition
();
}
void
Room
::
set_side
(
Direction
side
,
std
::
shared_ptr
<
IRoomSide
>
ptr_side
)
noexcept
{
if
(
side
==
INVALID
)
return
;
m_sides
.
at
(
side
)
=
std
::
move
(
ptr_side
);
m_sides
.
at
(
side
)
->
prepare_for_drawing
();
}
std
::
shared_ptr
<
IRoomSide
>
Room
::
get_side
(
Direction
side
)
{
return
m_sides
.
at
(
side
);
}
Room
::
Direction
Room
::
get_direction
(
IRoomSide
*
ptr_side
)
{
if
(
m_sides
.
at
(
LEFT
).
get
()
==
ptr_side
)
return
LEFT
;
else
if
(
m_sides
.
at
(
RIGHT
).
get
()
==
ptr_side
)
return
RIGHT
;
else
if
(
m_sides
.
at
(
UP
).
get
()
==
ptr_side
)
return
UP
;
else
if
(
m_sides
.
at
(
DOWN
).
get
()
==
ptr_side
)
return
DOWN
;
return
INVALID
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
source/Maze_Content/Wall.cpp
0 → 100644
+
59
−
0
View file @
581a115a
#include
"MazeContent/Wall.h"
#include
"Config.h"
//void Wall::prepare_for_drawing() {
// sf::Vector2f pos = m_room.get_position();
// float size = config::ROOM_SIZE;
//
// switch (m_room.get_direction(this)) {
// case Room::UP:
// 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);
// break;
//
// case Room::RIGHT:
// 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);
// break;
//
// case Room::DOWN:
// 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);
// break;
//
// case Room::LEFT:
// 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);
// break;
//
// default:
// throw std::runtime_error("There is invalid side in some room");
// }
//}
//
//void Wall::prepare_for_drawing() {
// if (m_room.get_direction(this) == Room::LEFT) {
// m_line[0] = sf::Vertex{ sf::Vector2f(m_room.get_position().x - m_room.get_size() / 2,
// m_room.get_position().y - m_room.get_size() / 2), config::GAME_COLOR_WALL };
// m_line[1] = sf::Vertex{ sf::Vector2f(m_room.get_position().x - m_room.get_size() / 2,
// m_room.get_position().y + m_room.get_size() / 2), config::GAME_COLOR_WALL };
// }
// else if (m_room.get_direction(this) == Room::RIGHT) {
// m_line[0] = sf::Vertex{ sf::Vector2f(m_room.get_position().x + m_room.get_size() / 2,
// m_room.get_position().y - m_room.get_size() / 2), config::GAME_COLOR_WALL };
// m_line[1] = sf::Vertex{ sf::Vector2f(m_room.get_position().x + m_room.get_size() / 2,
// m_room.get_position().y + m_room.get_size() / 2), config::GAME_COLOR_WALL };
// }
// else if (m_room.get_direction(this) == Room::UP) {
// m_line[0] = sf::Vertex{ sf::Vector2f( m_room.get_position().x - m_room.get_size() / 2,
// m_room.get_position().y - m_room.get_size() / 2 ), config::GAME_COLOR_WALL };
// m_line[1] = sf::Vertex{ sf::Vector2f( m_room.get_position().x + m_room.get_size() / 2,
// m_room.get_position().y - m_room.get_size() / 2), config::GAME_COLOR_WALL };
// }
// else if (m_room.get_direction(this) == Room::DOWN) {
// m_line[0] = sf::Vertex{ sf::Vector2f(m_room.get_position().x - m_room.get_size() / 2,
// m_room.get_position().y + m_room.get_size() / 2), config::GAME_COLOR_WALL };
// m_line[1] = sf::Vertex{ sf::Vector2f(m_room.get_position().x + m_room.get_size() / 2,
// m_room.get_position().y + m_room.get_size() / 2), config::GAME_COLOR_WALL };
// }
//}
\ 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