wolf: format lua
This commit is contained in:
parent
43cc2a179e
commit
01f27d1076
3 changed files with 54 additions and 22 deletions
30
.luarc.json
Normal file
30
.luarc.json
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json",
|
||||||
|
"workspace.checkThirdParty": false,
|
||||||
|
"workspace.library": ["~/.local/lib/picotron-definitions"],
|
||||||
|
"runtime.version": "Lua 5.4",
|
||||||
|
"diagnostics.disable": ["lowercase-global"],
|
||||||
|
"runtime.nonstandardSymbol": ["!=", "+=", "-=", "*=", "/=", "%=", "^=", "|=", "&=", "<<=", ">>=", "//"],
|
||||||
|
"runtime.builtin": {
|
||||||
|
"basic": "enable",
|
||||||
|
"bit": "disable",
|
||||||
|
"bit32": "disable",
|
||||||
|
"builtin": "enable",
|
||||||
|
"coroutine": "enable",
|
||||||
|
"debug": "enable",
|
||||||
|
"ffi": "disable",
|
||||||
|
"io": "disable",
|
||||||
|
"jit": "disable",
|
||||||
|
"math": "enable",
|
||||||
|
"os": "disable",
|
||||||
|
"package": "disable",
|
||||||
|
"string": "enable",
|
||||||
|
"table": "enable",
|
||||||
|
"table.clear": "disable",
|
||||||
|
"table.new": "disable",
|
||||||
|
"utf8": "enable"
|
||||||
|
},
|
||||||
|
"runtime.special": {
|
||||||
|
"include": "require"
|
||||||
|
}
|
||||||
|
}
|
||||||
10
flake.lock
generated
10
flake.lock
generated
|
|
@ -2,12 +2,10 @@
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1728279793,
|
"lastModified": 0,
|
||||||
"narHash": "sha256-W3D5YpNrUVTFPVU4jiEiboaaUDShaiH5fRl9aJLqUnU=",
|
"narHash": "sha256-z5NJPSBwsLf/OfD8WTmh79tlSU8XgIbwmk6qB1/TFzY=",
|
||||||
"owner": "NixOS",
|
"path": "/nix/store/99f9ksfwybf3naavcfs42wjyssqiliq5-source",
|
||||||
"repo": "nixpkgs",
|
"type": "path"
|
||||||
"rev": "f85a2d005e83542784a755ca8da112f4f65c4aa4",
|
|
||||||
"type": "github"
|
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"id": "nixpkgs",
|
"id": "nixpkgs",
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@
|
||||||
player = {
|
player = {
|
||||||
origin = {
|
origin = {
|
||||||
x = nil,
|
x = nil,
|
||||||
y = nil
|
y = nil,
|
||||||
},
|
},
|
||||||
dir = nil
|
dir = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
col_bg = 1
|
col_bg = 1
|
||||||
|
|
@ -12,22 +12,22 @@ col_ground = 6
|
||||||
fov = (120 / 180) * math.pi -- 120 horizontal
|
fov = (120 / 180) * math.pi -- 120 horizontal
|
||||||
|
|
||||||
function _init()
|
function _init()
|
||||||
for i=0,31 do
|
for i = 0, 31 do
|
||||||
for j=0,31 do
|
for j = 0, 31 do
|
||||||
if mget(i,j) == 5 then -- player id
|
if mget(i, j) == 5 then -- player id
|
||||||
player.origin.x = i + 0.5
|
player.origin.x = i + 0.5
|
||||||
player.origin.y = j + 0.5
|
player.origin.y = j + 0.5
|
||||||
player.dir = 0
|
player.dir = 0
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if (player.x) break
|
if player.x then
|
||||||
|
break
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function cast_ray(origin, angle)
|
function cast_ray(origin, angle) end
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
function draw_minimap()
|
function draw_minimap()
|
||||||
local tile_size = 4
|
local tile_size = 4
|
||||||
|
|
@ -48,9 +48,9 @@ end
|
||||||
function _draw()
|
function _draw()
|
||||||
cls(col_bg)
|
cls(col_bg)
|
||||||
rectfill(0, 135, 480, 270, col_ground)
|
rectfill(0, 135, 480, 270, col_ground)
|
||||||
local angle_step=(fov / 480) / 360 * math.pi
|
local angle_step = (fov / 480) / 360 * math.pi
|
||||||
for x=0,480-1 do
|
for x = 0, 480 - 1 do
|
||||||
local angle = (player.dir-(fov/2) + x * angle_step) % (2 * math.pi)
|
local angle = (player.dir - (fov / 2) + x * angle_step) % (2 * math.pi)
|
||||||
local bloc, dist = cast_ray(player.origin, angle)
|
local bloc, dist = cast_ray(player.origin, angle)
|
||||||
end
|
end
|
||||||
draw_minimap()
|
draw_minimap()
|
||||||
|
|
@ -58,13 +58,17 @@ end
|
||||||
|
|
||||||
function _update()
|
function _update()
|
||||||
local speed = 0.1
|
local speed = 0.1
|
||||||
if (btn(0)) player.dir -= speed
|
if btn(0) then
|
||||||
if (btn(1)) player.dir += speed
|
player.dir -= speed
|
||||||
if (btn(2)) then
|
end
|
||||||
|
if btn(1) then
|
||||||
|
player.dir += speed
|
||||||
|
end
|
||||||
|
if btn(2) then
|
||||||
player.origin.x += math.cos(player.dir) * speed
|
player.origin.x += math.cos(player.dir) * speed
|
||||||
player.origin.y += math.sin(player.dir) * speed
|
player.origin.y += math.sin(player.dir) * speed
|
||||||
end
|
end
|
||||||
if (btn(3)) then
|
if btn(3) then
|
||||||
player.origin.x -= math.cos(player.dir) * speed
|
player.origin.x -= math.cos(player.dir) * speed
|
||||||
player.origin.y -= math.sin(player.dir) * speed
|
player.origin.y -= math.sin(player.dir) * speed
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue