-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcube3d.p8
67 lines (64 loc) · 1.99 KB
/
cube3d.p8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
pico-8 cartridge // http://www.pico-8.com
version 41
__lua__
function _init()
x1 = {0,0,0}
x2 = {20,0,0}
x3 = {0,20,0}
x4 = {20,20,0}
x5 = {0,0,20}
x6 = {20,0,20}
x7 = {0,20,20}
x8 = {20,20,20}
positions = {x1,x2,x3,x4,x5,x6,x7,x8}
player = {10,0,-10}
ssize = 128
angle = 0.125
base_x = 64
base_y = 64
end
function _update()
if(btn(⬆️)) then
base_y -= 1
elseif(btn(⬇️)) then
base_y += 1
end
if(btn(⬅️)) then
x1[1] += 1
x2[1] += 1
x5[1] += 1
x6[1] += 1
elseif btn(➡️) then
x1[1] -= 1
x2[1] -= 1
x5[1] -= 1
x6[1] -= 1
end
end
function _draw()
cls()
for i = 1,8 do
local dx1 = {player[1] - positions[i][1]}
//print(dx1[1]*128/ssize)
local angle1 = asin((positions[i][2]-player[2])/(positions[i][1]-player[1]))
//print(asin((positions[i][2]-player[2])/(positions[i][1]-player[1])))
local ps1 =dx1[1]*abs(player[3]-positions[i][3])/40/cos(angle1)
pset(ps1+base_x,abs(player[2]-positions[i][2])+base_y,7)
print(i)
print(abs(player[2]-positions[i][2])+base_y)
end
//pset(x2[1]/x2[2]*128/ssize,80-x2[2],7)
//pset(x3[1]/x3[2]*128/ssize,80-x3[2],7)
//pset(x4[1]/x4[2]*128/ssize,80-x4[2],7)
//pset(player[1]+dm,player[2]+80,7)
end
function asin(y)
return atan2(sqrt(1-y*y),-y)
end
__gfx__
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000