Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TDP005
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jonas Törnqvist
TDP005
Commits
29e513ac
Commit
29e513ac
authored
3 years ago
by
Jonas Törnqvist
Browse files
Options
Downloads
Patches
Plain Diff
s
parent
0064371f
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Project/Player.cc
+6
-3
6 additions, 3 deletions
Project/Player.cc
Project/Player.h
+1
-0
1 addition, 0 deletions
Project/Player.h
Project/Player.o
+0
-0
0 additions, 0 deletions
Project/Player.o
Project/game
+0
-0
0 additions, 0 deletions
Project/game
with
7 additions
and
3 deletions
Project/Player.cc
+
6
−
3
View file @
29e513ac
...
...
@@ -3,7 +3,7 @@
Player
::
Player
(
float
width
,
float
height
,
float
x_pos
,
float
y_pos
,
float
velocity
)
:
player_size
{
width
,
height
},
player_pos
{
x_pos
,
y_pos
},
player
{
player_size
},
velocity
{
velocity
},
velocity_y
{
velocity
},
jumping
{
false
},
distance
{},
on_ground
{
true
},
spawn_y_pos
{
y_pos
}
jumping
{
false
},
falling
{
false
},
distance
{},
on_ground
{
true
},
spawn_y_pos
{
y_pos
}
{}
sf
::
Vector2f
Player
::
get_location
()
const
...
...
@@ -31,7 +31,8 @@ void Player::check_collision(Block & b, std::string const& type)
if
(
player_pos
.
y
>=
b
.
get_pos
().
y
+
b
.
get_size
().
y
-
10
)
//Hoppar in i något
{
on_ground
=
false
;
velocity_y
=
-
velocity_y
;
//velocity_y = -velocity_y;
velocity_y
=
-
1
}
else
if
(
player_pos
.
y
<=
b
.
get_pos
().
y
-
40
)
//landar på något
{
...
...
@@ -90,7 +91,9 @@ void Player::move(sf::Time & _delta)
}
else
if
(
player_pos
.
y
<
spawn_y_pos
)
{
velocity_y
=
-
velocity_y
;
velocity_y
=
0
;
jumping
=
true
;
//falling = true;
}
}
This diff is collapsed.
Click to expand it.
Project/Player.h
+
1
−
0
View file @
29e513ac
...
...
@@ -24,6 +24,7 @@ private:
float
velocity
{};
float
velocity_y
{};
bool
jumping
{};
bool
falling
{};
float
distance
{};
bool
on_ground
{};
const
float
spawn_y_pos
{};
...
...
This diff is collapsed.
Click to expand it.
Project/Player.o
+
0
−
0
View file @
29e513ac
No preview for this file type
This diff is collapsed.
Click to expand it.
Project/game
+
0
−
0
View file @
29e513ac
No preview for this file type
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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