From 37834ce2b0c8f7b247b2a6efb4d755ccadd62033 Mon Sep 17 00:00:00 2001 From: MrPixel92 <35262174+MrPixel92@users.noreply.github.com> Date: Sat, 29 Apr 2023 14:31:44 +0300 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=BB=D0=B8=D0=BB=20=D1=86=D0=B5?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D1=82=20=D0=B2=20=D0=BD=D0=BE=D0=B2=D0=BE?= =?UTF-8?q?=D0=B9=20=D1=81=D0=B8=D1=81=D1=82=D0=B5=D0=BC=D0=B5=20=D0=BE?= =?UTF-8?q?=D1=80=D1=83=D0=B6=D0=B8=D1=8F=20(=D0=BF=D0=BE=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D1=8F=D0=BB=20=D1=81=D0=BF=D0=BE=D1=81=D0=BE=D0=B1=20?= =?UTF-8?q?=D1=83=D0=B4=D0=B5=D1=80=D0=B6=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=BA?= =?UTF-8?q?=D0=B0=D1=80=D1=82=D0=B8=D0=BD=D0=BA=D0=B8=20=D0=B2=D1=8B=D1=81?= =?UTF-8?q?=D1=82=D1=80=D0=B5=D0=BB=D0=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Теперь оно не тормозит всю игру, а рисуется несколько кадров подряд --- Applications/RayWalk.app/RayEngine.lua | 32 +++++++++++++++++++++----- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/Applications/RayWalk.app/RayEngine.lua b/Applications/RayWalk.app/RayEngine.lua index 5da0dbe5..afab1030 100755 --- a/Applications/RayWalk.app/RayEngine.lua +++ b/Applications/RayWalk.app/RayEngine.lua @@ -13,7 +13,6 @@ local filesystem = require("Filesystem") local inputX = 0 local inputY = 0 local inputYaw = 0 - ---------------------------------------------------- Константы ------------------------------------------------------------------ local rayEngine = {} @@ -479,7 +478,12 @@ function rayEngine.toggleWatch() end function rayEngine.drawWeapon() - if rayEngine.currentWeapon.needToFire then screen.drawImage(rayEngine.currentWeapon.xFire, rayEngine.currentWeapon.yFire, rayEngine.currentWeapon.fireTexture); rayEngine.currentWeapon.needToFire = false end +--Пока рисуем, вычитаем время стрельбы + if rayEngine.currentWeapon.needToFire then + screen.drawImage(rayEngine.currentWeapon.xFire, rayEngine.currentWeapon.yFire, rayEngine.currentWeapon.fireTexture); + rayEngine.currentWeapon.needToFire = rayEngine.currentWeapon.needToFire - 1 + end +--Рисуем картинку оружия поверх вспышки, а затем и прицел screen.drawImage(rayEngine.currentWeapon.xWeapon, rayEngine.currentWeapon.yWeapon, rayEngine.currentWeapon.weaponTexture) screen.drawImage(rayEngine.currentWeapon.xCrosshair, rayEngine.currentWeapon.yCrosshair, rayEngine.currentWeapon.crosshairTexture) end @@ -585,10 +589,26 @@ function rayEngine.changeResolution(width, height) end function rayEngine.fire() - rayEngine.currentWeapon.needToFire = true - rayEngine.update() - event.sleep(0.1) - rayEngine.update() +--Если мы уже стреляем, то, естественно, выходим из функции + if rayEngine.currentWeapon.needToFire then return end +--Иначе стреляем + rayEngine.currentWeapon.needToFire = rayEngine.currentWeapon.fireTime + stopYaw() --Останавливаю игрока, т.к. события touch и key_up - злейшие враги всего OpenComputers + if inputY > 0 then + stopY() --Должно спасти жизнь игроку + end +end + +function rayEngine.fireAuto() +--Если мы уже стреляем, то, естественно, выходим из функции + if rayEngine.currentWeapon.needToFire then return end +--Тоже самое, если оружие - пистолет/полуавто винтовка + if not rayEngine.currentWeapon.isAuto then return end +--Иначе стреляем + rayEngine.currentWeapon.needToFire = rayEngine.currentWeapon.fireTime + stopYaw() --Останавливаю игрока, т.к. события touch и key_up - злейшие враги всего OpenComputers + stopX() + stopY() end ----------------------------------------------------------------------------------------------------------------------------------