Skip to content
Snippets Groups Projects
Commit f83302b0 authored by Ingrid Louise Lagethon Heck's avatar Ingrid Louise Lagethon Heck
Browse files

Merge branch '8-create-movement' into 'master'

Added jump with gravity component

Closes #8

See merge request !5
parents ed1c1db6 38d38985
No related branches found
No related tags found
2 merge requests!7Master,!5Added jump with gravity component
Pipeline #216126 passed
......@@ -7,7 +7,10 @@ import tdt4240.netrunner.model.util.Vec2f
class GravityComponent(val gravSpeed: Vec2f = Vec2f(0f, GRAVITY)) : Component {
override val componentName: String = this::class.java.name
companion object {
const val GRAVITY = 9.81f
const val GRAVITY = -700.0f
//TODO:
}
}
\ No newline at end of file
package tdt4240.netrunner.model.game.factories
import tdt4240.netrunner.model.game.Entity
import tdt4240.netrunner.model.game.components.dynamic.GravityComponent
import tdt4240.netrunner.model.game.components.dynamic.PositionComponent
import tdt4240.netrunner.model.game.components.dynamic.VelocityComponent
import tdt4240.netrunner.model.game.components.living.LivingComponent
......@@ -37,7 +38,8 @@ class PlayerFactory {
PositionComponent(initPosition),
VelocityComponent(Vec2f()),
PlayerComponent(username, color, uid),
LivingComponent(100, DEFAULT_MAX_PLAYER_SPEED)
LivingComponent(100, DEFAULT_MAX_PLAYER_SPEED),
GravityComponent()
))
}
......
......@@ -6,6 +6,7 @@ import tdt4240.netrunner.game.WorldGen
import tdt4240.netrunner.game.controllers.MovementController
import tdt4240.netrunner.model.game.EcsEngine
import tdt4240.netrunner.model.game.Entity
import tdt4240.netrunner.model.game.components.dynamic.GravityComponent
import tdt4240.netrunner.model.game.components.dynamic.VelocityComponent
import tdt4240.netrunner.model.game.factories.PlayerFactory
import tdt4240.netrunner.model.requests.JoinGameRequest
......@@ -80,7 +81,7 @@ class GameRoom(val socketRoomID: String, val server: SocketIoServer, val control
}
}
val delta = (System.currentTimeMillis() - prevTime).toDouble()
val delta = ((System.currentTimeMillis() - prevTime).toDouble())/1000.0
ecs.tick(delta)
......@@ -201,6 +202,8 @@ class GameRoom(val socketRoomID: String, val server: SocketIoServer, val control
}
}
}
// }}}
override fun toString(): String {
......@@ -221,7 +224,7 @@ class GameRoom(val socketRoomID: String, val server: SocketIoServer, val control
const val STANDARD_FIELD_LENGTH = 40_000
const val PLAYER_JUMP_VELOCITY = 10f
const val PLAYER_JUMP_VELOCITY = 600f
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment