Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
illuna-minetest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Illuna-Minetest
illuna-minetest
Commits
3a74b840
Commit
3a74b840
authored
9 years ago
by
Loïc Blot
Browse files
Options
Downloads
Patches
Plain Diff
Player::accelerateHorizontal/Vertical should be member of LocalPlayer
parent
cfc8e447
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/localplayer.cpp
+33
-0
33 additions, 0 deletions
src/localplayer.cpp
src/localplayer.h
+4
-1
4 additions, 1 deletion
src/localplayer.h
src/player.cpp
+0
-35
0 additions, 35 deletions
src/player.cpp
src/player.h
+0
-3
0 additions, 3 deletions
src/player.h
with
37 additions
and
39 deletions
src/localplayer.cpp
+
33
−
0
View file @
3a74b840
...
...
@@ -622,3 +622,36 @@ v3s16 LocalPlayer::getStandingNodePos()
return
floatToInt
(
getPosition
()
-
v3f
(
0
,
BS
,
0
),
BS
);
}
// Horizontal acceleration (X and Z), Y direction is ignored
void
LocalPlayer
::
accelerateHorizontal
(
const
v3f
&
target_speed
,
const
f32
max_increase
)
{
if
(
max_increase
==
0
)
return
;
v3f
d_wanted
=
target_speed
-
m_speed
;
d_wanted
.
Y
=
0
;
f32
dl
=
d_wanted
.
getLength
();
if
(
dl
>
max_increase
)
dl
=
max_increase
;
v3f
d
=
d_wanted
.
normalize
()
*
dl
;
m_speed
.
X
+=
d
.
X
;
m_speed
.
Z
+=
d
.
Z
;
}
// Vertical acceleration (Y), X and Z directions are ignored
void
LocalPlayer
::
accelerateVertical
(
const
v3f
&
target_speed
,
const
f32
max_increase
)
{
if
(
max_increase
==
0
)
return
;
f32
d_wanted
=
target_speed
.
Y
-
m_speed
.
Y
;
if
(
d_wanted
>
max_increase
)
d_wanted
=
max_increase
;
else
if
(
d_wanted
<
-
max_increase
)
d_wanted
=
-
max_increase
;
m_speed
.
Y
+=
d_wanted
;
}
This diff is collapsed.
Click to expand it.
src/localplayer.h
+
4
−
1
View file @
3a74b840
...
...
@@ -45,7 +45,7 @@ class LocalPlayer : public Player
bool
isAttached
;
v3f
overridePosition
;
void
move
(
f32
dtime
,
Environment
*
env
,
f32
pos_max_d
);
void
move
(
f32
dtime
,
Environment
*
env
,
f32
pos_max_d
,
std
::
vector
<
CollisionInfo
>
*
collision_info
);
...
...
@@ -81,6 +81,9 @@ class LocalPlayer : public Player
}
private
:
void
accelerateHorizontal
(
const
v3f
&
target_speed
,
const
f32
max_increase
);
void
accelerateVertical
(
const
v3f
&
target_speed
,
const
f32
max_increase
);
// This is used for determining the sneaking range
v3s16
m_sneak_node
;
// Whether the player is allowed to sneak
...
...
This diff is collapsed.
Click to expand it.
src/player.cpp
+
0
−
35
View file @
3a74b840
...
...
@@ -111,41 +111,6 @@ Player::~Player()
clearHud
();
}
// Horizontal acceleration (X and Z), Y direction is ignored
void
Player
::
accelerateHorizontal
(
v3f
target_speed
,
f32
max_increase
)
{
if
(
max_increase
==
0
)
return
;
v3f
d_wanted
=
target_speed
-
m_speed
;
d_wanted
.
Y
=
0
;
f32
dl
=
d_wanted
.
getLength
();
if
(
dl
>
max_increase
)
dl
=
max_increase
;
v3f
d
=
d_wanted
.
normalize
()
*
dl
;
m_speed
.
X
+=
d
.
X
;
m_speed
.
Z
+=
d
.
Z
;
}
// Vertical acceleration (Y), X and Z directions are ignored
void
Player
::
accelerateVertical
(
v3f
target_speed
,
f32
max_increase
)
{
if
(
max_increase
==
0
)
return
;
f32
d_wanted
=
target_speed
.
Y
-
m_speed
.
Y
;
if
(
d_wanted
>
max_increase
)
d_wanted
=
max_increase
;
else
if
(
d_wanted
<
-
max_increase
)
d_wanted
=
-
max_increase
;
m_speed
.
Y
+=
d_wanted
;
}
v3s16
Player
::
getLightPosition
()
const
{
return
floatToInt
(
m_position
+
v3f
(
0
,
BS
+
BS
/
2
,
0
),
BS
);
...
...
This diff is collapsed.
Click to expand it.
src/player.h
+
0
−
3
View file @
3a74b840
...
...
@@ -119,9 +119,6 @@ class Player
m_speed
=
speed
;
}
void
accelerateHorizontal
(
v3f
target_speed
,
f32
max_increase
);
void
accelerateVertical
(
v3f
target_speed
,
f32
max_increase
);
v3f
getPosition
()
{
return
m_position
;
...
...
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