diff options
| -rw-r--r-- | config.lua | 23 | ||||
| -rw-r--r-- | logic/MapGenerator.lua | 4 | ||||
| -rw-r--r-- | objects/Player.lua | 8 | ||||
| -rw-r--r-- | objects/Shot.lua | 8 | ||||
| -rw-r--r-- | render/draws/objects.lua | 2 |
5 files changed, 25 insertions, 20 deletions
@@ -3,7 +3,6 @@ config = { debug = false, lang = "zh", - playerShieldTime = 3, lootSize = 5, heartSize = 15, @@ -19,16 +18,20 @@ config = { defaultRoomW = 0.85, defaultRoomH = 0.8, - bulletSpeed = 300, - bulletSize = 15, - summonMargin = 30, - defaultPlayerSpeed = 100, - playerShootCooldown = 0.2, + bullet = { + speed = 300, + size = 15, + }, player = { size = 20, + speed = 100, + shieldTime = 3, + shoot = { + cooldown = 0.2, + }, punch = { radius = 15, angle = 120, @@ -47,8 +50,10 @@ config = { mobSummonDelay = 1, }, - initialMapSize = 7, - extendedMapSize = 5, + map = { + initialRoomCount = 7, + extendedRoomCount = 5, + }, defaultMusic = "briskFight" } @@ -81,7 +86,7 @@ function initGame() G.player = Player:new() - G.allRooms = mapGen.generate(config.initialMapSize, true) + G.allRooms = mapGen.generate(config.map.initialRoomCount, true) G.currentRoom = G.allRooms[1] G.currentRoom:init() diff --git a/logic/MapGenerator.lua b/logic/MapGenerator.lua index f1f45df..ae7c29b 100644 --- a/logic/MapGenerator.lua +++ b/logic/MapGenerator.lua @@ -7,7 +7,7 @@ function mapGenerator.generate(roomCount, initial) local map = { firstRoom } local available = utils.copy(map) - for i = 2, (roomCount or config.initialMapSize) do + for i = 2, (roomCount or config.map.initialRoomCount) do -- connect the room with a new room local newRoom = Room:new() local prevRoom = utils.any(available) @@ -26,7 +26,7 @@ end function mapGenerator.continue(roomCount, from) -- continue game by extending the map - local newMap = mapGenerator.generate(roomCount or config.extendedMapSize, true) + local newMap = mapGenerator.generate(roomCount or config.map.extendedRoomCount, true) local room = from or G.currentRoom -- try extending from the last room diff --git a/objects/Player.lua b/objects/Player.lua index d515a5f..9b36dd9 100644 --- a/objects/Player.lua +++ b/objects/Player.lua @@ -14,7 +14,7 @@ function Player.new() y = love.graphics.getHeight() / 2, r = config.player.size, zoom = 1/16, - speed = config.defaultPlayerSpeed, + speed = config.player.speed, shieldedTill = 0, hearts = { "redheart", "redheart", "redheart", "shinyheart", "shinyheart", "stickyheart" }, facing = Direction.DOWN, @@ -91,7 +91,7 @@ function Player:shoot(target) bullets.fire(currentBullet, target, self) table.remove(self.hearts) - self.shootCooldown = G.time + config.playerShootCooldown + self.shootCooldown = G.time + config.player.shoot.cooldown end function Player:punchCoolingDown() @@ -158,7 +158,7 @@ function Player:onContact(other, contact) self.knocked = G.time + config.player.knockback.duration self.physicsBody:applyLinearImpulse(knockbackX, knockbackY) -- shield this player - self.shieldedTill = G.time + config.playerShieldTime + self.shieldedTill = G.time + config.player.shieldTime end end end @@ -170,7 +170,7 @@ function Player:update(dt) -- deal with speed up time if self.speedUpTill and self.speedUpTill < G.time then - self.speed = config.defaultPlayerSpeed + self.speed = config.player.speed self.speedUpTill = nil end diff --git a/objects/Shot.lua b/objects/Shot.lua index 35c7514..48e5869 100644 --- a/objects/Shot.lua +++ b/objects/Shot.lua @@ -9,16 +9,16 @@ function Shot:new(bulletType, target, firer, friendly) local length = math.sqrt(vx*vx + vy*vy) local cos, sin = vx / length, vy / length - local offset = (config.bulletSize + (firer.physicsShape and firer.physicsShape:getRadius() or 0)) / 2 + local offset = (config.bullet.size + (firer.physicsShape and firer.physicsShape:getRadius() or 0)) / 2 local fireX = firer.x + cos * offset local fireY = firer.y + sin * offset local obj = { type = bulletType, x = fireX, y = fireY, - speed = { x = cos*config.bulletSpeed, y = sin*config.bulletSpeed }, + speed = { x = cos*config.bullet.speed, y = sin*config.bullet.speed }, orientation = math.asin(sin), - r = config.bulletSize, + r = config.bullet.size, damage = (bulletData[bulletType] and bulletData[bulletType].damage) or 100, mass = (bulletData[bulletType] and bulletData[bulletType].mass) or 0.1, friendly = friendly == nil and true or friendly @@ -26,7 +26,7 @@ function Shot:new(bulletType, target, firer, friendly) setmetatable(obj, Shot) - G.BodyLifeCycleManager:create(obj, config.bulletSize, "dynamic") + G.BodyLifeCycleManager:create(obj, config.bullet.size, "dynamic") return obj end diff --git a/render/draws/objects.lua b/render/draws/objects.lua index 0c95a0e..11192ad 100644 --- a/render/draws/objects.lua +++ b/render/draws/objects.lua @@ -89,7 +89,7 @@ end function draws.bullets() for k, bullet in pairs(G.currentRoom.objects.shots) do local x, y, angle = bullet.x, bullet.y, bullet.orientation - sprite.draw(bullet.type, x, y, angle, config.bulletSize, config.bulletSize) + sprite.draw(bullet.type, x, y, angle, config.bullet.size, config.bullet.size) end end |
