add vehicle test
This commit is contained in:
@@ -6,6 +6,7 @@ function update(dt) {
|
||||
updatePlayer(dt)
|
||||
updateBullets(dt)
|
||||
updateMonsters(dt)
|
||||
updateVehicles(dt)
|
||||
checkTreasure()
|
||||
checkPickups()
|
||||
checkLiquids()
|
||||
@@ -20,6 +21,23 @@ function updatePlayer(dt) {
|
||||
updateEntity(player, dt)
|
||||
}
|
||||
|
||||
function updateVehicles(dt) {
|
||||
var n, max
|
||||
for (n = 0, max = vehicles.length; n < max; n++)
|
||||
updateVehicle(vehicles[n], dt)
|
||||
}
|
||||
|
||||
function updateVehicle(vehicle, dt) {
|
||||
updateEntity(vehicle, dt)
|
||||
if (
|
||||
overlap(player.x, player.y, TILE, TILE, vehicle.x, vehicle.y, TILE, TILE)
|
||||
) {
|
||||
if (player.dy > 0 && vehicle.y - player.y > TILE / 2)
|
||||
// ! Wie mache ich hier den collision check? Achtung, die height und width des Vehicles ist immer noch 16x16
|
||||
console.log('log collision vehicle!')
|
||||
}
|
||||
}
|
||||
|
||||
function updateMonsters(dt) {
|
||||
var n, max
|
||||
for (n = 0, max = monsters.length; n < max; n++)
|
||||
@@ -28,6 +46,7 @@ function updateMonsters(dt) {
|
||||
|
||||
function updateMonster(monster, dt) {
|
||||
// monster.slimeMonster && console.log('log monster ', monster)
|
||||
|
||||
if (!monster.dead) {
|
||||
updateEntity(monster, dt)
|
||||
if (
|
||||
@@ -332,6 +351,8 @@ function collectTreasure(t) {
|
||||
}
|
||||
|
||||
function updateEntity(entity, dt) {
|
||||
entity.vehicle && console.log('log entity ', entity)
|
||||
|
||||
var wasleft = entity.dx < 0,
|
||||
wasright = entity.dx > 0,
|
||||
falling = entity.falling,
|
||||
|
||||
Reference in New Issue
Block a user