diff --git a/Applications.txt b/Applications.txt index 98a58a23..f311781d 100644 --- a/Applications.txt +++ b/Applications.txt @@ -546,45 +546,77 @@ }, }, }, - -- { - -- name="MineOS/Applications/RayWalk", - -- url="IgorTimofeev/OpenComputers/master/Applications/RayWalk/RayWalk.lua", - -- about="IgorTimofeev/OpenComputers/master/Applications/RayWalk/About/", - -- type="Application", - -- icon="IgorTimofeev/OpenComputers/master/Applications/RayWalk/Icon.pic", - -- createShortcut="desktop", - -- version=1.44, - -- resources={ - -- { - -- name="RayEngine.cfg", - -- url="IgorTimofeev/OpenComputers/master/Applications/RayWalk/RayEngine.cfg", - -- }, - -- { - -- name="Worlds/ExampleWorld/Map.cfg", - -- url="IgorTimofeev/OpenComputers/master/Applications/RayWalk/Worlds/ExampleWorld/Map.cfg", - -- }, - -- { - -- name="Worlds/ExampleWorld/Player.cfg", - -- url="IgorTimofeev/OpenComputers/master/Applications/RayWalk/Worlds/ExampleWorld/Player.cfg", - -- }, - -- { - -- name="Worlds/ExampleWorld/World.cfg", - -- url="IgorTimofeev/OpenComputers/master/Applications/RayWalk/Worlds/ExampleWorld/World.cfg", - -- }, - -- { - -- name="Worlds/SundownBeams/Map.cfg", - -- url="IgorTimofeev/OpenComputers/master/Applications/RayWalk/Worlds/SundownBeams/Map.cfg", - -- }, - -- { - -- name="Worlds/SundownBeams/Player.cfg", - -- url="IgorTimofeev/OpenComputers/master/Applications/RayWalk/Worlds/SundownBeams/Player.cfg", - -- }, - -- { - -- name="Worlds/SundownBeams/World.cfg", - -- url="IgorTimofeev/OpenComputers/master/Applications/RayWalk/Worlds/SundownBeams/World.cfg", - -- }, - -- }, - -- }, + { + name="MineOS/Applications/RayWalk", + url="IgorTimofeev/OpenComputers/master/Applications/RayWalk/RayWalk.lua", + about="IgorTimofeev/OpenComputers/master/Applications/RayWalk/About/", + type="Application", + icon="IgorTimofeev/OpenComputers/master/Applications/RayWalk/Icon.pic", + createShortcut="desktop", + version=1.45, + resources={ + { + name="RayEngine.cfg", + url="IgorTimofeev/OpenComputers/master/Applications/RayWalk/RayEngine.cfg", + }, +------------ + { + name="Weapons/CrosshairTextures/Angled.pic", + url="IgorTimofeev/OpenComputers/master/Applications/RayWalk/Weapons/CrosshairTextures/Angled.pic", + }, + { + name="Weapons/CrosshairTextures/Default.pic", + url="IgorTimofeev/OpenComputers/master/Applications/RayWalk/Weapons/CrosshairTextures/Default.pic", + }, + { + name="Weapons/CrosshairTextures/Half.pic", + url="IgorTimofeev/OpenComputers/master/Applications/RayWalk/Weapons/CrosshairTextures/Half.pic", + }, +------------ + { + name="Weapons/FireTextures/PowderFire.pic", + url="IgorTimofeev/OpenComputers/master/Applications/RayWalk/Weapons/FireTextures/PowderFire.pic", + }, +------------ + { + name="Weapons/WeaponTextures/Pistol.pic", + url="IgorTimofeev/OpenComputers/master/Applications/RayWalk/Weapons/WeaponTextures/Pistol.pic", + }, + { + name="Weapons/WeaponTextures/Sniper.pic", + url="IgorTimofeev/OpenComputers/master/Applications/RayWalk/Weapons/WeaponTextures/Sniper.pic", + }, + { + name="Weapons/WeaponTextures/Rifle.pic", + url="IgorTimofeev/OpenComputers/master/Applications/RayWalk/Weapons/WeaponTextures/Rifle.pic", + }, +------------ + { + name="Worlds/ExampleWorld/Map.cfg", + url="IgorTimofeev/OpenComputers/master/Applications/RayWalk/Worlds/ExampleWorld/Map.cfg", + }, + { + name="Worlds/ExampleWorld/Player.cfg", + url="IgorTimofeev/OpenComputers/master/Applications/RayWalk/Worlds/ExampleWorld/Player.cfg", + }, + { + name="Worlds/ExampleWorld/World.cfg", + url="IgorTimofeev/OpenComputers/master/Applications/RayWalk/Worlds/ExampleWorld/World.cfg", + }, + { + name="Worlds/SundownBeams/Map.cfg", + url="IgorTimofeev/OpenComputers/master/Applications/RayWalk/Worlds/SundownBeams/Map.cfg", + }, + { + name="Worlds/SundownBeams/Player.cfg", + url="IgorTimofeev/OpenComputers/master/Applications/RayWalk/Worlds/SundownBeams/Player.cfg", + }, + { + name="Worlds/SundownBeams/World.cfg", + url="IgorTimofeev/OpenComputers/master/Applications/RayWalk/Worlds/SundownBeams/World.cfg", + }, + }, + }, { name="MineOS/Applications/GuessWord", url="IgorTimofeev/OpenComputers/master/Applications/GuessWord/GuessWord.lua", diff --git a/Applications/RayWalk/RayWalk.lua b/Applications/RayWalk/RayWalk.lua index f26e4ea0..31a355f7 100644 --- a/Applications/RayWalk/RayWalk.lua +++ b/Applications/RayWalk/RayWalk.lua @@ -11,6 +11,9 @@ local libraries = { } for library in pairs(libraries) do if not _G[library] then _G[library] = require(libraries[library]) end end; libraries = nil + +---------------------------------------------------------------------------------------------------------------------------------- + local applicationPath = "MineOS/Applications/RayWalk.app/Resources/" local worldsPath = applicationPath .. "Worlds/" local rayWalkVersion = "RayWalk v3.2 closed beta" @@ -82,7 +85,8 @@ local controls = { buffer.start() -- rayEngine.intro() -rayEngine.init(applicationPath .. "RayEngine.cfg") +rayEngine.loadEngine(applicationPath .. "RayEngine.cfg") +rayEngine.loadWeapons(applicationPath .. "Weapons/") rayEngine.loadWorld(worldsPath .. "ExampleWorld") menu() rayEngine.update() @@ -92,9 +96,17 @@ while (true) do if ( e[1] ) then if e[1] == "touch" then - if e[5] == 1 then rayEngine.place(3) else rayEngine.destroy(3) end + if e[5] == 1 then + if not rayEngine.currentWeapon then rayEngine.place(3) end + else + if rayEngine.currentWeapon then rayEngine.fire() else rayEngine.destroy(3) end + end else - if controls[e[1]] and controls[e[1]][e[4]] then controls[e[1]][e[4]]() end + if e[4] > 1 and e[4] < 10 then + rayEngine.changeWeapon(e[4] - 2) + else + if controls[e[1]] and controls[e[1]][e[4]] then controls[e[1]][e[4]]() end + end end end diff --git a/Applications/RayWalk/Weapons/CrosshairTextures/Angled.pic b/Applications/RayWalk/Weapons/CrosshairTextures/Angled.pic new file mode 100644 index 00000000..301892fd Binary files /dev/null and b/Applications/RayWalk/Weapons/CrosshairTextures/Angled.pic differ diff --git a/Applications/RayWalk/Weapons/CrosshairTextures/Default.pic b/Applications/RayWalk/Weapons/CrosshairTextures/Default.pic new file mode 100644 index 00000000..e997c9a3 Binary files /dev/null and b/Applications/RayWalk/Weapons/CrosshairTextures/Default.pic differ diff --git a/Applications/RayWalk/Weapons/CrosshairTextures/Half.pic b/Applications/RayWalk/Weapons/CrosshairTextures/Half.pic new file mode 100644 index 00000000..465c6f47 Binary files /dev/null and b/Applications/RayWalk/Weapons/CrosshairTextures/Half.pic differ diff --git a/Applications/RayWalk/Weapons/FireTextures/PowderFire.pic b/Applications/RayWalk/Weapons/FireTextures/PowderFire.pic new file mode 100644 index 00000000..f91c3c47 Binary files /dev/null and b/Applications/RayWalk/Weapons/FireTextures/PowderFire.pic differ diff --git a/Applications/RayWalk/Weapons/WeaponTextures/Pistol.pic b/Applications/RayWalk/Weapons/WeaponTextures/Pistol.pic new file mode 100644 index 00000000..806f1d6d Binary files /dev/null and b/Applications/RayWalk/Weapons/WeaponTextures/Pistol.pic differ diff --git a/Applications/RayWalk/Weapons/WeaponTextures/Rifle.pic b/Applications/RayWalk/Weapons/WeaponTextures/Rifle.pic new file mode 100644 index 00000000..50858628 Binary files /dev/null and b/Applications/RayWalk/Weapons/WeaponTextures/Rifle.pic differ diff --git a/Applications/RayWalk/Weapons/WeaponTextures/Sniper.pic b/Applications/RayWalk/Weapons/WeaponTextures/Sniper.pic new file mode 100644 index 00000000..926953e2 Binary files /dev/null and b/Applications/RayWalk/Weapons/WeaponTextures/Sniper.pic differ diff --git a/Applications/RayWalk/Weapons/Weapons.cfg b/Applications/RayWalk/Weapons/Weapons.cfg new file mode 100644 index 00000000..517be9f3 --- /dev/null +++ b/Applications/RayWalk/Weapons/Weapons.cfg @@ -0,0 +1,35 @@ +{ + { + name = "USP-5", + damage = 25, + weaponTexture = "WeaponTextures/Pistol.pic", + fireTexture = "FireTextures/PowderFire.pic", + firePosition = { + x = -1, + y = -4, + }, + crosshairTexture = "CrosshairTextures/Default.pic", + }, + { + name = "MAG20-USP", + damage = 48, + weaponTexture = "WeaponTextures/Rifle.pic", + fireTexture = "FireTextures/PowderFire.pic", + firePosition = { + x = 1, + y = -1, + }, + crosshairTexture = "CrosshairTextures/Half.pic", + }, + { + name = "UberSniper228", + damage = 100, + weaponTexture = "WeaponTextures/Sniper.pic", + fireTexture = "FireTextures/PowderFire.pic", + firePosition = { + x = -5, + y = 1, + }, + crosshairTexture = "CrosshairTextures/Angled.pic", + }, +} \ No newline at end of file diff --git a/Applications/RayWalk/Worlds/ExampleWorld/Player.cfg b/Applications/RayWalk/Worlds/ExampleWorld/Player.cfg index a43d74fe..777a7e19 100644 --- a/Applications/RayWalk/Worlds/ExampleWorld/Player.cfg +++ b/Applications/RayWalk/Worlds/ExampleWorld/Player.cfg @@ -3,6 +3,10 @@ x = 5, y = 5, }, + health = { + maximum = 100, + current = 100, + }, isCrouched = false, jumpHeight = 10, moveSpeed = 16, diff --git a/Applications/RayWalk/Worlds/ExampleWorld/World.cfg b/Applications/RayWalk/Worlds/ExampleWorld/World.cfg index a52f11c8..81b76a9c 100644 --- a/Applications/RayWalk/Worlds/ExampleWorld/World.cfg +++ b/Applications/RayWalk/Worlds/ExampleWorld/World.cfg @@ -1,7 +1,7 @@ { dayNightCycle = { enabled = true, - currentTime = 90, + currentTime = 100, speed = 1, length = 300, }, diff --git a/Applications/RayWalk/Worlds/ForeverDay/Map.cfg b/Applications/RayWalk/Worlds/ForeverDay/Map.cfg deleted file mode 100644 index 74dde403..00000000 --- a/Applications/RayWalk/Worlds/ForeverDay/Map.cfg +++ /dev/null @@ -1,28 +0,0 @@ -{ - { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, - { 0x0, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0x0 }, - { 0x0, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0x0 }, - { 0x0, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0x0 }, - { 0x0, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0x0 }, - { 0x0, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0x0 }, - { 0x0, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0x0 }, - { 0x0, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0x0 }, - { 0x0, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0x0 }, - { 0x0, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0x0 }, - { 0x0, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0x0 }, - { 0x0, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0x0 }, - { 0x0, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0x0 }, - { 0x0, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0x0 }, - { 0x0, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0x0 }, - { 0x0, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0x0 }, - { 0x0, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0x0 }, - { 0x0, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0x0 }, - { 0x0, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0x0 }, - { 0x0, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0x0 }, - { 0x0, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0x0 }, - { 0x0, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0x0 }, - { 0x0, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0x0 }, - { 0x0, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0x0 }, - { 0x0, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0x0 }, - { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, -} \ No newline at end of file diff --git a/Applications/RayWalk/Worlds/ForeverDay/Player.cfg b/Applications/RayWalk/Worlds/ForeverDay/Player.cfg deleted file mode 100644 index a43d74fe..00000000 --- a/Applications/RayWalk/Worlds/ForeverDay/Player.cfg +++ /dev/null @@ -1,13 +0,0 @@ -{ - position = { - x = 5, - y = 5, - }, - isCrouched = false, - jumpHeight = 10, - moveSpeed = 16, - rotationSpeed = 5, - crouchHeight = 10, - fieldOfView = 60, - rotation = 0, -} \ No newline at end of file diff --git a/Applications/RayWalk/Worlds/ForeverDay/World.cfg b/Applications/RayWalk/Worlds/ForeverDay/World.cfg deleted file mode 100644 index 99f62b94..00000000 --- a/Applications/RayWalk/Worlds/ForeverDay/World.cfg +++ /dev/null @@ -1,59 +0,0 @@ -{ - dayNightCycle = { - enabled = false, - currentTime = 90, - speed = 1, - length = 200, - }, - colors = { - ground = 0xEEEEEE, - clouds = 0xFFFFFF, - sky = { - 0x002440, - 0x002480, - 0x3349BF, - 0x6692FF, - 0x99DBFF, - 0x99DBFF, - 0x99DBFF, - 0x66B6FF, - 0x66B6FF, - 0xFFDB80, - 0xFFB640, - 0xCCBD00, - 0x000080, - 0x002440, - }, - brightnessMultiplyer = { - 20, - 40, - 60, - 80, - 100, - 100, - 100, - 80, - 80, - 70, - 60, - 50, - 40, - 30, - }, - tile = { - 0x000000, - 0x111111, - 0x222222, - 0x333333, - 0x444444, - 0x555555, - 0x666666, - 0x777777, - 0x888888, - 0x999999, - 0xAAAAAA, - 0xBBBBBB, - 0xCCCCCC, - }, - }, -} \ No newline at end of file diff --git a/Applications/RayWalk/Worlds/SundownBeams/Player.cfg b/Applications/RayWalk/Worlds/SundownBeams/Player.cfg index a43d74fe..777a7e19 100644 --- a/Applications/RayWalk/Worlds/SundownBeams/Player.cfg +++ b/Applications/RayWalk/Worlds/SundownBeams/Player.cfg @@ -3,6 +3,10 @@ x = 5, y = 5, }, + health = { + maximum = 100, + current = 100, + }, isCrouched = false, jumpHeight = 10, moveSpeed = 16, diff --git a/lib/rayEngine.lua b/lib/rayEngine.lua index 84339ee6..713f8f33 100644 --- a/lib/rayEngine.lua +++ b/lib/rayEngine.lua @@ -88,14 +88,39 @@ local function getBlockCoordsByLook(distance) return convertWorldCoordsToMapCoords(rayEngine.player.position.x + distance * math.sin(radRotation) * rayEngine.properties.tileWidth, rayEngine.player.position.y + distance * math.cos(radRotation) * rayEngine.properties.tileWidth) end +function rayEngine.changeWeapon(weaponID) + if rayEngine.weapons[weaponID] then + rayEngine.currentWeapon = { + damage = rayEngine.weapons[weaponID].damage, + weaponTexture = image.load(rayEngine.weaponsFolder .. rayEngine.weapons[weaponID].weaponTexture), + fireTexture = image.load(rayEngine.weaponsFolder .. rayEngine.weapons[weaponID].fireTexture), + crosshairTexture = image.load(rayEngine.weaponsFolder .. rayEngine.weapons[weaponID].crosshairTexture) + } + rayEngine.currentWeapon.xWeapon = buffer.screen.width - rayEngine.currentWeapon.weaponTexture.width + 1 + rayEngine.currentWeapon.yWeapon = buffer.screen.height - rayEngine.currentWeapon.weaponTexture.height + 1 + rayEngine.currentWeapon.xFire = rayEngine.currentWeapon.xWeapon + rayEngine.weapons[weaponID].firePosition.x + rayEngine.currentWeapon.yFire = rayEngine.currentWeapon.yWeapon + rayEngine.weapons[weaponID].firePosition.y + rayEngine.currentWeapon.xCrosshair = math.floor(buffer.screen.width / 2 - rayEngine.currentWeapon.crosshairTexture.width / 2) + rayEngine.currentWeapon.yCrosshair = math.floor(buffer.screen.height / 2 - rayEngine.currentWeapon.crosshairTexture.height / 2) + else + rayEngine.currentWeapon = nil + end +end + ---------------------------------------------------- Работа с файлами ------------------------------------------------------------------ --Грузим базовый конфиг движка -function rayEngine.init(pathToRayEnginePropertiesFile) +function rayEngine.loadEngine(pathToRayEnginePropertiesFile) rayEngine.properties = files.loadTableFromFile(pathToRayEnginePropertiesFile) rayEngine.properties.raycastQuality = rayEngine.properties.raycastQuality * rayEngine.properties.tileWidth end +function rayEngine.loadWeapons(pathToWeaponsFolder) + rayEngine.weaponsFolder = pathToWeaponsFolder + rayEngine.weapons = files.loadTableFromFile(rayEngine.weaponsFolder .. "Weapons.cfg") + rayEngine.changeWeapon(1) +end + --Загружаем все конфиг-файлы мира function rayEngine.loadWorld(pathToWorldFolder) rayEngine.world = files.loadTableFromFile(pathToWorldFolder .. "/World.cfg") @@ -381,6 +406,21 @@ function rayEngine.toggleWatch() if not rayEngine.watchEnabled then rayEngine.watchImage = nil end end +function rayEngine.drawWeapon() + if rayEngine.currentWeapon.needToFire then buffer.image(rayEngine.currentWeapon.xFire, rayEngine.currentWeapon.yFire, rayEngine.currentWeapon.fireTexture); rayEngine.currentWeapon.needToFire = false end + buffer.image(rayEngine.currentWeapon.xWeapon, rayEngine.currentWeapon.yWeapon, rayEngine.currentWeapon.weaponTexture) + buffer.image(rayEngine.currentWeapon.xCrosshair, rayEngine.currentWeapon.yCrosshair, rayEngine.currentWeapon.crosshairTexture) +end + +function rayEngine.drawStats() + local width = math.floor(buffer.screen.width * 0.3) + local height = 5 + local x, y = buffer.screen.width - width - 1, 2 + buffer.square(x, y, width, height, 0x000000, 0xFFFFFF, " ", 50) + + GUI.progressBar(x + 1, y + 4, width - 2, 1, 0x000000, 0xFF5555, rayEngine.player.health.current, rayEngine.player.health.maximum, true) +end + ---------------------------------------------------- Функции отрисовки мира ------------------------------------------------------------------ local function raycast(angle) @@ -425,6 +465,7 @@ function rayEngine.drawWorld() --Кусочек стенки tileColor = height > distanceLimit and rayEngine.world.colors.tile.byTime[#rayEngine.world.colors.tile.byTime] or rayEngine.world.colors.tile.byTime[math.floor(#rayEngine.world.colors.tile.byTime * height / distanceLimit)] + -- tileColor = 0x000000 buffer.square(math.floor(startX), math.floor(startY), 1, math.floor(height), tileColor, 0x000000, " ") end startX = startX + 1 @@ -433,11 +474,12 @@ end function rayEngine.update() rayEngine.drawWorld() + if rayEngine.currentWeapon then rayEngine.drawWeapon() end if rayEngine.minimapEnabled then rayEngine.drawMap(3, 2, 25, 13, 50) end + -- rayEngine.drawStats() local xTools, yTools = 3, buffer.screen.height - 25 if rayEngine.compassEnabled then rayEngine.compass(xTools, yTools); xTools = xTools + 30 end if rayEngine.watchEnabled then rayEngine.watch(xTools, yTools) end - --rayEngine.drawWeapon() if rayEngine.chatEnabled then rayEngine.chat() end doDayNightCycle() buffer.draw() @@ -445,4 +487,13 @@ end ---------------------------------------------------------------------------------------------------------------------------------- +function rayEngine.fire() + rayEngine.currentWeapon.needToFire = true + rayEngine.update() + os.sleep(0.1) + rayEngine.update() +end + +---------------------------------------------------------------------------------------------------------------------------------- + return rayEngine