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
Чаадаев Алексей Константинович
3 laba
Commits
dd9b4fe1
Commit
dd9b4fe1
authored
2 months ago
by
Чаадаев Алексей Константинович
Browse files
Options
Download
Patches
Plain Diff
the part with the rooms has been startes
parent
79128b9e
main
No related merge requests found
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
CMakeLists.txt
+1
-1
CMakeLists.txt
Sources/Button/Button.h
+1
-1
Sources/Button/Button.h
Sources/IDraw_n_IPrep/IDraw_n_IPrep.h
+15
-0
Sources/IDraw_n_IPrep/IDraw_n_IPrep.h
Sources/Menu/Menu.h
+1
-1
Sources/Menu/Menu.h
Sources/Room/Room.cpp
+33
-0
Sources/Room/Room.cpp
Sources/Room/Room.h
+83
-0
Sources/Room/Room.h
with
134 additions
and
3 deletions
+134
-3
CMakeLists.txt
+
1
−
1
View file @
dd9b4fe1
...
...
@@ -7,6 +7,6 @@ set(BUILD_SHARED_LIBS FALSE)
FetchContent_Declare
(
game_pacman GIT_REPOSITORY https://github.com/SFML/SFML.git GIT_TAG 2.6.1
)
FetchContent_MakeAvailable
(
game_pacman
)
add_executable
(
game_pacman main.cpp
"Sources/Application/App_n_IState.cpp"
"Sources/States/States.cpp"
"Sources/Window/Window.cpp"
"Sources/Button/Button.cpp"
"Sources/SelectCommand/SelectCommand.cpp"
"Sources/Font/MyFont.cpp"
"Sources/Menu/Menu.cpp"
)
add_executable
(
game_pacman main.cpp
"Sources/Application/App_n_IState.cpp"
"Sources/States/States.cpp"
"Sources/Window/Window.cpp"
"Sources/Button/Button.cpp"
"Sources/SelectCommand/SelectCommand.cpp"
"Sources/Font/MyFont.cpp"
"Sources/Menu/Menu.cpp"
"Sources/Room/Room.cpp"
)
target_link_libraries
(
game_pacman PUBLIC sfml-window sfml-graphics sfml-system
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Sources/Button/Button.h
+
1
−
1
View file @
dd9b4fe1
...
...
@@ -3,7 +3,7 @@
#include
<memory>
#include
"../SelectCommand/SelectCommand.h"
#include
"../IDraw
able/IDrawable
.h"
#include
"../IDraw
_n_IPrep/IDraw_n_IPrep
.h"
class
Button
:
public
IDrawable
{
...
...
This diff is collapsed.
Click to expand it.
Sources/IDraw
able/IDrawable
.h
→
Sources/IDraw
_n_IPrep/IDraw_n_IPrep
.h
+
15
−
0
View file @
dd9b4fe1
...
...
@@ -5,4 +5,11 @@ class IDrawable {
public:
virtual
void
draw_into
(
sf
::
RenderWindow
&
window
)
const
=
0
;
virtual
~
IDrawable
()
=
default
;
};
class
IPreparable
:
public
IDrawable
{
public:
virtual
void
prepare_for_drawing
()
=
0
;
virtual
~
IPreparable
()
=
default
;
//здесь тоже, потому что он чисто virtual класс
};
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Sources/Menu/Menu.h
+
1
−
1
View file @
dd9b4fe1
...
...
@@ -2,7 +2,7 @@
#include
<array>
#include
"../IDraw
able/IDrawable
.h"
#include
"../IDraw
_n_IPrep/IDraw_n_IPrep
.h"
#include
"../Application/App_n_IState.h"
#include
"../Button/Button.h"
...
...
This diff is collapsed.
Click to expand it.
Sources/Room/Room.cpp
0 → 100644
+
33
−
0
View file @
dd9b4fe1
#include
"Room.h"
//MAZE
Maze
::
Maze
(
std
::
vector
<
std
::
unique_ptr
<
Room
>>&
rooms
)
:
m_rooms
(
std
::
move
(
rooms
))
{}
//move потому что вектор с unique
void
Maze
::
draw_into
(
sf
::
RenderWindow
&
window
)
const
{
for
(
const
std
::
unique_ptr
<
Room
>&
ptr_room
:
m_rooms
)
ptr_room
->
draw_into
(
window
);
//-> потому что в ptr_room указатель, который надо разыменовать
}
//IENTITY
void
IEntity
::
set_location
(
Room
*
ptr_room
)
{
m_ptr_room
=
ptr_room
;
this
->
prepare_for_drawing
();
//отрисовываем себя
}
Room
*
IEntity
::
get_location
()
{
return
m_ptr_room
;
}
//PASS
Pass
::
Pass
(
Room
&
room1
,
Room
&
room2
)
:
m_room1
(
room1
),
m_room2
(
room2
)
{}
void
Pass
::
draw_into
(
sf
::
RenderWindow
&
window
)
const
{};
void
Pass
::
prepare_for_drawing
()
{};
//WALL
Wall
::
Wall
(
Room
&
room
)
:
m_room
(
room
)
{}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Sources/Room/Room.h
0 → 100644
+
83
−
0
View file @
dd9b4fe1
#pragma once
#include
<array>
#include
<vector>
#include
"../IDraw_n_IPrep/IDraw_n_IPrep.h"
class
Room
;
class
Maze
:
public
IDrawable
{
public:
Maze
(
std
::
vector
<
std
::
unique_ptr
<
Room
>>&
rooms
);
void
draw_into
(
sf
::
RenderWindow
&
window
)
const
override
;
private:
std
::
vector
<
std
::
unique_ptr
<
Room
>>
m_rooms
;
};
class
IEntity
:
public
IPreparable
{
//мб entity отсюда надо убрать
public:
void
set_location
(
Room
*
ptr_room
);
Room
*
get_location
();
protected:
Room
*
m_ptr_room
;
//не unique тк room без него живет
};
class
IRoomSide
:
public
IPreparable
{
public:
virtual
~
IRoomSide
()
=
default
;
virtual
void
enter
(
IEntity
*
entity
)
=
0
;
};
class
Pass
:
public
IRoomSide
{
public:
Pass
(
Room
&
room1
,
Room
&
room2
);
void
draw_into
(
sf
::
RenderWindow
&
window
)
const
override
;
void
prepare_for_drawing
()
override
;
void
enter
(
IEntity
*
entity
)
override
;
//РЕАЛИЗОВАТЬ
private:
Room
&
m_room1
;
Room
&
m_room2
;
};
class
Wall
:
public
IRoomSide
{
public:
Wall
(
Room
&
room
);
void
draw_into
(
sf
::
RenderWindow
&
window
)
const
override
;
//РЕАЛИЗОВАТЬ
void
prepare_for_drawing
()
override
;
//РЕАЛИЗОВАТЬ
void
enter
(
IEntity
*
entity
)
override
;
//РЕАЛИЗОВАТЬ
private:
Room
&
m_room
;
sf
::
Vertex
m_line
[
2
];
};
class
Room
:
public
IDrawable
{
public:
enum
Direction
{
INVALID
=
-
1
,
LEFT
,
RIGHT
,
UP
,
DOWN
};
Room
(
float
size
);
//РЕАЛИЗОВАТЬ
float
get_size
();
//РЕАЛИЗОВАТЬ
void
set_position
(
sf
::
Vector2f
pos
);
//РЕАЛИЗОВАТЬ
sf
::
Vector2f
get_position
();
//РЕАЛИЗОВАТЬ
void
set_side
(
Direction
side
,
std
::
shared_ptr
<
IRoomSide
>
ptr_side
);
//РЕАЛИЗОВАТЬ // shared_ptr, потому что одна IRoomSide будет у нескольких комнат
IRoomSide
*
get_side
(
Direction
side
);
//РЕАЛИЗОВАТЬ
Direction
get_direction
(
IRoomSide
*
ptr_side
);
//РЕАЛИЗОВАТЬ
void
draw_into
(
sf
::
RenderWindow
&
window
)
const
override
;
//РЕАЛИЗОВАТЬ
public
:
std
::
array
<
std
::
shared_ptr
<
IRoomSide
>
,
4
>
m_sides
;
private
:
sf
::
RectangleShape
m_rectangle
;
};
\ 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