Compare commits
36 Commits
gun_upgrad
...
4e66c875ad
Author | SHA1 | Date | |
---|---|---|---|
4e66c875ad
|
|||
812d32e70c
|
|||
d2ec1b39df
|
|||
a3ac8074ae
|
|||
85d28ae28b
|
|||
c514c61b3a
|
|||
9be828dd5c
|
|||
2b51a3472b
|
|||
95ea70baae
|
|||
b18b4f885d
|
|||
2fdb8d1a05
|
|||
fc1f84fa28
|
|||
93b63a5831
|
|||
297e6e4996
|
|||
9b3120c47b
|
|||
abee6d1206
|
|||
3151db5430
|
|||
2964159858
|
|||
95d4b6eb37
|
|||
96312e3adf
|
|||
bf9a45d87e
|
|||
36f7c6572f
|
|||
45b70d3aca
|
|||
35980d801a
|
|||
734811bd62
|
|||
4fddbea82c
|
|||
f675e31967
|
|||
0bd1463416
|
|||
267f8a3667
|
|||
fa206c37c5
|
|||
928e7f7418
|
|||
2439fda068
|
|||
d13290f438
|
|||
e3a2810f0a
|
|||
3764063b20
|
|||
90f6df2922
|
141
collisiontest.p8
Normal file
141
collisiontest.p8
Normal file
@ -0,0 +1,141 @@
|
||||
pico-8 cartridge // http://www.pico-8.com
|
||||
version 42
|
||||
__lua__
|
||||
bx0=0
|
||||
by0=0
|
||||
bx1=127
|
||||
by1=127
|
||||
lx0=0
|
||||
ly0=0
|
||||
lx1=127
|
||||
ly1=127
|
||||
|
||||
-->8
|
||||
|
||||
function collides()
|
||||
local tmin=0
|
||||
local tmax=1
|
||||
|
||||
local ldx=lx1-lx0
|
||||
local ldy=ly1-ly0
|
||||
|
||||
|
||||
-- x
|
||||
if ldx==0 then
|
||||
if (lx0<bx0 or lx0>bx1) return
|
||||
else
|
||||
local tx0=(bx0-lx0)/ldx
|
||||
local tx1=(bx1-lx0)/ldx
|
||||
if (tx0 > tx1) tx0,tx1=tx1,tx0
|
||||
if (tmin < tx0) tmin=tx0
|
||||
if (tmax > tx1) tmax=tx1
|
||||
end
|
||||
|
||||
if ldy==0 then
|
||||
if (ly0<by0 or ly0>by1) return
|
||||
else
|
||||
local ty0=(by0-ly0)/ldy
|
||||
local ty1=(by1-ly0)/ldy
|
||||
if (ty0 > ty1) ty0,ty1=ty1,ty0
|
||||
if (tmin < ty0) tmin=ty0
|
||||
if (tmax > ty1) tmax=ty1
|
||||
end
|
||||
|
||||
if (tmax < tmin) return
|
||||
return tmin,tmax
|
||||
end
|
||||
|
||||
|
||||
-->8
|
||||
function _init()
|
||||
poke(0x5f2d,1) -- enable mouse
|
||||
end
|
||||
|
||||
function _bounce_screen(x)
|
||||
return _bounce(x*128,128)
|
||||
end
|
||||
function _bounce(x,mx)
|
||||
x=x%(mx * 2)
|
||||
if (x>=mx)return mx-(x-mx)
|
||||
return x
|
||||
end
|
||||
|
||||
function _to_halfopen(x0,x1)
|
||||
-- turn two numbers into a
|
||||
-- half-open integer range
|
||||
x0=flr(x0)
|
||||
x1=flr(x1)
|
||||
local lo=min(x0,x1)
|
||||
local hi=max(x0,x1)
|
||||
if (hi==lo) return lo,hi
|
||||
return lo,hi-1
|
||||
end
|
||||
|
||||
function _update60()
|
||||
local t=time()/16
|
||||
|
||||
local bx0_=_bounce_screen(t*1)
|
||||
local by0_=_bounce_screen(t*2)
|
||||
local bx1_=_bounce_screen(t*3)
|
||||
local by1_=_bounce_screen(t*4)
|
||||
|
||||
bx0,bx1=_to_halfopen(bx0_,bx1_)
|
||||
by0,by1=_to_halfopen(by0_,by1_)
|
||||
|
||||
update_line()
|
||||
|
||||
--[[
|
||||
local lx0_=_bounce_screen(t*1.5)
|
||||
local ly0_=_bounce_screen(t*2.5)
|
||||
local lx1_=_bounce_screen(t*3.5)
|
||||
local ly1_=_bounce_screen(t*4.5)
|
||||
|
||||
lx0,lx1=lx0_,lx1_
|
||||
ly0,ly1=ly0_,ly1_
|
||||
]]--
|
||||
end
|
||||
|
||||
was_down=false
|
||||
last_mx,last_my=nil,nil
|
||||
|
||||
function update_line()
|
||||
local mx,my=stat(32),stat(33)
|
||||
local is_down=stat(34)!=0
|
||||
|
||||
if is_down then
|
||||
if was_down then
|
||||
lx1,ly1=mx,my
|
||||
else
|
||||
lx0,ly0=mx,my
|
||||
end
|
||||
end
|
||||
was_down=is_down
|
||||
last_mx,last_my=mx,my
|
||||
end
|
||||
-->8
|
||||
function _draw()
|
||||
cls(0)
|
||||
rect(bx0,by0,bx1,by1,6)
|
||||
line(lx0,ly0,lx1,ly1,2)
|
||||
local cmin, cmax = collides()
|
||||
if cmin then
|
||||
local dx,dy=lx1-lx0,ly1-ly0
|
||||
line(lx0 + dx*cmin,
|
||||
ly0 + dy*cmin,
|
||||
lx0 + dx*cmax,
|
||||
ly0 + dy*cmax,
|
||||
8)
|
||||
pset(lx0 + dx*cmin,
|
||||
ly0 + dy*cmin,
|
||||
12)
|
||||
end
|
||||
|
||||
pset(last_mx,last_my,7)
|
||||
end
|
||||
__gfx__
|
||||
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
857
vacuum_gambit.p8
857
vacuum_gambit.p8
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user