diff --git a/main.lua b/main.lua new file mode 100644 index 0000000..9f63529 --- /dev/null +++ b/main.lua @@ -0,0 +1,172 @@ +-----ЗАГРУЗКА СТОРОННИХ ФАЙЛОВ----- + +require "scripts/mainMenu" --функции связанные с главным меню +require "scripts/gameMode" --функции связанные с экраном игры +require "scripts/gameInterface" --функции связанные с интерфейсом игры + +require "scripts/player/draw" --функции связанные с отрисовкой игрока +require "scripts/player/update" --функции связанные с обновлением игрока +require "scripts/player/load" --функции связанные с загрузкой игрока + +require "scripts/enemy/draw" --функции связанные с отрисовкой врагов +require "scripts/enemy/update" --функции связанные с обновлением врагов +require "scripts/enemy/load" --функции связанные с загрузкой врагов + +require "scripts/bonus/draw" --функции связанные с отрисовкой бонусов +require "scripts/bonus/update" --функции связанные с обновлением бонусов +require "scripts/bonus/load" --функции связанные с загрузкой бонусов + +require "scripts/levels/draw" --функции связанные с отрисовкой уровней +require "scripts/levels/update" --функции связанные с обновлением уровней +require "scripts/levels/load" --функции связанные с загрузкой уровней + +require "scripts/test" --функции связанные с тестирование + +-----ЗАГРУЗКА ПРОГРАММЫ----- +function love.load() + + --Размер Окна-- + love.graphics.setMode(1280, 720, false, false, 1) --размер окна + + --Массив для Текущих Значений-- + current = {} + + --Проверка Текущего Состояния-- + --режим: + --1) главное меню + --2) игра + current.screen = 1 + + --кнопка: + --1) новая игра + --2) выход + --3) продолжить + --4) рестарт + --5) меню + current.button = buttonGame + + --выбор в меню: + -- -1) вверх + -- 0) стоп + -- 1) вниз + current.selection = 0 + + menu.load() + + --Загрузка Игры-- + current.pause = false + current.test = false + current.enemies = 0 + current.godmode = false + current.level = 1 + current.levelChanged = true + current.levelCompleted = false + current.gameCompleted = false + + game.background.load() + game.level.load() + game.player.load() + game.enemy.load() + game.bonus.load() + + +end + +-----ОБНОВЛЕНИЕ ПРОГРАММЫ----- +function love.update(dt) + + --выполнение функций главного меню при его включении + if current.screen == 1 then + menu.selection() + menu.enter() + end + + --выполнение функций игрового экрана при его включении + if current.screen == 2 then + if not current.pause and not player.dead then + game.update(dt) + end + end + +end + +-----ОТРИСОВКА ИГРЫ----- +function love.draw() + if current.screen == 1 then --если экран меню + menu.draw() --то рисуем его + + elseif current.screen == 2 then --если экран игры + game.draw() --то рисуем его + end + +end + + + + +--------------------------------------------------------------------------------------- +--------------------------------------------------------------------------------------- +--------------------------------------------------------------------------------------- + +function love.keyreleased(key) + + if (current.screen == 1) or (player.dead) then --если экран меню + + if key == "down" or key == "right" then --то по нажатию "Вниз" + current.selection = 1 --записать информацию о том что было нажато "Вниз" + elseif key == "up" or key == "left" then --а по нажатию "Вверх" + current.selection = -1 --записать информацию о том что было нажато "Вверх" + end + + if key == "escape" and current.pause == true then + current.pause = false + current.screen = 2 + end + + if key == "escape" and player.dead then + current.screen = 1 + end + + + + end + + if current.screen == 2 then --если экран игры + if key == "escape" then --то по нажатию "Esc" + current.pause = true --поставить на паузу + current.screen = 1 --открыть меню + current.button = buttonResume --и выбрать пункт "Продолжить" + end + + if key == "p" then + current.pause = not current.pause + end + + if key == "t" then + current.test = not current.test + end + + if current.test then + if key == "1" then + player.weapon.changed = true + player.weapon.type.new = "plasma" + elseif key == "2" then + player.weapon.changed = true + player.weapon.type.new = "laser" + end + + if key == "g" and current.test then + current.godmode = not current.godmode + end + + if key == "l" and player.level < 5 then + player.levelUp = true + end + + if key == "b" then + game.bonus.create(1280, 360, math.random(1, bonus.types) ) + end + end + end + +end \ No newline at end of file diff --git a/scripts/bonus/draw.lua b/scripts/bonus/draw.lua new file mode 100644 index 0000000..09785a2 --- /dev/null +++ b/scripts/bonus/draw.lua @@ -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 diff --git a/scripts/bonus/load.lua b/scripts/bonus/load.lua new file mode 100644 index 0000000..96f52ae --- /dev/null +++ b/scripts/bonus/load.lua @@ -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 diff --git a/scripts/bonus/update.lua b/scripts/bonus/update.lua new file mode 100644 index 0000000..7c256e9 --- /dev/null +++ b/scripts/bonus/update.lua @@ -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 \ No newline at end of file diff --git a/scripts/enemy/draw.lua b/scripts/enemy/draw.lua new file mode 100644 index 0000000..64191e1 --- /dev/null +++ b/scripts/enemy/draw.lua @@ -0,0 +1,20 @@ +-----Отрисовка Врагов----- +function game.enemy.draw() + for i,v in ipairs(enemy) do + if v.type == 1 then + love.graphics.setColor(255, 255, 255, 255) + love.graphics.draw(v.texture.ship, v.x, v.y, v.angle, -1, 1) + elseif v.type == 2 then + love.graphics.setColor(255, 255, 255, 255) + love.graphics.draw(v.texture.ship, v.x, v.y, v.angle, -1, 1) + end + + end +end + +function game.enemy.shot.draw() + for i,v in ipairs(enemy.shot) do + love.graphics.setColor(255, 100, 0, 255) + love.graphics.draw(v.texture, v.x, v.y, v.angle, 1, 1) + end +end \ No newline at end of file diff --git a/scripts/enemy/load.lua b/scripts/enemy/load.lua new file mode 100644 index 0000000..33ad566 --- /dev/null +++ b/scripts/enemy/load.lua @@ -0,0 +1,47 @@ +function game.enemy.load() + + enemy = {} + enemy.shot = {} + --Тип Врага №1-- + enemy.type1 = {} + enemy.type1.texture = {} + enemy.type1.texture.ship = love.graphics.newImage("textures/enemy/1/ship.png") + enemy.type1.texture.shot = love.graphics.newImage("textures/enemy/1/shot.png") + enemy.type1.shot = {} + enemy.type1.shot.height = {} + enemy.type1.shot.damage = 100 + enemy.type1.shot.speed = 1000 + enemy.type1.width = 100 + enemy.type1.height = 50 + enemy.type1.health = 250 + enemy.type1.x = 1500 + enemy.type1.y = 360 + enemy.type1.speed = {current = 0, max = 2500} + enemy.type1.acceleration = 500 + enemy.massEnemyIndex = 0 + --Тип Врага №1-- + enemy.type2 = {} + enemy.type2.texture = {} + enemy.type2.texture.ship = love.graphics.newImage("textures/enemy/2/ship.png") + enemy.type2.texture.shot = love.graphics.newImage("textures/enemy/2/shot.png") + enemy.type2.shot = {} + enemy.type2.shot.height = {} + enemy.type2.shot.damage = 150 + enemy.type2.shot.speed = 500 + enemy.type2.width = 100 + enemy.type2.height = 50 + enemy.type2.health = 250 + enemy.type2.x = 1500 + enemy.type2.y = 360 + enemy.type2.speed = {current = 0, max = 1000} + enemy.type2.acceleration = 250 + + enemy.massEnemyIndex = 0 + + test = {} + test.angle1 = {x = 0, y = 0} + test.angle2 = {x = 0, y = 0} + test.angle3 = {x = 0, y = 0} + test.angle4 = {x = 0, y = 0} + +end \ No newline at end of file diff --git a/scripts/enemy/update.lua b/scripts/enemy/update.lua new file mode 100644 index 0000000..0b0a9f5 --- /dev/null +++ b/scripts/enemy/update.lua @@ -0,0 +1,263 @@ +-----Создание Врагов----- +function game.enemy.create(dt) + if enemy.count == nil then + enemy.count = enemyOnStart + end + if enemy.left > 0 then + if enemy.count <= 0 and current.enemies < 5 then + enemy.massEnemyIndex = enemy.massEnemyIndex+1 + enemy.type = level.lvl1.enemy[enemy.massEnemyIndex] + + local locEnemy = {} + locEnemy.texture = {} + locEnemy.speed = {} + locEnemy.shot = {} + + if enemy.type == 1 then + locEnemy.sideSpeed = 0 + locEnemy.angle = math.random(math.pi - 0.5, math.pi + 0.5) + locEnemy.reload = 0 + locEnemy.type = 1 + locEnemy.width = enemy.type1.width + locEnemy.height = enemy.type1.height + locEnemy.health = enemy.type1.health + locEnemy.x = enemy.type1.x + locEnemy.y = enemy.type1.y + locEnemy.realX = locEnemy.x + locEnemy.width / 2 + locEnemy.realY = locEnemy.y + locEnemy.height / 2 + locEnemy.speed.current = enemy.type1.speed.current + locEnemy.speed.max = enemy.type1.speed.max + locEnemy.shot.damage = enemy.type1.shot.damage + locEnemy.shot.speed = enemy.type1.shot.speed + locEnemy.acceleration = enemy.type1.acceleration + locEnemy.texture.ship = enemy.type1.texture.ship + locEnemy.texture.shot = enemy.type1.texture.shot + enemy.massEnemyIndex = enemy.massEnemyIndex+1 + enemy.delay = 250 + + table.insert(enemy, locEnemy) + + elseif enemy.type == 2 then + locEnemy.sideSpeed = 0 + locEnemy.angle = math.random(math.pi - 0.5, math.pi + 0.5) + locEnemy.reload = 0 + locEnemy.type = 2 + locEnemy.width = enemy.type2.width + locEnemy.height = enemy.type2.height + locEnemy.health = enemy.type2.health + 100 + locEnemy.x = enemy.type2.x + locEnemy.y = enemy.type2.y + locEnemy.realX = locEnemy.x + locEnemy.width / 2 + locEnemy.realY = locEnemy.y + locEnemy.height / 2 + locEnemy.speed.current = enemy.type2.speed.current + locEnemy.speed.max = enemy.type2.speed.max + locEnemy.shot.damage = enemy.type2.shot.damage + locEnemy.shot.speed = enemy.type2.shot.speed + locEnemy.acceleration = enemy.type2.acceleration + locEnemy.texture.ship = enemy.type2.texture.ship + locEnemy.texture.shot = enemy.type2.texture.shot + enemy.massEnemyIndex = enemy.massEnemyIndex+1 + enemy.delay = 250 + + table.insert(enemy, locEnemy) + end + + current.enemies = current.enemies + 1 + enemy.count = enemy.delay + enemy.left = enemy.left - 1 + + else + enemy.count = enemy.count - 100 * dt + end + else + current.levelCompleted = true + current.level = current.level + 1 + current.levelChanged = true + end + +end + +-----Удаление Врагов----- +function game.enemy.delete(deletedEnemies) + + for i,v in ipairs(deletedEnemies) do + table.remove(enemy, v) + current.enemies = current.enemies - 1 + end +end + +-----Обновление Врагов----- +function game.enemy.update(dt) + + local deletedEnemies = {} + local deletedPlayerShots = {} + + --Перебор Врагов-- + for i,v in ipairs(enemy) do + + + --Разгон-- + if v.speed.current < v.speed.max and v.speed.current > -v.speed.max then + if DistanceMeasurement(player.x, player.y, player.width, player.height, v.x, v.y, v.width, v.height) > 500 then + v.speed.current = v.speed.current + v.acceleration * dt + else + if v.speed.current > 0 then + v.speed.current = v.speed.current - v.acceleration * dt * (v.speed.current / 100 + 0.1) + else + v.speed.current = v.speed.current - v.acceleration * dt + end + end + end + if v.realY > player.realY then + v.sideSpeed = v.sideSpeed + dt * 75 + else + v.sideSpeed = v.sideSpeed - dt * 75 + end + + --Обновление Координат-- + v.x = v.x + v.speed.current * dt * math.cos(v.angle) + v.y = v.y + v.speed.current * dt * math.sin(v.angle) + v.x = v.x + v.sideSpeed * dt * math.cos(v.angle+math.pi/2) + v.y = v.y + v.sideSpeed * dt * math.sin(v.angle+math.pi/2) + + --Расчет Углов-- + test.angle1 = {x = v.x, y = v.y} + test.angle2 = {x = v.x + v.width * math.cos(v.angle+math.pi), y = v.y + v.width * math.sin(v.angle+math.pi) } + test.angle3 = {x = test.angle2.x + v.height * math.sin(v.angle+math.pi), y = test.angle2.y - v.height * math.cos(v.angle+math.pi) } + test.angle4 = {x = v.x + v.height * math.sin(v.angle+math.pi), y = v.y - v.height * math.cos(v.angle+math.pi) } + + + --Расчет Реальных Координат-- + v.realX = (test.angle1.x + test.angle3.x) / 2 + v.realY = (test.angle1.y + test.angle3.y) / 2 + + --Поворот-- + if directionCheckUp7(v.realX, v.realY, v.angle, player.realX, player.realY) then + v.angle = v.angle - dt + else + v.angle = v.angle + dt + end + + + + --Удаление Врагов Когда Их ХП Падает Ниже Нуля-- + if v.health <= 0 then + table.insert(deletedEnemies, i) + + player.score = player.score + 500 + + local bonusCreate = math.random(1, 10) + if bonusCreate == 1 then + game.bonus.create(v.x, v.y, math.random(1, bonus.types) ) + end + + end + + --Удаление Врагов Когда Они Уходят Далеко за Экран-- + if v.x < -1000 or v.x > 2280 or v.y < -1000 or v.y > 1720 then + table.insert(deletedEnemies, i) + end + + --Перебор Снарядов и Проверка на Попадания-- + for ii,vv in ipairs(player.shot) do + if hitCheck(v.x, v.y, v.width, v.height, v.angle, vv.x, vv.y, vv.size.width, vv.size.height) then + v.health = v.health - math.random(vv.damage*0.5, vv.damage*2) + + v.angle = v.angle + math.random(-1, 1) * player.weapon.projectile.kick + v.speed.current = v.speed.current - player.weapon.projectile.kick * 10 + + table.insert(deletedPlayerShots, ii) + + end + end + game.player.shot.delete(deletedPlayerShots) + + --Стрельба-- + if v.reload < 0 then + game.enemy.shot.create(v) + v.reload = 10 + else + v.reload = v.reload - dt*5 + end + + + end + game.enemy.delete(deletedEnemies) + +end + + +function directionCheckUp7(enemyX, enemyY, enemyA, playerX, playerY) + local y = (playerX - enemyX) * math.tan(enemyA) + enemyY + if y < playerY then + return true + else + return false + end +end + +function hitCheck(enemyX, enemyY, enemyW, enemyH, enemyA, shotX, shotY, shotW, shotH) + -- 1 2 + -- 4 3 + + local max = {x = math.max(test.angle1.x, test.angle2.x, test.angle3.x, test.angle4.x), y = math.max(test.angle1.y, test.angle2.y, test.angle3.y, test.angle4.y)} + local min = {x = math.min(test.angle1.x, test.angle2.x, test.angle3.x, test.angle4.x), y = math.min(test.angle1.y, test.angle2.y, test.angle3.y, test.angle4.y)} + + local shell = {x = shotX + shotW / 2, y = shotY + shotH / 2} + + if ( (shell.y > min.y) and (shell.y < max.y) and (shell.x > min.x) and (shell.x < max.x) ) then + + return true + + else + return false + end +end + +function game.enemy.shot.create(v) + local shot = {} + shot.x = v.realX + shot.y = v.realY + shot.angle = v.angle + shot.speed = v.shot.damage + shot.damage = v.shot.speed + shot.size = {} + shot.size.width = 15 + shot.size.height = 15 + shot.texture = v.texture.shot + + table.insert(enemy.shot, shot) +end + +function game.enemy.shot.update(dt) + local deletedEnemyShots = {} + for i,v in ipairs(enemy.shot) do + v.x = v.x + v.speed * dt * math.cos(v.angle) + v.y = v.y + v.speed * dt * math.sin(v.angle) + + if v.x < 0 or v.y > 720 or v.y < 0 or v.x > 1280 then + table.insert(deletedEnemyShots, i) + end + + if CheckCollision(v.x, v.y, v.size.width, v.size.height, player.x, player.y, player.width, player.height) then + if not current.godmode then + player.health.current = player.health.current - v.damage + end + table.insert(deletedEnemyShots, i) + end + end + game.enemy.shot.delete(deletedEnemyShots) +end + +function game.enemy.shot.delete(deletedEnemyShots) + for i,v in ipairs(deletedEnemyShots) do + table.remove(enemy.shot, v) + end +end + +function game.enemy.reset() + while current.enemies ~= 0 do + table.remove(enemy, i) + current.enemies = current.enemies - 1 + end +end \ No newline at end of file diff --git a/scripts/gameInterface.lua b/scripts/gameInterface.lua new file mode 100644 index 0000000..d3c1a32 --- /dev/null +++ b/scripts/gameInterface.lua @@ -0,0 +1,100 @@ +function game.interface() + + --HP-- + game.player.health() + + game.player.score() + + --Перегрев-- + game.player.heat() + + --Пауза-- + if current.pause then + love.graphics.setColor(255, 255, 255, 255) + love.graphics.drawq(menu.texture.buttons, menu.texture.interface.pause, 490, 260) + end + + game.menu() + + + +end + +-----Отрисовка Меню в Игре----- +function game.menu() + if player.dead then + + menu.selection() + menu.enter() + + love.graphics.setColor(255, 255, 255, 255) + love.graphics.draw(menu.texture.dead, 50, 50) + + love.graphics.setColor(255, 255, 255, 255) + if current.button == buttonRestart then + love.graphics.drawq(menu.texture.buttons, menu.texture.button.restart.pressed, 200, 500) + else + love.graphics.drawq(menu.texture.buttons, menu.texture.button.restart.unpressed, 200, 500) + end + + if current.button == buttonMenu then + love.graphics.drawq(menu.texture.buttons, menu.texture.button.menu.pressed, 900, 500) + else + love.graphics.drawq(menu.texture.buttons, menu.texture.button.menu.unpressed, 900, 500) + end + end +end + +-----Отрисовка HP Игрока----- +function game.player.health() + + local health = {x = 50, y = 50, multiplier = 0.5} --координаты левого верхнего угла полоски здоровья и множитель зависимости от HP + + if not player.dead then + --Красное-- + love.graphics.setColor(255, 0, 0, 100) + love.graphics.rectangle("fill", health.x + player.health.current * health.multiplier, health.y, (player.health.max - player.health.current) * health.multiplier, 25) + --Зеленое-- + love.graphics.setColor(0, 255, 0, 100) + love.graphics.rectangle("fill", health.x, health.y, player.health.current * health.multiplier, 25) + + if current.godmode then + love.graphics.setColor(255, 100, 0, 200) + love.graphics.print("Godmode", health.x+175, health.y, 0, 2.5, 2.5, 0, 0) + end + else + love.graphics.setColor(255, 0, 0, 100) + love.graphics.rectangle("fill", health.x, health.y, player.health.max * health.multiplier, 25) + end + +end + +-----Отрисовка Перегрева Оружия----- +function game.player.heat() + + local heat = {x = 50, y = 80, multiplier = 5} --координаты левого верхнего угла полоски перегрева и множитель зависимости от перегрева + + if player.weapon.heat.current >= 0 then + --Серое-- + love.graphics.setColor(100, 100, 100, 100) + love.graphics.rectangle("fill", heat.x + player.weapon.heat.current * heat.multiplier, heat.y, (player.weapon.heat.max - player.weapon.heat.current) * heat.multiplier, 10) + --Оранжевое-- + love.graphics.setColor(220, 100, 0, 100) + love.graphics.rectangle("fill", heat.x, heat.y, player.weapon.heat.current * heat.multiplier, 10) + else + love.graphics.setColor(100, 100, 100, 100) + love.graphics.rectangle("fill", heat.x, heat.y, player.weapon.heat.max * heat.multiplier, 10) + end + +end + +-----Очки и Жизни----- +function game.player.score() + local score = {x = 50, y = 100} + local life = {x = 50, y = 150} + love.graphics.setColor(255, 255, 255, 100) + love.graphics.print(player.score, score.x, score.y, 0, 2.5, 2.5, 0, 0) + for i = 0, player.lifes.current-1 do + love.graphics.draw(menu.texture.live, life.x + life.x * i /2, life.y) + end +end \ No newline at end of file diff --git a/scripts/gameMode.lua b/scripts/gameMode.lua new file mode 100644 index 0000000..6523022 --- /dev/null +++ b/scripts/gameMode.lua @@ -0,0 +1,119 @@ +-----КОНСТАНТЫ----- +enemyOnStart = 1 + +-----Массивы Функций----- +game = {} --массив с функциями по работе с экраном игры +game.enemy = {} --массив с функциями по работе с врагами +game.enemy.shot = {} --массив с функциями по работе с выстрелами игрока +game.player = {} --массив с функциями по работе с игроком +game.player.weapon = {} --массив с функциями по работе с оружием игрока +game.player.shot = {} --массив с функциями по работе с выстрелами игрока +game.test = {} --массив с функциями для тестирования +game.bonus = {} +game.background = {} +game.level = {} + +-----ОТРИСОВКА ИГРЫ----- +function game.draw() + + game.background.draw() + + --Игрок-- + game.player.draw() + game.player.shot.draw() + + --Враги-- + game.enemy.draw() + game.enemy.shot.draw() + + --Бонусы-- + game.bonus.draw() + + --Интерфейс-- + game.interface() + + --Тестирование-- + game.test.draw() + + +end + + + +-----ОБНОВЛЕНИЕ ИГРЫ----- +function game.update(dt) + + game.background.update(dt) + + game.level.update() + + game.player.weapon.update() + game.player.dead() + game.player.control(dt) + game.player.shot.update(dt) + game.player.levelUpdate() + + + enemy.type = 1 + game.enemy.create(dt) + + game.enemy.update(dt) + game.enemy.shot.update(dt) + + game.bonus.update(dt) + + +end + + +function DistanceMeasurement(box1x, box1y, box1w, box1h, box2x, box2y, box2w, box2h) + local x1 = box1x + box1w/2 + local y1 = box1y + box1h/2 + local x2 = box2x + box2w/2 + local y2 = box2y + box2h/2 + local dist = ( (x1 - x2)^2 + (y1 - y2)^2 )^0.5 + return dist +end + +function CheckCollision(box1x, box1y, box1w, box1h, box2x, box2y, box2w, box2h) + if box1x > box2x + box2w - 1 or -- box1 на правой стороне box2? + box1y > box2y + box2h - 1 or -- box1 под box2? + box2x > box1x + box1w - 1 or -- box2 на правой стороне box1? + box2y > box1y + box1h - 1 -- box2 под box1? + then + return false -- Нет коллизии!! + else + return true -- Есть контакт! + end +end + +function game.background.load() + background1 = {} + background1.texture = love.graphics.newImage("textures/background.png") + background1.x = 0 + background1.y = 0 + background2 = {} + background2.texture = love.graphics.newImage("textures/background.png") + background2.x = 2560 + background2.y = 0 +end + +function game.background.update(dt) + background1.x = background1.x - dt * 500 + + if background1.x < -2560 then + background1.x = 1280 + end + + background2.x = background2.x - dt * 500 + + if background2.x < -2560 then + background2.x = 1280 + end +end + +function game.background.draw() + love.graphics.setColor(255, 255, 255, 255) + love.graphics.draw(background1.texture, background1.x, background1.y) + love.graphics.draw(background2.texture, background2.x, background2.y) +end diff --git a/textures/Sources/Alle Texturen.ora b/textures/Sources/Alle Texturen.ora new file mode 100644 index 0000000..5c279b9 Binary files /dev/null and b/textures/Sources/Alle Texturen.ora differ diff --git a/textures/Sources/buttons.ora b/textures/Sources/buttons.ora new file mode 100644 index 0000000..d6166a5 Binary files /dev/null and b/textures/Sources/buttons.ora differ diff --git a/textures/Sources/buttons.png b/textures/Sources/buttons.png new file mode 100644 index 0000000..d9d308f Binary files /dev/null and b/textures/Sources/buttons.png differ diff --git a/textures/Sources/buttons.xcf b/textures/Sources/buttons.xcf new file mode 100644 index 0000000..95b431d Binary files /dev/null and b/textures/Sources/buttons.xcf differ diff --git a/textures/background.png b/textures/background.png new file mode 100644 index 0000000..5041d82 Binary files /dev/null and b/textures/background.png differ diff --git a/textures/bonus/health.png b/textures/bonus/health.png new file mode 100644 index 0000000..56a13a1 Binary files /dev/null and b/textures/bonus/health.png differ diff --git a/textures/bonus/laser.png b/textures/bonus/laser.png new file mode 100644 index 0000000..40bd878 Binary files /dev/null and b/textures/bonus/laser.png differ diff --git a/textures/bonus/life.png b/textures/bonus/life.png new file mode 100644 index 0000000..9c44103 Binary files /dev/null and b/textures/bonus/life.png differ diff --git a/textures/bonus/lvlUp.png b/textures/bonus/lvlUp.png new file mode 100644 index 0000000..20ae714 Binary files /dev/null and b/textures/bonus/lvlUp.png differ diff --git a/textures/bonus/plasma.png b/textures/bonus/plasma.png new file mode 100644 index 0000000..d739d65 Binary files /dev/null and b/textures/bonus/plasma.png differ diff --git a/textures/enemy/1/ship.png b/textures/enemy/1/ship.png new file mode 100644 index 0000000..6df40e6 Binary files /dev/null and b/textures/enemy/1/ship.png differ diff --git a/textures/enemy/1/shot.png b/textures/enemy/1/shot.png new file mode 100644 index 0000000..7175173 Binary files /dev/null and b/textures/enemy/1/shot.png differ diff --git a/textures/enemy/2/ship.png b/textures/enemy/2/ship.png new file mode 100644 index 0000000..02abb59 Binary files /dev/null and b/textures/enemy/2/ship.png differ diff --git a/textures/enemy/2/shot.png b/textures/enemy/2/shot.png new file mode 100644 index 0000000..9761c93 Binary files /dev/null and b/textures/enemy/2/shot.png differ diff --git a/textures/menu/buttons.png b/textures/menu/buttons.png new file mode 100644 index 0000000..6d40d75 Binary files /dev/null and b/textures/menu/buttons.png differ diff --git a/textures/menu/dead.png b/textures/menu/dead.png new file mode 100644 index 0000000..14ed8b9 Binary files /dev/null and b/textures/menu/dead.png differ diff --git a/textures/menu/live.png b/textures/menu/live.png new file mode 100644 index 0000000..64a05c2 Binary files /dev/null and b/textures/menu/live.png differ diff --git a/textures/menu/main.png b/textures/menu/main.png new file mode 100644 index 0000000..213f412 Binary files /dev/null and b/textures/menu/main.png differ diff --git a/textures/player/Ship.png b/textures/player/Ship.png new file mode 100644 index 0000000..94f1591 Binary files /dev/null and b/textures/player/Ship.png differ diff --git a/textures/player/laser.png b/textures/player/laser.png new file mode 100644 index 0000000..f52e1da Binary files /dev/null and b/textures/player/laser.png differ diff --git a/textures/player/laserShot.png b/textures/player/laserShot.png new file mode 100644 index 0000000..8cf90a7 Binary files /dev/null and b/textures/player/laserShot.png differ diff --git a/textures/player/plasma.png b/textures/player/plasma.png new file mode 100644 index 0000000..97b285d Binary files /dev/null and b/textures/player/plasma.png differ diff --git a/textures/player/plasmaShot.png b/textures/player/plasmaShot.png new file mode 100644 index 0000000..200cd07 Binary files /dev/null and b/textures/player/plasmaShot.png differ