First version

This commit is contained in:
2022-04-11 18:34:26 +03:00
committed by GitHub
parent d68a4f0da7
commit 37e6bd6a28
32 changed files with 824 additions and 0 deletions
+7
View File
@@ -0,0 +1,7 @@
-----Отрисовка Бонусов-----
function game.bonus.draw()
for i,v in ipairs(bonus) do
love.graphics.setColor(255, 255, 255, 255)
love.graphics.draw(v.texture, v.x-25, v.y-25)
end
end
+11
View File
@@ -0,0 +1,11 @@
function game.bonus.load()
bonus = {}
bonus.texture = {}
bonus.types = 5
bonus.textures = {}
bonus.textures.lvlUp = love.graphics.newImage("textures/bonus/lvlUp.png")
bonus.textures.laser = love.graphics.newImage("textures/bonus/laser.png")
bonus.textures.plasma = love.graphics.newImage("textures/bonus/plasma.png")
bonus.textures.health = love.graphics.newImage("textures/bonus/health.png")
bonus.textures.life = love.graphics.newImage("textures/bonus/life.png")
end
+85
View File
@@ -0,0 +1,85 @@
-----Создание Бонусов-----
function game.bonus.create(enemyX, enemyY, type)
local locBonus = {}
locBonus.type = type
locBonus.x = enemyX
locBonus.y = enemyY
locBonus.width = 50
locBonus.height = 50
locBonus.angle = 0
if type == 1 then
locBonus.texture = bonus.textures.lvlUp
elseif type == 2 then
locBonus.texture = bonus.textures.laser
elseif type == 3 then
locBonus.texture = bonus.textures.plasma
elseif type == 4 then
locBonus.texture = bonus.textures.health
elseif type == 5 then
locBonus.texture = bonus.textures.life
end
table.insert(bonus, locBonus)
end
-----Удаление Бонусов-----
function game.bonus.delete(deletedBonuses)
for i,v in ipairs(deletedBonuses) do
table.remove(bonus, v)
end
end
-----Обновление Бонусов-----
function game.bonus.update(dt)
local deletedBonuses = {}
--Перебор Бонусов--
for i,v in ipairs(bonus) do
--Обновление Координат--
v.x = v.x - dt * 250
v.y = v.y + dt * 500 * math.cos(v.angle)
v.angle = v.angle + 0.05
--Удаление Бонусов Когда Они Уходят Далеко за Экран--
if v.x < -100 then
table.insert(deletedBonuses, i)
end
if CheckCollision(v.x, v.y, v.width, v.height, player.x, player.y, player.width, player.height) then
if v.type == 1 then
player.levelUp = true
player.score = player.score + 200
elseif v.type == 2 then
player.weapon.type.new = "laser"
player.weapon.changed = true
player.score = player.score + 100
elseif v.type == 3 then
player.weapon.type.new = "plasma"
player.weapon.changed = true
player.score = player.score + 100
elseif v.type == 4 then
if player.health.current + 100 < player.health.max then
player.health.current = player.health.current + 100
else
player.health.current = player.health.max
end
player.score = player.score + 50
elseif v.type == 5 then
if player.lifes.current < player.lifes.max then
player.lifes.current = player.lifes.current + 1
end
player.score = player.score + 250
end
table.insert(deletedBonuses, i)
end
end
game.bonus.delete(deletedBonuses)
end