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
a134be1b
Commit
a134be1b
authored
2 weeks ago
by
Сулимов Игорь Андреевич
Browse files
Options
Download
Patches
Plain Diff
Test commit
parent
2c8bed1e
main
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
assets/PacmanTexture.png
+0
-0
assets/PacmanTexture.png
source/MazeContent/Entities/DynamicEntities/Enemy.cpp
+8
-10
source/MazeContent/Entities/DynamicEntities/Enemy.cpp
source/MazeContent/Entities/Pacman.cpp
+9
-8
source/MazeContent/Entities/Pacman.cpp
with
17 additions
and
18 deletions
+17
-18
assets/PacmanTexture.png
+
0
−
0
View replaced file @
2c8bed1e
View file @
a134be1b
206 KB
|
W:
|
H:
780 KB
|
W:
|
H:
2-up
Swipe
Onion skin
This diff is collapsed.
Click to expand it.
source/MazeContent/Entities/DynamicEntities/Enemy.cpp
+
8
−
10
View file @
a134be1b
...
...
@@ -18,24 +18,22 @@ void Enemy::prepare_for_drawing() {
m_sprite
.
setTexture
(
m_ptr_texture
->
get_texture
());
if
(
m_direction
==
config
::
RIGHT
)
{
m_sprite
.
setTextureRect
(
sf
::
IntRect
(
0
,
0
,
m_ptr_texture
->
get_texture
().
getSize
().
x
/
m_rect_count
,
(
m_ptr_texture
->
get_texture
().
getSize
().
y
-
2
)
/
4
));
(
m_ptr_texture
->
get_texture
().
getSize
().
y
)
/
4
));
}
else
if
(
m_direction
==
config
::
DOWN
)
{
m_sprite
.
setTextureRect
(
sf
::
IntRect
(
0
,
(
m_ptr_texture
->
get_texture
().
getSize
().
y
-
2
)
/
(
4
),
m_ptr_texture
->
get_texture
().
getSize
().
x
/
m_rect_count
,
(
m_ptr_texture
->
get_texture
().
getSize
().
y
-
2
)
/
(
4
)));
m_sprite
.
setTextureRect
(
sf
::
IntRect
(
0
,
(
m_ptr_texture
->
get_texture
().
getSize
().
y
)
/
(
4
),
m_ptr_texture
->
get_texture
().
getSize
().
x
/
m_rect_count
,
(
m_ptr_texture
->
get_texture
().
getSize
().
y
)
/
(
4
)));
}
else
if
(
m_direction
==
config
::
LEFT
)
{
m_sprite
.
setTextureRect
(
sf
::
IntRect
(
0
,
(
m_ptr_texture
->
get_texture
().
getSize
().
y
-
2
)
/
(
m_rect_count
),
m_ptr_texture
->
get_texture
().
getSize
().
x
/
m_rect_count
,
(
m_ptr_texture
->
get_texture
().
getSize
().
y
-
2
)
/
4
));
m_sprite
.
setTextureRect
(
sf
::
IntRect
(
0
,
(
m_ptr_texture
->
get_texture
().
getSize
().
y
)
/
(
m_rect_count
),
m_ptr_texture
->
get_texture
().
getSize
().
x
/
m_rect_count
,
(
m_ptr_texture
->
get_texture
().
getSize
().
y
)
/
4
));
}
else
if
(
m_direction
==
config
::
UP
)
{
m_sprite
.
setTextureRect
(
sf
::
IntRect
(
0
,
3
*
(
m_ptr_texture
->
get_texture
().
getSize
().
y
-
2
)
/
(
2
*
m_rect_count
),
m_ptr_texture
->
get_texture
().
getSize
().
x
/
m_rect_count
,
(
m_ptr_texture
->
get_texture
().
getSize
().
y
-
2
)));
m_sprite
.
setTextureRect
(
sf
::
IntRect
(
0
,
3
*
(
m_ptr_texture
->
get_texture
().
getSize
().
y
)
/
(
2
*
m_rect_count
),
m_ptr_texture
->
get_texture
().
getSize
().
x
/
m_rect_count
,
(
m_ptr_texture
->
get_texture
().
getSize
().
y
)));
}
m_sprite
.
setPosition
(
m_ptr_room
->
get_position
()
+
sf
::
Vector2f
(
-
20
,
-
20
));
m_sprite
.
setScale
(
0.2
,
0.2
);
// m_rectangle.setPosition(m_ptr_room->get_position());
m_sprite
.
setScale
(
0.15
,
0.15
);
}
void
Enemy
::
draw_into
(
sf
::
RenderWindow
&
window
)
const
{
// window.draw(m_rectangle);
window
.
draw
(
m_sprite
);
}
...
...
This diff is collapsed.
Click to expand it.
source/MazeContent/Entities/Pacman.cpp
+
9
−
8
View file @
a134be1b
...
...
@@ -17,19 +17,20 @@ void Pacman::prepare_for_drawing() {
m_sprite
.
setTexture
(
m_ptr_texture
->
get_texture
());
if
(
m_direction
==
config
::
RIGHT
)
{
m_sprite
.
setTextureRect
(
sf
::
IntRect
(
0
,
0
,
m_ptr_texture
->
get_texture
().
getSize
().
x
/
m_rect_count
,
(
m_ptr_texture
->
get_texture
().
getSize
().
y
-
2
)
/
4
));
(
m_ptr_texture
->
get_texture
().
getSize
().
y
)
/
4
));
m_sprite
.
setOrigin
(
m_ptr_texture
->
get_texture
().
getSize
().
x
/
2
+
5
,
m_ptr_texture
->
get_texture
().
getSize
().
y
/
2
+
5
);
}
else
if
(
m_direction
==
config
::
DOWN
)
{
m_sprite
.
setTextureRect
(
sf
::
IntRect
(
0
,
(
m_ptr_texture
->
get_texture
().
getSize
().
y
-
2
)
/
(
4
),
m_ptr_texture
->
get_texture
().
getSize
().
x
/
m_rect_count
,
(
m_ptr_texture
->
get_texture
().
getSize
().
y
-
2
)
/
(
4
)));
m_sprite
.
setTextureRect
(
sf
::
IntRect
(
0
,
(
m_ptr_texture
->
get_texture
().
getSize
().
y
)
/
(
4
),
m_ptr_texture
->
get_texture
().
getSize
().
x
/
m_rect_count
,
(
m_ptr_texture
->
get_texture
().
getSize
().
y
)
/
(
4
)));
}
else
if
(
m_direction
==
config
::
LEFT
)
{
m_sprite
.
setTextureRect
(
sf
::
IntRect
(
0
,
(
m_ptr_texture
->
get_texture
().
getSize
().
y
-
2
)
/
(
m_rect_count
),
m_ptr_texture
->
get_texture
().
getSize
().
x
/
m_rect_count
,
(
m_ptr_texture
->
get_texture
().
getSize
().
y
-
2
)
/
4
));
m_sprite
.
setTextureRect
(
sf
::
IntRect
(
0
,
(
m_ptr_texture
->
get_texture
().
getSize
().
y
)
/
(
m_rect_count
),
m_ptr_texture
->
get_texture
().
getSize
().
x
/
m_rect_count
,
(
m_ptr_texture
->
get_texture
().
getSize
().
y
)
/
4
));
}
else
if
(
m_direction
==
config
::
UP
)
{
m_sprite
.
setTextureRect
(
sf
::
IntRect
(
0
,
3
*
(
m_ptr_texture
->
get_texture
().
getSize
().
y
-
2
)
/
(
2
*
m_rect_count
),
m_ptr_texture
->
get_texture
().
getSize
().
x
/
m_rect_count
,
(
m_ptr_texture
->
get_texture
().
getSize
().
y
-
2
)));
m_sprite
.
setTextureRect
(
sf
::
IntRect
(
0
,
3
*
(
m_ptr_texture
->
get_texture
().
getSize
().
y
)
/
(
2
*
m_rect_count
),
m_ptr_texture
->
get_texture
().
getSize
().
x
/
m_rect_count
,
(
m_ptr_texture
->
get_texture
().
getSize
().
y
)));
}
m_sprite
.
setPosition
(
m_ptr_room
->
get_position
()
+
sf
::
Vector2f
(
-
20
,
-
20
));
m_sprite
.
setScale
(
0.
2
5
,
0.
2
5
);
m_sprite
.
setScale
(
0.
1
5
,
0.
1
5
);
}
void
Pacman
::
next_animation
()
{
...
...
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