Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
srikavin committed Dec 29, 2019
1 parent aa4b52d commit f585876
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion core/assets/assets
Submodule assets updated 142 files
5 changes: 5 additions & 0 deletions core/src/me/srikavin/fbla/game/ecs/component/DisableInput.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package me.srikavin.fbla.game.ecs.component

import com.artemis.Component

class DisableInput : Component()
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import com.artemis.managers.TagManager
import com.badlogic.gdx.graphics.OrthographicCamera
import me.srikavin.fbla.game.ecs.component.Transform

class CameraFollowSystem(val followVertical: Boolean = false, val followHorizontal: Boolean = true) : BaseSystem() {
lateinit var transformMapper: ComponentMapper<Transform>
class CameraFollowSystem(private val followVertical: Boolean = false, private val followHorizontal: Boolean = true) : BaseSystem() {
private lateinit var transformMapper: ComponentMapper<Transform>

@Wire
lateinit var camera: OrthographicCamera
Expand Down
12 changes: 6 additions & 6 deletions core/src/me/srikavin/fbla/game/ecs/system/InputSystem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@ package me.srikavin.fbla.game.ecs.system

import com.artemis.ComponentMapper
import com.artemis.annotations.All
import com.artemis.annotations.Exclude
import com.artemis.annotations.Wire
import com.artemis.systems.IteratingSystem
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.math.Vector2
import com.badlogic.gdx.physics.box2d.*
import me.srikavin.fbla.game.Actions
import me.srikavin.fbla.game.ecs.component.DisableInput
import me.srikavin.fbla.game.ecs.component.PhysicsBody
import me.srikavin.fbla.game.ecs.component.PlayerControlled
import me.srikavin.fbla.game.ecs.component.Transform
import me.srikavin.fbla.game.graphics.player_foot_fixture_id
import me.srikavin.fbla.game.physics.ContactListenerManager
import java.util.function.BiConsumer

private const val JUMP_DELAY_SEC = 1.5f
private const val MAX_HORIZONTAL_VELOCITY = 7f
Expand All @@ -23,6 +24,7 @@ private val LEFT_FORCE = Vector2(-50f, 10.0f)
private val RIGHT_FORCE = Vector2(50f, 10.0f)

@All(PlayerControlled::class, PhysicsBody::class, Transform::class)
@Exclude(DisableInput::class)
class InputSystem(private val listenerManager: ContactListenerManager) : IteratingSystem() {
private lateinit var playerControlledMapper: ComponentMapper<PlayerControlled>
private lateinit var physicsBodyMapper: ComponentMapper<PhysicsBody>
Expand Down Expand Up @@ -66,16 +68,14 @@ class InputSystem(private val listenerManager: ContactListenerManager) : Iterati
override fun process(entityId: Int) {
val body = physicsBodyMapper[entityId].body

playerControlledMapper[entityId].bindings.bindings.forEach(BiConsumer { action, keyCode ->
playerControlledMapper[entityId].bindings.bindings.forEach { (action, keyCode) ->
if (Gdx.input.isKeyPressed(keyCode)) {
when (action) {
Actions.JUMP -> {
if (allowJump) {
allowJump = false
} else {
return@BiConsumer
body.applyLinearImpulse(JUMP_IMPULSE, body.position, true)
}
body.applyLinearImpulse(JUMP_IMPULSE, body.position, true)
}
Actions.MOVE_LEFT -> {
if (body.linearVelocity.x > -MAX_HORIZONTAL_VELOCITY) {
Expand All @@ -90,7 +90,7 @@ class InputSystem(private val listenerManager: ContactListenerManager) : Iterati
Actions.USE -> TODO()
}
}
})
}

}

Expand Down
2 changes: 1 addition & 1 deletion core/src/me/srikavin/fbla/game/ecs/system/PhysicsSystem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class PhysicsSystem(var physicsWorld: World, private val contactManager: Contact
val footBox = FixtureDef().apply {
this.isSensor = true
this.shape = PolygonShape().apply {
setAsBox(0.4f, 0.1f, Vector2(0f, -1f), 0f)
setAsBox(0.5f, 0.05f, Vector2(0f, -1f), 0f)
}
}

Expand Down
7 changes: 5 additions & 2 deletions core/src/me/srikavin/fbla/game/ecs/system/TriggerSystem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ import me.srikavin.fbla.game.EntityInt
import me.srikavin.fbla.game.ecs.component.MapTrigger
import me.srikavin.fbla.game.ecs.component.PhysicsBody
import me.srikavin.fbla.game.physics.ContactListenerManager
import me.srikavin.fbla.game.trigger.TriggerManager


@All(MapTrigger::class, PhysicsBody::class)
class TriggerSystem(private val listenerManager: ContactListenerManager) : IteratingSystem() {
private lateinit var triggerMapper: ComponentMapper<MapTrigger>
private lateinit var physicsMapper: ComponentMapper<PhysicsBody>

private val triggerManager = TriggerManager()

@Wire
lateinit var camera: OrthographicCamera

Expand Down Expand Up @@ -51,9 +54,9 @@ class TriggerSystem(private val listenerManager: ContactListenerManager) : Itera
if (triggerMapper.has(e)) {
val trigger = triggerMapper[e]

// Remove body outside of physics simulation
// Handle outside of physics simulation
Gdx.app.postRunnable {
world.delete(e)
triggerManager.handle(world, e, other.userData as Int, trigger)
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/me/srikavin/fbla/game/map/MapLoader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class MapLoader(private val assetManager: AssetManager, private val world: World
}
info { vertices.joinToString { e -> e.toString() } }

if (vertices.size > 8) {
if (vertices.size / 2 >= 8) {
info { "Polygon has greater than 8 vertices [${vertices.size / 2}] and will be triangulated" }
val triangulator = EarClippingTriangulator()
val triangles = triangulator.computeTriangles(vertices)
Expand Down

0 comments on commit f585876

Please sign in to comment.