From 9fddcf33828534b0258ff511e09452c5275bcab6 Mon Sep 17 00:00:00 2001 From: Igor Timofeev Date: Sat, 31 Oct 2015 16:42:14 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D0=BF=D1=80=D0=B8=D0=BB=D0=BE=D0=B6=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20"=D0=BC=D0=B0=D1=82=D1=80=D0=B8=D1=86=D0=B0"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Applications.txt | 7 +++ Applications/Matrix/Icon.pic | Bin 0 -> 267 bytes Applications/Matrix/Matrix.lua | 83 +++++++++++++++++++++++++++++++++ Installer/Installer.lua | 2 + 4 files changed, 92 insertions(+) create mode 100644 Applications/Matrix/Icon.pic create mode 100644 Applications/Matrix/Matrix.lua diff --git a/Applications.txt b/Applications.txt index dd5ee079..f9c695e4 100644 --- a/Applications.txt +++ b/Applications.txt @@ -472,6 +472,13 @@ ["icon"]="IgorTimofeev/OpenComputers/master/Applications/AppStore/Icon.pic", ["version"]=1.0, }, + { + ["name"]="MineOS/Applications/Matrix", + ["url"]="IgorTimofeev/OpenComputers/master/Applications/Matrix/Matrix.lua", + ["type"]="Application", + ["icon"]="IgorTimofeev/OpenComputers/master/Applications/Matrix/Icon.pic", + ["version"]=1.0, + }, ----------------------------------------------------- Приложения с ресурсами -------------------------------------------------------------------------- diff --git a/Applications/Matrix/Icon.pic b/Applications/Matrix/Icon.pic new file mode 100644 index 0000000000000000000000000000000000000000..a7d61f29402c008a108b0e5ca485ceabb4189077 GIT binary patch literal 267 zcmeCoPtHt};^JUoU|{(F|38BQkT%}Nz@UQ6_hewOMdkzL?UDKa85p$C_^QbKTm}XQ xWIj;8G7=wTFS30gKC-;=BnAc>B=yEX`;g6pxf>S^@{b~tevrCHEz{6M6aZA|Q^o)Q literal 0 HcmV?d00001 diff --git a/Applications/Matrix/Matrix.lua b/Applications/Matrix/Matrix.lua new file mode 100644 index 00000000..23f0ae0b --- /dev/null +++ b/Applications/Matrix/Matrix.lua @@ -0,0 +1,83 @@ + + +local event = require("event") +local gpu = require("component").gpu +if not _G.buffer then _G.buffer = require("doubleBuffering") end + +local xOld, yOld = gpu.getResolution() +local xSize, ySize = 80, 25 +gpu.setResolution(xSize, ySize) + +local lengthOfLine = 14 +local countOfLinesToGenerate = 5 +local counter = 0 +local speed = 0.08 + +local lines = { + {x = 2, y = 3}, +} + +local chars = { "%", "!", "@", "#", ":", "<", ">", "&", "?", "~", "/", "+", "=", "-", "*"} + +local function generateLines() + for i = 1, countOfLinesToGenerate do + table.insert(lines, {x = math.random(1, xSize), y = 1}) + end +end + +local function moveLines() + local i = 1 + while i <= #lines do + lines[i].y = lines[i].y + 1 + if lines[i].y - lengthOfLine > ySize then table.remove(lines, i) else i = i + 1 end + end +end + +local function showLine(lineNumber) + local baseColor = 0x00FF00 + local yPos = lines[lineNumber].y + for i = 1, lengthOfLine do + local symbol = chars[math.random(1, #chars)] + + if i == 1 then + buffer.set(lines[lineNumber].x, yPos, 0x000000, 0xFFFFFF, symbol) + else + buffer.set(lines[lineNumber].x, yPos, 0x000000, baseColor, symbol) + baseColor = baseColor - 0x001100 + end + + yPos = yPos - 1 + end + buffer.set(lines[lineNumber].x, yPos, 0x000000, 0x000000, " ") +end + +local function showLines() + for i = 1, #lines do + showLine(i) + end +end + +local counter = 0 +local function matrix() + showLines() + moveLines() + counter = counter + 1 + if counter >= 5 then counter = 0; generateLines() end + buffer.draw() +end + +buffer.square(1, 1, xSize, ySize, 0x000000, 0x000000, " ") +buffer.draw() + +local timerID = event.timer(speed, matrix, math.huge) + +ecs.wait() +event.cancel(timerID) +gpu.setResolution(xOld, yOld) + +buffer.square(1, 1, xSize, ySize, 0x000000, 0x000000, " ") +buffer.draw() + + + + diff --git a/Installer/Installer.lua b/Installer/Installer.lua index 2144cb90..333b3308 100644 --- a/Installer/Installer.lua +++ b/Installer/Installer.lua @@ -431,6 +431,8 @@ local apps = { "Camera.app", "Autorun.app", "BufferDemo.app", + "Matrix.app", + "AppStore.app", } local dockApps = {