Compare commits
2 commits
0ba85c04db
...
834b40e932
Author | SHA1 | Date | |
---|---|---|---|
|
834b40e932 | ||
|
d509a2cc2f |
25
flake.lock
Normal file
25
flake.lock
Normal file
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1728279793,
|
||||
"narHash": "sha256-W3D5YpNrUVTFPVU4jiEiboaaUDShaiH5fRl9aJLqUnU=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "f85a2d005e83542784a755ca8da112f4f65c4aa4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
17
flake.nix
Normal file
17
flake.nix
Normal file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
description = "Cartridges";
|
||||
|
||||
outputs = { self, nixpkgs }:
|
||||
let pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||
in {
|
||||
devShell.x86_64-linux = with pkgs;
|
||||
mkShell {
|
||||
buildInputs = [
|
||||
just
|
||||
lua-language-server
|
||||
];
|
||||
};
|
||||
|
||||
formatter.x86_64-linux = pkgs.nixfmt;
|
||||
};
|
||||
}
|
|
@ -1,6 +1,9 @@
|
|||
player = {
|
||||
x = nil,
|
||||
y = nil
|
||||
origin = {
|
||||
x= nil,
|
||||
y = nil
|
||||
},
|
||||
dir = nil
|
||||
}
|
||||
|
||||
col_bg = 1
|
||||
|
@ -10,18 +13,29 @@ function _init()
|
|||
for i=0,31 do
|
||||
for j=0,31 do
|
||||
if mget(i,j) == 5 then -- player id
|
||||
player.x = i
|
||||
player.y = j
|
||||
player.origin.x = i + 0.5
|
||||
player.origin.y = j + 0.5
|
||||
player.dir = math.pi / 2
|
||||
break
|
||||
end
|
||||
end
|
||||
if (player.x) break
|
||||
end
|
||||
print("player: ("..player.x..", "..player.y..")")
|
||||
print("player: ("..player.origin.x..", "..player.origin.y..")")
|
||||
end
|
||||
|
||||
function cast_ray(origin, angle)
|
||||
|
||||
end
|
||||
|
||||
function _draw()
|
||||
cls(col_bg)
|
||||
rectfill(0, 135, 480, 270, col_ground)
|
||||
local fov = 120 -- horizontal
|
||||
local angle_step=(fov / 480) / 360 * math.pi
|
||||
for x=0,480-1 do
|
||||
local angle = (player.dir-(fov/2) + x * angle_step) % (2 * math.pi)
|
||||
local bloc, dist = cast_ray(player.origin, angle)
|
||||
end
|
||||
-- map()
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue