Added DoubleJump component and JumpSpeed in Player component so jumpheight can be adjusted for regular jump and double jump.

This commit is contained in:
William Moberg
2016-02-25 12:12:44 +01:00
parent da1c7b3093
commit cd315bbaa0
8 changed files with 38 additions and 6 deletions
+1
View File
@@ -46,4 +46,5 @@
<xs:include schemaLocation="Components/Page.xsd"/>
<xs:include schemaLocation="Components/SpriteIndicator.xsd"/>
<xs:include schemaLocation="Components/Button.xsd"/>
<xs:include schemaLocation="Components/DoubleJump.xsd"/>
</xs:schema>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<DoubleJump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="DoubleJump.xsd">
<DoubleJumpSpeed>4.0</DoubleJumpSpeed>
</DoubleJump>
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="types">
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
<xs:element name="DoubleJump">
<xs:annotation><xs:documentation>Enables a Player to double jump.</xs:documentation></xs:annotation>
<xs:complexType>
<xs:all>
<xs:element name="DoubleJumpSpeed" type="t:float" minOccurs="0">
<xs:annotation><xs:documentation>Vertical velocity set on double jump.</xs:documentation></xs:annotation>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
+1
View File
@@ -2,5 +2,6 @@
<Player xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Player.xsd">
<MovementSpeed>3</MovementSpeed>
<CrouchSpeed>1.5</CrouchSpeed>
<JumpSpeed>4.0</JumpSpeed>
<CurrentWishDirection X="0" Y="0" Z="0"/>
</Player>
+3
View File
@@ -11,6 +11,9 @@
<xs:all>
<xs:element name="MovementSpeed" type="t:float" minOccurs="0"/>
<xs:element name="CrouchSpeed" type="t:float" minOccurs="0"/>
<xs:element name="JumpSpeed" type="t:float" minOccurs="0">
<xs:annotation><xs:documentation>Vertical velocity set when jumping.</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="CurrentWishDirection" type="t:Vector" minOccurs="0"/>
</xs:all>
</xs:complexType>
+1
View File
@@ -11,6 +11,7 @@
</c:AssaultWeapon>
<c:Collidable/>
<c:DashAbility/>
<c:DoubleJump/>
<c:Health/>
<c:Physics>
<PrevOrigin X="0" Y="0.772000015" Z="0"/>
+1
View File
@@ -11,6 +11,7 @@
</c:AssaultWeapon>
<c:Collidable/>
<c:DashAbility/>
<c:DoubleJump/>
<c:Health/>
<c:Physics>
<PrevOrigin X="0" Y="0.772000015" Z="0"/>
+11 -6
View File
@@ -116,12 +116,18 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
ImGui::Text("velocity: (%f, %f, %f) |%f|", velocity.x, velocity.y, velocity.z, glm::length(velocity));
}
//you cant jump and dash at the same time - since there is no friction in the air and we would thus dash much further in the air
if (!controller->PlayerIsDashing() && controller->Jumping() && !controller->Crouching() && (isOnGround || !controller->DoubleJumping())) {
(bool)cPhysics["IsOnGround"] = false;
if (isOnGround) {
controller->SetDoubleJumping(false);
}
//If player presses Jump and is not crouching.
if (controller->Jumping() && !controller->Crouching()) {
if (isOnGround) {
controller->SetDoubleJumping(false);
} else {
(bool)cPhysics["IsOnGround"] = false;
velocity.y = player["Player"]["JumpSpeed"];
} else if (player.HasComponent("DoubleJump") && !controller->DoubleJumping()) {
//Enter here if player can double jump and is doing so.
(bool)cPhysics["IsOnGround"] = false;
velocity.y = player["DoubleJump"]["DoubleJumpSpeed"];
if (IsClient) {
//put a hexagon at the players feet
auto hexagonEffect = ResourceManager::Load<EntityFile>("Schema/Entities/DoubleJumpHexagon.xml");
@@ -134,7 +140,6 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
m_EventBroker->Publish(e);
}
}
velocity.y = 4.f;
}
if (player.HasComponent("AABB")) {