Skip to content

Commit

Permalink
Updated directory structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
nagolove committed Jan 22, 2019
1 parent 36342a9 commit 8652214
Show file tree
Hide file tree
Showing 60 changed files with 6,357 additions and 0 deletions.
42 changes: 42 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
- список рекордов, который прокручивается
- два режима игры - со звуком и без (как-же тогда быть с таблицей рекордов?)
как вариант - звук не отключать. Хорошая идея
- чистка истории, запаковка репозитория на гитхаб
[+] подготовка README.md со стандартными пунктами
сделал, пока рыба
подготовка бинарных файлов
[+] пунк помощи в меню, с првилами
сделал, пока без правил, рыба
- интернационализация?(нафиг)
- показ сигнала два раза подряд на одном и том же месте

BUGS
- кривой рендеринг в текстуру списка рекордов.
При залитие на гитхаб - дай ссылку Дожу, добавить клавишу скриншота.
- нажатие пробела во время игры

[28.07.2018]

Сделано почти нихуя. Пункты меню не работают. Игровой цикл отсутствует.
Решено делать четыре типа раздражителей - позиция(4 * 4 = 16 вариантов),
цвет(зеленый, красный, синий, желтый, фиолетовый, коричневый = 6 вариантов),
форма(прямоугольник, круг, треугольник вниз, треугольник вверх, треугольник вниз + треугольник вверх,
ромб), звук(выстрел, гитара, барабан, тарелка, свисток, кряканье утки, лай собаки, мяуканье кошки, мычание коровы,
визг тормозов).

Скачать семпл паки на rutracker.org, ренойз 2.8.

Как всю шляпу запускать? Раннер для виндос, порт на андроид.

[08.09.2018]

- список рекордов не прокручивается
- список рекордов не сортируется
- на https://github.com/nagolove/nback залит репозиторий с бинарниками
- не оформлен ридми.эмди
- статья о исследовании http://www.pnas.org/content/pnas/105/19/6829.full.pdf
- режим подсказски, который показывает эн-предыдущий элемент в нужном месте


Три метода nback.check_form(), nback.check_color(), nback.check_sound(), check_position()
переписать в одну функцию с параметром.
72 changes: 72 additions & 0 deletions bhupur.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
local lg = love.graphics

local bhupur = {
color = {0.1, 0.1, 0.1}
}

function bhupur.draw(x, y, w)
-- width - size in pixels of square in center on bhupur
-- neck - percentage value(0-1) of yantrawidth
-- foot - percentage value(0-1) of yantrawidth
-- height - size in pixels on bhupur
local height = 30
local foot = 0.8 * w
local neck = 0.5 * w
local stair = math.abs((w - neck - foot) / 2)
local tmp = (w - neck) / 2

local topw = w * 0.6
local paramw = 80
local points = {
x, y,
x + tmp, y,
x + tmp, y - height / 2,
x + tmp - stair, y - height / 2, --
x + tmp - stair, y - height,
x + tmp - stair + foot, y - height, --
x + tmp - stair + foot, y - height / 2,
x + tmp - stair * 2 + foot, y - height / 2,
x + tmp - stair * 2 + foot, y,
x + w, y,
}
local old = pack(lg.getColor())
lg.setColor(bhupur.color)
lg.setLineWidth(2)

lg.line(points)

local xcenter = x + w / 2
local ycenter = y + w / 2

lg.translate(xcenter, y)
lg.rotate(math.pi / 1)
lg.translate(-xcenter, -y - w)
lg.line(points)
lg.origin()

lg.translate(xcenter, y)
lg.rotate(math.pi + math.pi / 2)
lg.translate(-xcenter - w / 2, -y - w / 2)
lg.line(points)
lg.origin()

lg.translate(xcenter, y / 1)
lg.rotate(math.pi - math.pi / 2)
lg.translate(-xcenter + w / 2, -y - w / 2)
lg.line(points)
lg.origin()

lg.setColor(old)
lg.setLineWidth(1)

local function centralAxis()
local scrw, scrh = lg.getDimensions()
lg.setColor({100, 100, 100})
lg.line(scrw / 2, 0, scrw / 2, scrh)
lg.line(0, scrh / 2, scrw, scrh / 2)
end

--centralAxis()
end

return bhupur
88 changes: 88 additions & 0 deletions colorpicker.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
local class = require "libs.30log"
local suit = require "libs.suit"
local inspect = require "libs.inspect"
local lg = love.graphics

local colorpicker = class("colorpicker")

function colorpicker:init()
print(string.format("Colorpicker created"))
self.color = {0.5, 0.5, 0.5, 1}
self.rslider = {value = self.color[1], min = 0, max = 1}
self.gslider = {value = self.color[2], min = 0, max = 1}
self.bslider = {value = self.color[3], min = 0, max = 1}
self.aslider = {value = self.color[4], min = 0, max = 1}
--self.canvas = lg.newCanvas(lg.getWidth(), lg.getHeight(), { type = "2d", format = "normal", msaa = 4})
self.canvas = lg.newCanvas(lg.getWidth(), lg.getHeight())
print("self.canvas = ", inspect(self.canvas))
end

-- button = 1 -- primary button
-- button = 2 -- secondary button
function colorpicker:mousepressed(x, y, button, istouch)
-- беру пиксель пипетки
if button == 2 then
local imgdata = self.canvas:newImageData()
local r, g, b, a = imgdata:getPixel(love.mouse.getPosition())
self.color[1], self.color[2], self.color[3] = r, g, b
self.rslider.value, self.gslider.value, self.bslider.value, self.bslider.value = r, g, b, a
-- копирование в буфер обмена
elseif button == 3 then
print("color copied to clpbrd")
love.system.setClipboardText(string.format("{%s, %s, %s}", self.color[1], self.color[2], self.color[3]))
end
end

function colorpicker:mousereleased(x, y, button, istouch)
end

function colorpicker:mousemoved(x, y, dx, dy, istouch)
end

function colorpicker:draw(func)
lg.setCanvas(self.canvas)
lg.setColor(1, 1, 1, 1)
func()
lg.setCanvas()
if self.canvas then lg.draw(self.canvas, 0, 0) end

local pickerwidth = 200
local pickerheight = 128
local w, h = lg.getDimensions()
local cornerx, cornery = (w - pickerwidth) / 2, h / 3
local old = pack(lg.getColor())
--local lc = pack(lg.getColor(
--print("getColor()", inspect(lc))
--print("self.color", inspect(self.color))
lg.setColor(self.color)
lg.rectangle("fill", cornerx, cornery, pickerwidth, pickerheight, 3, 3)
lg.setColor(old)

cornery = cornery + pickerheight

local sliderh = 16
suit.Slider(self.rslider, cornerx, cornery, pickerwidth, sliderh)
lg.print(string.format("%3f", self.color[1]), cornerx + pickerwidth, cornery)
cornery = cornery + sliderh
suit.Slider(self.gslider, cornerx, cornery, pickerwidth, sliderh)
lg.print(string.format("%3f", self.color[2]), cornerx + pickerwidth, cornery)
cornery = cornery + sliderh
suit.Slider(self.bslider, cornerx, cornery, pickerwidth, sliderh)
lg.print(string.format("%3f", self.color[3]), cornerx + pickerwidth, cornery)
cornery = cornery + sliderh
suit.Slider(self.aslider, cornerx, cornery, pickerwidth, sliderh)
if self.color[4] then
lg.print(string.format("%3f", self.color[4]), cornerx + pickerwidth, cornery)
end

suit.draw()
end

function colorpicker:update(dt)
self.color = {self.rslider.value, self.gslider.value, self.bslider.value}
--print("color = ", inspect(self.color))
--print(string.format("color[1] = %f color[2] = %f color[3] = %f", self.color[1], self.color[2], self.color[3]))
end

return colorpicker

18 changes: 18 additions & 0 deletions common.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

function pack(...)
return {...}
end

function xassert(a, ...)
if a then return a, ... end
local f = ...
if type(f) == "function" then
error(f(select(2, ...)), 2)
else
error(f or "assertion failed!", 2)
end
end

function table.copy(t)
return {unpack(t)}
end
5 changes: 5 additions & 0 deletions conf.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function love.conf(t)
--t.console = true
t.window.msaa = 4
t.window.vsync = false
end
26 changes: 26 additions & 0 deletions dbg.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

local dbg = {
show = true
}

local g = love.graphics
local y = 0

function dbg.clear()
y = 0
end

function dbg.print_text(text)
if not dbg.show then return end

local color = {g.getColor()}
g.setColor(1, 0.5, 0)
g.print(text, 5, y)
local font = g.getFont()
if font then
y = y + font:getHeight()
end
g.setColor(unpack(color))
end

return dbg
62 changes: 62 additions & 0 deletions geo.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

local geo = {}

function geo.isPointInCircle(px, py, cx, cy, cr)
return (px - cx)^2 + (py - cy)^2 <= cr ^ 2
end

-- check - is point lie on circle
function isPointOnCircle(px, py, cx, cy, cr, theta)
return ((px - cx)^2 + (py - cy)^2 - cr ^ 2) <= theta
end

function isPointOnLine(px, py, x1, y1, x2, y2)
local p = (px - x2) / (x1 - x2)
if 0 <= p and p <= 1 then
local x = p * x1 + (1 - p) * x2
local y = p * y1 + (1 - p) * y2
return x == y
end
return false
end

function geo.dist(x1, y1, x2, y2)
return math.sqrt((x2 - x1) ^ 2 + (y2 - y1) ^ 2)
end

function geo.lineCross(x1, y1, x2, y2, x3, y3, x4, y4)
--print(x1, y1, x2, y2, x3, y3, x4, y4)
local divisor = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1)

-- lines are parralell
if divisor == 0 then return nil end

local ua = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3)
ua = ua / divisor
--local ub = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3)
--ub = ub / divisor
--print("lineCross ua: ",ua, " ub: ", ub)
local x, y = x1 + ua * (x2 - x1), y1 + ua * (y2 - y1)
if not (x > x1 and x < x2 and y < y2 and y > y1) then
--print("point is not on segment")
return nil
end
return x, y
end

-- [[
-- Function expect array of (x, y) points in yantra internal coordinate format(-1, 1) and translates
-- it to screen size of width and height. Returns translated points array.
-- ]]
function translate2Screen(points, w, h)
local ret = {}
for _, v in pairs(points) do
assert(v.x >= -1 and v.x <= 1, string.format("unsupported x = %f for range (-1, 1)", v.x))
assert(v.y >= -1 and v.y <= 1, string.format("unsupported y = %f for range (-1, 1)", v.y))
local t = { x = 2.0 / (v.x + 1) * w, y = 2.0 / (v.y - 1) * h}
ret[#ret + 1] = t
end
return ret
end

return geo
Binary file added gfx/DejaVuSansMono.ttf
Binary file not shown.
Binary file added gfx/IMG_20190111_115755.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions help.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
local pallete = require "pallete"
local nback = require "nback"

local help = {
font = love.graphics.newFont("gfx/DejaVuSansMono.ttf", 15),
init = function() end,
update = function() end,
}

local g = love.graphics

function help.draw()
g.clear(pallete.background)
g.push("all")
g.setFont(help.font)
local w, h = g.getDimensions()
local y = 20
g.printf("This is a bla-bla", 0, y, w, "center")
y = y + help.font:getHeight()
g.printf("Put description here!", 0, y, w, "center")
--FIXME Not work, using nil table nback here
--g.printf("Escape - to go back", 0, bottom_text_line_y + nback.font:getHeight(), w, "center")
g.pop()
end

function help.keypressed(key)
if key == "escape" then
states.pop()
end
end

return help
24 changes: 24 additions & 0 deletions ihelp.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

local ihelp = {
}

local max_rows = 3
local max_columns = 2

-- state - string name
-- key - string name
-- description - string
function ihelp.add_hotkey_help(state, key, description)
end

function ihelp.draw()
love.graphics.clear(pallete.background)
end

function ihelp.update(dt)
end

function ihelp.keypressed(key)
end

return ihelp
Loading

0 comments on commit 8652214

Please sign in to comment.