Last active
September 12, 2021 01:01
-
-
Save neauoire/200d97396805dda71154 to your computer and use it in GitHub Desktop.
Pico8 Cube
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 3D CUBE | |
-- BY ALICEFFEKT | |
angle = 0 | |
function _update() | |
angle += 2 | |
if angle > 360 then | |
angle = 0 | |
end | |
end | |
function _draw() | |
rectfill(0,0,127,127,0) | |
r = 40 | |
cx = 64 | |
cy = 64 | |
stx = {0,0,0,0} | |
sty = {0,0,0,0} | |
sbx = {0,0,0,0} | |
sby = {0,0,0,0} | |
i = 0 | |
while(i < 4) do | |
angleoffset = (angle + (i*90)) % 360 | |
a = angleoffset/360 | |
ltx = cx + r * cos(a) | |
lty = cy + r * sin(a) | |
lty = lty * 0.5 | |
lbx = cx + r * cos(a) | |
lby = cy + r * sin(a) | |
lby = (lby * 0.6) + 40 | |
line(lbx,lby,ltx,lty,7) | |
-- save coordinates | |
stx[i] = ltx | |
sty[i] = lty | |
sbx[i] = lbx | |
sby[i] = lby | |
i += 1 | |
end | |
-- draw back cross | |
if angle < 135 or angle > 315 then | |
line(stx[0],sty[0],sbx[1],sby[1],8) | |
line(sbx[0],sby[0],stx[1],sty[1],8) | |
end | |
-- connect faces | |
line(stx[0],sty[0],stx[1],sty[1],7) | |
line(stx[1],sty[1],stx[2],sty[2],7) | |
line(stx[2],sty[2],stx[3],sty[3],7) | |
line(stx[3],sty[3],stx[0],sty[0],7) | |
line(sbx[0],sby[0],sbx[1],sby[1],7) | |
line(sbx[1],sby[1],sbx[2],sby[2],7) | |
line(sbx[2],sby[2],sbx[3],sby[3],7) | |
line(sbx[3],sby[3],sbx[0],sby[0],7) | |
-- draw front cross | |
if angle >= 135 and angle <= 315 then | |
line(stx[0],sty[0],sbx[1],sby[1],8) | |
line(sbx[0],sby[0],stx[1],sty[1],8) | |
end | |
-- draw text | |
print("pico",5,100,7) | |
print("f",22,100,6) | |
print("x",26,100,5) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment