CP MCSIMAGEFILE/ ¬©/` / 7 7ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿsystem€ /hlibraryè'/@REV3è'/@REV2D,/@REV1D,/@LOCAL40D,/@LOCAL39D,/@LOCAL38D,/@LOCAL37D,/@LOCAL36D,/@LOCAL35D,/@LOCAL34D,/@LOCAL33D,/@LOCAL32D,/@LOCAL31D,/@LOCAL30D,/@LOCAL29D,/@LOCAL28D,/@LOCAL27D,/@LOCAL26D,/@LOCAL25D,/@LOCAL24D,/@LOCAL23D,/@LOCAL22D,/@LOCAL21D,/@LOCAL20D,/@LOCAL19D,/@LOCAL18D,/@LOCAL17D,/@LOCAL16D,/@LOCAL15D,/@LOCAL14D,/@LOCAL13D,/@LOCAL12D,/@LOCAL11D,/@LOCAL10D,/@LOCAL9D,/@LOCAL8D,/@LOCAL7D,/@LOCAL6D,/@LOCAL5D,/@LOCAL4D,/@LOCAL3D,/@LOCAL2D,/@LOCAL1D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/D,/SpaceD,/ SpaceRES”˜/main¬©/@APLWORK¬©/BMPOpt Calc Random Value (CalRandom)ÿÿÿÿGraph Graph Sheet 2D (Sheet),ä&~ä+,ä0,ä1,ä3,ä4,ä5,(f1-f100),(Modify),(Graph2D)Graph Graph Sheet 3D (Sheet3D),ä2,(z1-z100),(Graph3D)Graph Graph Summary (summary)Graph View Window ä~ä#,äÐ,(ViewWindow)Graph View Window 3D ä~äGraph Factor ä$,ä%Graph Table ä/,ä,,ä-,ä.Graph Conics Eq ä\Graph Sequence äG,äE,äF,äH,äR,äS,äT,äI~äQ,(an-cn+2),(seq_hist),(Sequence)ÿÿÿÿRuncas Ans Memory (ANSMEM)Runcas Main History (HISTRY)Runcas eAct (EAC_TEMP)Runcas Geometry (GEO_TEMP)Runcas Clipboad (CLIP)ÿÿÿÿSetup Setup "system\StupList","system\StupPict","system\StupFLG1",(StupFLG2)ÿÿÿÿSolve Numeric Solve (NumericSolveData)ÿÿÿÿSetup Setup "system\STATSYS","system\LISTSYS"Stat Stat List "system\STATSYS","system\LISTSYS",ä]~äbStat Stat Result äc,äd~äu,(IntrnalCodeS)ÿÿÿÿSpaceLNa_logicP ¤Na_pickup ô˜Na_playerŒàNa_projsl ¬Na_ships%4Na_ships25LüNa_ships3:H  Ne_gameDè hNe_mmenuNP8NengineQˆ0Nlevel1a¸XNresourceh@N LuaSource10>jÁÙ+PATH="Space/" NEXTENG="mmenu" disp_fps=1 disp_mem=1 function include(p) doscript(PATH..p,{E=getfenv()}) end ---------------------------- include("engine") include("resource") showgraph() fullscreen(1) draw.onbuffer() repeat loadengine(NEXTENG) run() until NEXTENG=="" LuaSource10>jÁÙ ‚if not args then return end setfenv(1,args.E) --[[ Logic and point based actors Those don't have a collision box and usually work with other solid actors. ]] ACTORS.beam={ dy=-1, bb={0,0,0,0}, d=0, hit="solid", think=function(a) a.yhit=a.y+240*a.dy local h if not G[a.hit] then return end for _,k in pairs(G[a.hit]) do if a~=k and a.owner~=k then if a.x>k.x+k.bb[1] and a.xa.y then a.yhit=k.y+k.bb[2] h=k end elseif a.dy==-1 then if k.y+k.bb[4]>a.yhit and k.y+k.bb[4]180 then for _,t in pairs(a.tanks) do t:kill() end a:kill() return end for _,t in pairs(a.tanks) do local n,dx,dy n=a.nodes[t.next] if t.d==1 then dx,dy=a.nodes[t.next][3],a.nodes[t.next][4] else dx,dy=-a.nodes[t.next+1][3],-a.nodes[t.next+1][4] end t.ty=t.ty+1 t.tx,t.ty=t.tx+dx,t.ty+dy if t.tx*dx>(a.x+n[1])*dx or t.ty*dy>(a.y+n[2])*dy then t.next=t.next+t.d if not a.nodes[t.next] then if a.loop then if t.d==1 then t.next=1 else t.next=#a.nodes end else t.d=-t.d t.next=t.next+2*t.d n=a.nodes[t.next-t.d] end end t.tx,t.ty=a.x+n[1],a.y+n[2] end t.x,t.y=t.tx,t.ty end end, draw=function(a) local k=2 if a.loop then k=1 end for i=k,#a.nodes do local j=i-1 if j==0 then j=#a.nodes end draw.line(a.x+a.nodes[j][1],a.y+a.nodes[j][2],a.x+a.nodes[i][1],a.y+a.nodes[i][2]) end end, } LuaSource10>jÁÙuif not args then return end setfenv(1,args.E) --[[ Pickups and pickup spawners Give bonus points or powerups. ]] ACTORS.dgem={ think=function(a) spawn("gem",{x=a.x-10,y=a.y}) spawn("gem",{x=a.x+10,y=a.y}) a:kill() end, } ACTORS.coin={ defgroups={"pickup"}, score=50, dy=1, bb={-5,-5,5,5}, p_idle=getres("coin"), destroy=function(a) a:ungroup("pickup") a.tx,a.ty,a.dty=a.x,a.y,0 end, think=function(a) a.y=a.y+a.dy if a.y>180 then a:kill() end end, draw=function(a) if a.ty then draw.text(a.tx-10,a.dty+a.ty-3,a.score,1,8) a.dty=a.dty-1 if a.dty==-8 then a:kill() end else draw.anim(a.x+a.bb[1],a.y+a.bb[2],a.p_idle,"or") end end, } ACTORS.gem={ base="coin", score=100, p_idle=getres("gem"), } ACTORS.lgem={ base="coin", score=500, p_idle=getres("lgem"), bb={-6,-10,6,10}, }arg LuaSource10>jÁÙ¿if not args then return end setfenv(1,args.E) --[[ Player This is your ship, duh. It also manages your score, and other stats (accuracy, weapons). ]] ACTORS.player={ defgroups={"solid","player"}, t="", x=100, y=139, power=100, rate=2, gun=-2, charge=0, health=100, maxhealth=100, N_enemies=0, N_destroyed=0, N_shots=0, N_hits=0, spd=4, p_explo=getres("explo2"), bb={-9,0,9,20}, score=0, destroy=function(a) a.f=1 a:ungroup("player") end, endlevel=function(a) a.dy=4 a.ddy=-0.4 a:ungroup("player") a.t="" end, think=function(a) if a.dy then a.y=a.y+a.dy a.dy=a.dy+a.ddy if a.y<-100 then a.levelend=1 end return end a.power=a.power+a.rate if a.power>100 then a.power=100 end local k=a:collide("flying") if k then a:hurt(k.dmg or 10) k:hurt(k.sdmg or 10) end local k=a:collide("pickup") if k then a.score=a.score+(k.score or 0) k:destroy() end if a.charge>0 then a.charge=a.charge-1 end a.t="" if testkey(K_LEFT) and a.x>10 then a.t="l" a.x=a.x-a.spd elseif testkey(K_RIGHT) and a.x<149 then a.t="r" a.x=a.x+a.spd end if testkey(K_UP) and a.y>0 then a.y=a.y-a.spd elseif testkey(K_DOWN) and a.y<139 then a.y=a.y+a.spd end if testkey(K_EQUAL) and a.charge==0 and a.power>=10 then a:shoot() a.power=a.power-10 a.N_shots=a.N_shots+1 end if testkey(K_x) and not a.beam then a.beam=makeactor("beam") a.beam.x=a.x a.beam.y=a.y a.beam.owner=a end if a.beam then if not testkey(K_x) or a.power<3 then a.beam:kill() a.beam=nil end a.power=a.power-3 a.N_shots=a.N_shots+1 end end, draw=function(a) if a.f then draw.anim(a.x-(a.p_explo.w-1)/2,a.y,a.p_explo,"or") if a.p_explo.e then a:kill() a.f=2 end else draw.pict(a.x-10,a.y,res["player"..a.t],"or") end end, shoot=function(a) spawn("laser",{dx=0,x=a.x,y=a.y-2,owner=a}) --spawn("laser",{dx=-1,x=a.x-2,y=a.y-2,owner=a}) --spawn("laser",{dx=1,x=a.x+2,y=a.y-2,owner=a}) a.charge=5 end, hurt=function(a,d) a.health=a.health-d if a.health<=0 then a:destroy() end end, } LuaSource10>jÁÙ ‹if not args then return end setfenv(1,args.E) --[[ Projectiles Any projectile fired by your ship or enemies. (laser beams don't count as projectiles, you will find them in a_logic) "bullet" is the base enemy projectile. ]] ACTORS.bullet={ dx=0, dy=4, bb={-1,-1,1,1}, dmg=10, p_explo=getres("laserexplo"), destroy=function(a,k) a.f=1 a:ungroup("solid") if k then a.dx,a.dy=k.dx or 0,k.dy or 1 else a.dx,a.dy=0,1 end end, think=function(a) if a.x<-4 or a.x>164 or a.y<-4 or a.y>164 then a:kill() end if a.f then return end local k=a:collide("player") if k then k:hurt(a.dmg) a:destroy() end a.x=a.x+a.dx a.y=a.y+a.dy end, draw=function(a) if a.f then draw.anim(a.x-(a.p_explo.w-1)/2,a.y-(a.p_explo.h-1)/2,a.p_explo,"or") if a.p_explo.e then a:kill() end else if a.p_idle then draw.anim(a.x+a.bb[1],a.y+a.bb[2],a.p_idle,"or") else draw.rect(a.x+a.bb[1],a.y+a.bb[2],a.x+a.bb[3],a.y+a.bb[4]) end end end, } ACTORS.laser={ dx=0, dy=-8, bb={-1,-2,1,2}, p_explo=getres("laserexplo"), destroy=function(a,k) a.f=1 if k then a.dx,a.dy=k.dx or 0,k.dy or 1 else a.dx,a.dy=0,1 end end, think=function(a) if a.y<-3 then a:kill() end if a.f then return end local k=a:collide("solid") if k then if k:ingroup("damageable") then k:hurt(10) PLAYER.N_hits= PLAYER.N_hits+1 end a:destroy(k) end a.x=a.x+a.dx a.y=a.y+a.dy end, draw=function(a) if a.f then draw.anim(a.x-4,a.y-4,a.p_explo,"or") if a.p_explo.e then a:kill() end else a.baseact.draw(a) end end, } ACTORS.laser2={ base="bullet", } ACTORS.laser3={ base="bullet", bb={-4,-4,-4,4}, p_idle=getres("fball1"), p_explo=getres("fireexplo"), dmg=20, } ACTORS.bullet1={ base="bullet", defgroups={"solid"}, defgroups={"solid","damageable"}, h=20, bb={-2,-5,2,5}, p_idle=getres("bullet1"), p_explo=getres("explo"), dmg=30, hurt=function(a,d) a.h=a.h-d if a.h<=0 then a:destroy() end end, } ACTORS.mine1={ base="bullet", dy=2, defgroups={"solid","damageable"}, bb={-2,-2,2,2}, p_idle=getres("mine1"), p_explo=getres("explo"), dmg=20, h=20, hurt=function(a,d) a.h=a.h-d if a.h<=0 then a:destroy() end end, think=function(a) if a.x<-4 or a.x>164 or a.y<-4 or a.y>164 then a:kill() end if a.f then return end local k=a:collide("player") if k then k:hurt(a.dmg) a:destroy() end a.x=a.x+a.dx a.y=a.y+a.dy if a.x>PLAYER.x+1 then a.x=a.x-1.5 elseif a.xjÁÙif not args then return end setfenv(1,args.E) --[[ Enemy ships Those are the enemy ships that will move around and eventually shoot at you. "brick" is the base enemy ship. ]] ACTORS.brick={ defgroups={"solid","damageable"}, health=30, p_idle=getres("ship1"), p_explo=getres("explo"), init=function(a) PLAYER.N_enemies= PLAYER.N_enemies+1 end, destroy=function(a) PLAYER.N_destroyed= PLAYER.N_destroyed+1 a.f=1 a.dy=1 a:ungroup("solid") PLAYER.score=PLAYER.score+ (a.score or 0) if a.spawn then spawn(a.spawn,{x=a.x,y=a.y}) end end, hurt=function(a,d) a.health=a.health-d if a.health<=0 then a:destroy() end end, draw=function(a) if a.f then draw.anim(a.x-(a.p_explo.w-1)/2,a.y-(a.p_explo.h-1)/2,a.p_explo,"or") if a.p_explo.e then a:kill() end else draw.anim(a.x+a.bb[1],a.y+a.bb[2],a.p_idle,"or") end end, } ACTORS.rocket1={ base="brick", dy=4, dx=0, dmg=30, sdmg=20, score=10, defgroups={"solid","damageable","flying"}, health=20, bb={-5,-5,5,5}, p_idle2=getres("thrust"), p_idle=getres("rocket1"), destroy=function(a) a.baseact.destroy(a) a:ungroup("flying") end, think=function(a) a.x=a.x+a.dx --[[if a.x>PLAYER.x+1 then a.dx=-2 elseif a.x8 then a.dx=8 end if a.dx<-8 then a.dx=-8 end a.y=a.y+a.dy if a.y>180 then a:kill() end end, draw=function(a) a.baseact.draw(a) if not a.f then draw.anim(a.x-3,a.y-17,a.p_idle2,"or") end end, } ACTORS.ship1={ base="brick", score=10, defgroups={"solid","damageable","flying"}, health=20, dy=3, bb={-5,-5,5,5}, p_idle=getres("ship1"), p_idle2=getres("thrust"), destroy=function(a) a.baseact.destroy(a) a:ungroup("flying") end, think=function(a) a.y=a.y+a.dy if a.y>180 then a:kill() end end, draw=function(a) a.baseact.draw(a) if not a.f then draw.anim(a.x-3,a.y-17,a.p_idle2,"or") end end, } ACTORS.ship2={ base="brick", score=15, defgroups={"solid","damageable","flying"}, health=20, dy=2, dx=0, ddx=0.1, bb={-5,-5,5,5}, charge=20, p_idle=getres("ship2"), p_idle2=getres("thrust"), destroy=function(a) a.baseact.destroy(a) a:ungroup("flying") end, think=function(a) a.x=a.x+a.dx a.y=a.y+a.dy a.dx=a.dx+a.ddx if a.y>180 then a:kill() end if PLAYER and a.charge==0 then a:shoot() else a.charge=a.charge-1 end end, draw=function(a) a.baseact.draw(a) if not a.f then draw.anim(a.x-3,a.y-17,a.p_idle2,"or") end end, shoot=function(a) local dx,dy=PLAYER.x-a.x,PLAYER.y-a.y local d=math.sqrt(dx^2+dy^2) dx,dy=3*dx/d,3*dy/d spawn("laser2",{dx=dx,dy=dy,x=a.x,y=a.y,owner=a}) a.charge=30 end, } ACTORS.ship3={ base="brick", score=20, defgroups={"solid","damageable","flying"}, health=30, dy=5, ddy=-0.2, bb={-7,-7,7,7}, p_idle=getres("ship3"), p_idle2=getres("thrust"), destroy=function(a) a.baseact.destroy(a) a:ungroup("flying") spawn("rocket1",{x=a.x,y=a.y}) end, think=function(a) a.y=a.y+a.dy if a.f then return end a.dy=a.dy+a.ddy if not a.fl and a.dy<0 then a.fl=1 spawn("laser3",{x=a.x,y=a.y,owner=a}) spawn("laser3",{x=a.x,y=a.y,dx=-1,dy=3.8,owner=a}) spawn("laser3",{x=a.x,y=a.y,dx=1,dy=3.8,owner=a}) end if a.y<-10 or a.y>180 then a:kill() end end, draw=function(a) a.baseact.draw(a) if not a.f then draw.anim(a.x-3,a.y-19,a.p_idle2,"or") end end, } ACTORS.cannon1={ base="brick", score=30, health=40, dy=1, bb={-5,-5,5,5}, charge=15, p_idle=getres("cannon1"), think=function(a) a.y=a.y+a.dy if a.y>180 then a:kill() end if PLAYER and a.charge==0 then a:shoot() else a.charge=a.charge-1 end end, shoot=function(a) local dx,dy=PLAYER.x-a.x,PLAYER.y-a.y local d=math.sqrt(dx^2+dy^2) dx,dy=4*dx/d,4*dy/d spawn("laser2",{dx=dx,dy=dy,x=a.x,y=a.y,owner=a}) a.charge=20 end, }ea LuaSource10>jÁÙÚif not args then return end setfenv(1,args.E) --[[ Enemy ships Part 2 ]] ACTORS.ship4={ base="brick", score=100, sdmg=0, defgroups={"solid","damageable","flying"}, health=100, p_explo=getres("explo2"), dy=4, dx=1, phase=1, ddy=-0.2, dp2=60, bb={-15,-7,15,7}, p_idle=getres("ship4"), p_idle2=getres("thrust"), destroy=function(a) a.baseact.destroy(a) a:ungroup("flying") if a.b1 then a.b1:kill() a.b2:kill() end end, think=function(a) if a.f then return end if a.phase==1 then a.y=a.y+a.dy a.dy=a.dy+a.ddy if a.dy<=0.2 then a.phase=2 a.b1=makeactor("beam") a.b1.x=a.x-13 a.b1.y=a.y+1 a.b1.dy=1 a.b1.hit="player" a.b1.owner=a a.b2=makeactor("beam") a.b2.x=a.x+13 a.b2.y=a.y+1 a.b2.dy=1 a.b2.hit="player" a.b2.owner=a end elseif a.phase==2 then a.x=a.x+a.dx a.dp2=a.dp2-1 if a.dp2==0 then a.phase=3 a.b1:kill() a.b2:kill() end elseif a.phase==3 then a.y=a.y+a.dy a.dy=a.dy-a.ddy end if a.y>180 then a:kill() end end, draw=function(a) a.baseact.draw(a) if not a.f then --draw.anim(a.x-3,a.y-19,a.p_idle2,"or") end end, } n LuaSource10>jÁÙ ~if not args then return end setfenv(1,args.E) --[[ Enemy ships Part 3 ]] ACTORS.cannon2={ base="brick", score=30, health=40, bb={-5,-5,5,5}, charge=20, p_idle=getres("cannon2"), think=function(a) if PLAYER and a.charge==0 and PLAYER.y>a.y then a:shoot() else a.charge=a.charge-1 end end, shoot=function(a) local dx,dy=PLAYER.x-a.x,PLAYER.y-a.y local d=math.sqrt(dx^2+dy^2) dx,dy=2*dx/d,2*dy/d spawn("laser2",{dx=2*dx,dy=2*dy,x=a.x,y=a.y,owner=a}) a.charge=20 end, } ACTORS.ship5={ base="brick", score=40, t=0, defgroups={"solid","damageable","flying"}, health=80, dy=1.5, charge=12, bb={-15,-10,15,5}, p_idle=getres("ship5"), p_idle2=getres("thrust"), p_explo=getres("explo2"), destroy=function(a) a.baseact.destroy(a) a:ungroup("flying") end, think=function(a) if not a.x0 then a.x0=a.x end a.y=a.y+a.dy a.x=a.x0+math.sin(a.t)*20 a.t=a.t+0.1 if a.y>180 then a:kill() end if PLAYER and a.charge==0 then a:shoot() else a.charge=a.charge-1 end end, draw=function(a) a.baseact.draw(a) if not a.f then draw.anim(a.x-3,a.y-20,a.p_idle2,"or") end end, shoot=function(a) spawn("bullet1",{x=a.x,y=a.y+8,owner=a}) a.charge=12 end, } ACTORS.ship7={ base="brick", score=50, defgroups={"solid","damageable","flying"}, health=80, dy=1, dx=2, charge=30, bb={-7,-7,7,7}, p_idle=getres("ship7"), p_explo=getres("explo1"), destroy=function(a) a.baseact.destroy(a) a:ungroup("flying") end, think=function(a) if a.x>200 or a.x<-40 or a.y>180 then a:kill() end a.x,a.y=a.x+a.dx,a.y+a.dy if PLAYER and a.charge==0 then a:shoot() else a.charge=a.charge-1 end end, shoot=function(a) spawn("mine1",{x=a.x,y=a.y,owner=a}) a.charge=20 end, } ACTORS.ship8={ base="brick", score=50, defgroups={"solid","damageable","flying"}, health=50, dy=5, ddy=-0.3, bb={-13,-10,13,5}, p_idle=getres("ship8"), p_idle2=getres("thrust"), p_explo=getres("explo2"), destroy=function(a) a.baseact.destroy(a) a:ungroup("flying") end, think=function(a) a.y=a.y+a.dy if a.f then return end if not a.ammo then a.dy=a.dy+a.ddy end if a.ammo then if a.ammo<=0 then a.dy=a.dy-a.ddy else a.ammo=a.ammo-1 if a.ammo%2==0 then spawn("laser2",{x=a.x,y=a.y+5,dy=10,dx=math.random(-100,100)/30,owner=a}) end end elseif a.dy<=1 then a.ammo=30 a.dy=1 end if a.y<-10 or a.y>180 then a:kill() end end, draw=function(a) a.baseact.draw(a) if not a.f then draw.anim(a.x-3,a.y-20,a.p_idle2,"or") end end, } ] LuaSource10>jÁÙ Hif not args then return end setfenv(1,args.E) engine_game={ init=function() if not ACTORS.player then include("a_player") include("a_projs") include("a_ships") include("a_ships2") include("a_ships3") include("a_pickup") include("a_logic") end PLAYER=makeactor("player") P=0 include("level1") N=1 BGL,BGH=160,160 BG=pict.new(BGL,BGH) BG2=pict.new(BGL,BGH+1) draw.onpict(BG) for i=0,159 do if math.random(1,3)==1 then local u=math.random(2,157) if math.random(1,4)==1 then draw.line(u-1,i,u+1,i) draw.line(u,i-1,u,i+1) else draw.pixel(u,i) end end end draw.onbuffer(BG) end, think=function() if testkey(K_0) then NEXTENG="mmenu" Q=1 return 1 end P=P+1 while L[N] and P>=L[N][1] do if not L[N][2] then local q for _,v in pairs(G.damageable or {}) do q=1 end for _,v in pairs(G.pickup or {}) do q=1 end if not q then PLAYER:endlevel() N=N+1 end break end spawn(L[N][2],L[N][3]) N=N+1 end draw.pict(0,0,BG) draw.onpict(BG2) draw.pict(0,0,BG) draw.onpict(BG) draw.clear() draw.pict(0,1,BG2) if math.random(1,3)==1 then local u=math.random(2,157) if math.random(1,4)==1 then draw.line(u-1,0,u+1,0) draw.line(u,-1,u,1) else draw.pixel(u,0) end end draw.onbuffer() if PLAYER.levelend then NEXTENG="mmenu" return 1 end if PLAYER.f==30 then Q=1 NEXTENG="mmenu" return 1 end end, postdraw=function() draw.rect(0,160,159,231,1,1,0) draw.rect(20,165,100,170) draw.rect(20,165,20+80*PLAYER.health/PLAYER.maxhealth,170,1,1,1) draw.rect(20,175,100,180) draw.rect(20,175,20+PLAYER.power*80/100,180,1,1,1) draw.text(10,218,PLAYER.score,1,8) if PLAYER.f and PLAYER.f>=2 then draw.text(49,72,"Game Over",1,12,1) PLAYER.f=PLAYER.f+1 end end, postrun=function() D=math.floor(100*PLAYER.N_destroyed/PLAYER.N_enemies) if PLAYER.N_enemies==0 then D=0 end D2=math.floor(100*PLAYER.N_hits/PLAYER.N_shots) if PLAYER.N_shots==0 then D2=0 end clearactors() if Q then return 1 end postdraw() draw.text(20,20,"Level completed",1,13,1) draw.text(20,50,"Score: "..PLAYER.score,1,10) draw.text(20,70,"Destruction: "..D.."%",1,10) draw.text(20,90,"Accuracy: "..D2.."%",1,10) draw.update() waitkey() end } LuaSource10>jÁÙif not args then return end setfenv(1,args.E) engine_mmenu={ init=function() M={ "New Game", "Load Game", "Highscores", "Options", "Quit", } S=1 end, think=function() if not kd and testkey(K_UP) and S>1 then S=S-1 kd=1 end if not kd and testkey(K_DOWN) and S<#M then S=S+1 kd=1 end if not testkey(K_DOWN) and not testkey(K_UP) then kd=nil end if testkey(K_EXE) then if S==1 then NEXTENG="game" draw.clear() draw.text((160-9*6)/2,80,"Loading...") draw.update() return 1 elseif S==5 then NEXTENG="" return 1 end end end, postdraw=function() for i=1,#M do c=0 if S==i then c=1 end draw.text((160-#M[i]*(6+c))/2,148+12*i,M[i],1,10,c) end end, postrun=function() end, } LuaSource10>jÁÙif not args then return end setfenv(1,args.E) require("draw","table") fps=0 maxfps=30 wait=0 fpscount=1 frames=0 A={} AD={} G={} -- Performs a deep copy function copy(t) if type(t)~="table" then return t end local r={} for k,v in pairs(t) do r[k]=copy(v) end return r end -- Load and display animations function pict.loadanim(fd,fl,w,h,f,l) local t,p={},pict.load(fd,fl) for i=1,f do t[i]=pict.part(p,w*i-w,0,w*i-1,h-1) end t.f,t.w,t.h,t.n,t.loop=1,w,h,f,l return t end function draw.anim(x,y,a,r) if type(a)=="userdata" then draw.pict(x,y,a,r) return end draw.pict(x,y,a[a.f],r) if a.f==a.n then if a.loop then a.f=1 else a.e=true end else a.f=a.f+1 a.e=nil end end -- Spawn an actor at the end of -- the current frame function spawn(n,args,...) local t={class=n,args=args,groups=copy(arg)} AD[t]=t end -- Spawn an actor immediatelu -- Do not use this, use spawn() -- instead function makeactor(n,...) local t=copy(ACTORS[n]) local base,q q=t repeat if not q.base then base="baseact" else base=q.base end q=ACTORS[base] for k,v in pairs(q) do if not t[k] then t[k]=copy(v) end end until base=="baseact" if t.base then t.baseact=ACTORS[t.base] else t.baseact=ACTORS.baseact end t.type=n A[t]=t if arg.n==0 and t.defgroups then arg=t.defgroups end for _,g in ipairs(arg) do if not G[g] then G[g]={} end G[g][t]=t table.insert(t.group,g) end return t end function clearactors() A={} AD={} G={} collectgarbage() end ACTORS={ baseact={ group={}, bb={0,0,0,0}, x=0, y=0, ingroup=function(a,g) for _,h in ipairs(a.group) do if h==g then return true end end return false end, ungroup=function(a,g) for i,h in ipairs(a.group) do if h==g then table.remove(a.group,i) break end end G[g][a]=nil end, collide=function(a,b) if not b or type(b)=="string" then local P=A if b then P=G[b] or {} end for _,k in pairs(P) do if a~=k and a.owner~=k then if a:collide(k) then return k end end end return nil end return a.x+a.bb[3]>=b.x+b.bb[1] and b.x+b.bb[3]>=a.x+a.bb[1] and a.y+a.bb[4]>=b.y+b.bb[2] and b.y+b.bb[4]>=a.y+a.bb[2] end, draw=function(a) draw.rect(a.x+a.bb[1],a.y+a.bb[2],a.x+a.bb[3],a.y+a.bb[4]) end, kill=function(a) for _,g in ipairs(a.group) do G[g][a]=nil end A[a]=nil collectgarbage() end, think=function(a) end, init=function(a) end, } } -- Engine events -- Override those in main -- program function init() end function think() end function postdraw() end function postrun() end function loadengine(s) if not getfenv()["engine_"..s] then pcall(include,"e_"..s) end if getfenv()["engine_"..s] then local e=getfenv()["engine_"..s] init=e.init or function() end think=e.think or function() end postdraw=e.postdraw or function() end postrun=e.postrun or function() end end end function run() init() collectgarbage() while 1 do _,_,s=gettime() if s0 and s0~=s then fps=frames wait=wait+(frames-maxfps)*60 if wait<0 then wait=0 end frames=0 end s0=s frames=frames+1 draw.clear() if think() then break end for _,v in pairs(A) do v:draw() end for _,v in pairs(A) do v:think() end postdraw() if disp_mem then local c=math.floor(collectgarbage("count")/2) local c2=math.floor(c/10) draw.rect(144,214,155,225) draw.rect(145,225-c2,154,225,1,1,1) draw.line(144,225-c2-1,145+c-10*c2-1,225-c2-1) draw.text(120,218,2*c,1,8) draw.text(133,218,"KB",1,8) end if disp_fps then draw.text(90,218,fps.." fps",1,8) end draw.update() for m,v in pairs(AD) do local t if v.groups then t=makeactor(v.class,unpack(v.groups)) else t=makeactor(v.class) end for k,w in pairs(v.args) do t[k]=w end t:init() end AD={} if wait>0 then for i=1,wait do end end end postrun() end LuaSource10>jÁÙ7if not args then return end setfenv(1,args.E) L={ --{0}, --{0,"tanktrack",{spd=4,x=0,y=-45,nodes={{10,0},{40,-30},{70,0},{40,30}},tanks={{"cannon2",1}},loop=1}}, --{0,"ship3",{x=60,y=-10}, --{0,"ship5",{x=80,y=-10}}, --{0,"ship7",{x=-20,y=-10,dx=2}}, --{20,"ship7",{x=180,y=-10,dx=-2}}, --{0,"ship8",{x=80,y=-10}}, --{0,"lgem",{x=80,y=-10}}, {50,"ship1",{x=20,y=-10}}, {70,"ship1",{x=20,y=-10}}, {90,"ship1",{x=20,y=-10}}, {110,"ship1",{x=20,y=-10}}, {115,"cannon1",{x=60,y=-10}}, {115,"cannon1",{x=100,y=-10}}, {130,"ship1",{x=20,y=-10,spawn="coin"}}, {210,"ship1",{x=140,y=-10}}, {230,"ship1",{x=140,y=-10}}, {250,"ship1",{x=140,y=-10}}, {270,"ship1",{x=140,y=-10}}, {290,"ship1",{x=140,y=-10,spawn="coin"}}, {310,"cannon1",{x=120,y=-10}}, {320,"ship2",{x=20,y=-10,ddx=0.05}}, {340,"ship2",{x=20,y=-10,ddx=0.05}}, {360,"ship2",{x=20,y=-10,ddx=0.05}}, {370,"cannon1",{x=40,y=-10}}, {380,"ship2",{x=140,y=-10,ddx=-0.05}}, {400,"ship2",{x=140,y=-10,ddx=-0.05}}, {420,"ship2",{x=140,y=-10,ddx=-0.05}}, {490,"ship3",{x=60,y=-10,spawn="gem"}}, {540,"ship3",{x=100,y=-10,spawn="gem"}}, {580,"rocket1",{x=20,y=-10}}, {600,"rocket1",{x=140,y=-10}}, {610,"ship4",{x=20,y=-10,spawn="dgem"}}, {690,"ship4",{x=140,y=-10,dx=-1,spawn="dgem"}}, {840,"cannon1",{x=30,y=-10}}, {840,"cannon1",{x=130,y=-10}}, {880,"cannon1",{x=30,y=-10}}, {880,"cannon1",{x=130,y=-10}}, {960,"ship7",{x=-20,y=-10,dx=2}}, {990,"ship7",{x=180,y=-10,dx=-2}}, {1090,"ship8",{x=50,y=-10}}, {1150,"ship8",{x=110,y=-10}}, {1210}, } LuaSource10>jÁÙif not args then return end setfenv(1,args.E) --[[ Pictures and animations ]] PATH2="SpaceRES" function loadpict(f) return pict.load(PATH2,f) end function loadanim(f,a,b,c,d) return pict.loadanim(PATH2,f,a,b,c,d) end res={ player=loadpict("ship"), playerl=loadpict("shipl"), playerr=loadpict("shipr"), ship1=loadpict("sship"), ship2=loadpict("sship2"), ship3=loadpict("mship"), ship4=loadpict("lship"), ship5=loadpict("lship2"), ship6=loadpict("sship4"), ship7=loadpict("sship5"), ship8=loadpict("lship3"), rocket1=loadpict("sship3"), cannon1=loadpict("cannon"), cannon2=loadpict("cannon2"), bullet1=loadpict("bullet1"), mine1=loadanim("mine1",5,5,2,true), fball1=loadanim("fball1",9,9,4,true), explo=loadanim("expls",31,31,6), explo2=loadanim("explm",51,35,7), laserexplo=loadanim("explss",9,9,7), fireexplo=loadanim("explsf",15,15,7), thrust=loadanim("thrust",7,14,2,true), coin=loadanim("coin",11,11,4,true), gem=loadpict("gem"), lgem=loadpict("lgem"), } function getres(s) return res[s] end f nbullet1ôMcannon(Mcannon28(Mcoin`TMexplm´8MexplsìøMexplsf ääMexplss ÈXMfball1 @Mgem `(Mlgem ˆ0 then for i=1,wait do end end end postrun() end LuaSource10>jÁÙ7if not args then return end setfenv(1,args.E) L={ --{0}, --{0,"tanktrack",{spd=4,x=0,y=-45,nodes={{10,0},{40,-30},{70,0},{40,30}},tanks={{"cannon2",1}},loop=1}}, --{0,"ship3",{x=60,y=-10}, --{0,"ship5",{x=80,y=-10}}, --{0,"ship7",{x=-20,y=-10,dx=2}}, --{20,"ship7",{x=180,y=-10,dx=-2}}, --{0,"ship8",{x=80,y=-10}}, --{0,"lgem",{x=80,y=-10}}, {50,"ship1",{x=20,y=-10}}, {70,"ship1",{x=20,y=-10}}, {90,"ship1",{x=20,y=-10}}, {110,"ship1",{x=20,y=-10}}, {115,"cannon1",{x=60,y=-10}}, {115,"cannon1",{x=100,y=-10}}, {130,"ship1",{x=20,y=-10,spawn="coin"}}, {210,"ship1",{x=140,y=-10}}, {230,"ship1",{x=140,y=-10}}, {250,"ship1",{x=140,y=-10}}, {270,"ship1",{x=140,y=-10}}, {290,"ship1",{x=140,y=-10,spawn="coin"}}, {310,"cannon1",{x=120,y=-10}}, {320,"ship2",{x=20,y=-10,ddx=0.05}}, {340,"ship2",{x=20,y=-10,ddx=0.05}}, {360,"ship2",{x=20,y=-10,ddx=0.05}}, {370,"cannon1",{x=40,y=-10}}, {380,"ship2",{x=140,y=-10,ddx=-0.05}}, {400,"ship2",{x=140,y=-10,ddx=-0.05}}, {420,"ship2",{x=140,y=-10,ddx=-0.05}}, {490,"ship3",{x=60,y=-10,spawn="gem"}}, {540,"ship3",{x=100,y=-10,spawn="gem"}}, {580,"rocket1",{x=20,y=-10}}, {600,"rocket1",{x=140,y=-10}}, {610,"ship4",{x=20,y=-10,spawn="dgem"}}, {690,"ship4",{x=140,y=-10,dx=-1,spawn="dgem"}}, {840,"cannon1",{x=30,y=-10}}, {840,"cannon1",{x=130,y=-10}}, {880,"cannon1",{x=30,y=-10}}, {880,"cannon1",{x=130,y=-10}}, {960,"ship7",{x=-20,y=-10,dx=2}}, {990,"ship7",{x=180,y=-10,dx=-2}}, {1090,"ship8",{x=50,y=-10}}, {1150,"ship8",{x=110,y=-10}}, {1210}, } LuaSource10>jÁÙ LuaSource10>jÁÙif not args then return end setfenv(1,args.E) --[[ Pictures and animations ]] PATH2="SpaceRES" function loadpict(f) return pict.load(PATH2,f) end function loadanim(f,a,b,c,d) return pict.loadanim(PATH2,f,a,b,c,d) end res={ player=loadpict("ship"), playerl=loadpict("shipl"), playerr=loadpict("shipr"), ship1=loadpict("sship"), ship2=loadpict("sship2"), ship3=loadpict("mship"), ship4=loadpict("lship"), ship5=loadpict("lship2"), ship6=loadpict("sship4"), ship7=loadpict("sship5"), ship8=loadpict("lship3"), rocket1=loadpict("sship3"), cannon1=loadpict("cannon"), cannon2=loadpict("cannon2"), bullet1=loadpict("bullet1"), mine1=loadanim("mine1",5,5,2,true), fball1=loadanim("fball1",9,9,4,true), explo=loadanim("expls",31,31,6), explo2=loadanim("explm",51,35,7), laserexplo=loadanim("explss",9,9,7), fireexplo=loadanim("explsf",15,15,7), thrust=loadanim("thrust",7,14,2,true), coin=loadanim("coin",11,11,4,true), gem=loadpict("gem"), lgem=loadpict("lgem"), } function getres(s) return res[s] end f nbullet1ôMcannon(Mcannon28(Mcoin`TMexplm´8MexplsìøMexplsfä äMexplssÈ XMfball1 @Mgem` (Mlgemˆ <MlshipÄ LMlship2dMlship3tdMmine1ØMmshipô0Mship$PMshipltPMshiprÄPMsship(Msship2<(Msship3d(Msship4Œ4Msship5À0Mthrustð(M SÐD@ÇÔÐS¾ ø¸¸¸¸¸¸¸pp  ÐSv€.€Ó`§ ¯ ¿ ß`.€ ÐSyD?€`Àß`§ ¯ ¿ ß`1€, SДy‚àÐSÃàÀ (€ ‚ (€ ‚ (€ADP(@ADP(@ADP(@"‚`( €&‚ ( € (€Àe#SÐä~‚àÐS‹ðÀ<  Àà &@ |dÀm€ðx`ò0À€™@À¾°B `" @!#H0À0 ðà&À(GˆrX@€ x@ AÈL0@ЈP `pàâ‚(à~ €€€ð°H €C@€=@È ¿@€@¡0 € €&ƒF !€pÀ) (`Gð` 1DA  À$I$$ÀH(20€€†JK 88I#†€B ( R`A€‚  „ x‰  @`@0’@˜3€¨@PD €À&$0˜ pD@€HÏ à@P, à"ð°@à`ü `ºSÐä~zÌÐS0Œ8ŒàÄ•94€ 4| € bœÀ@p0 " €€¢ 0€€BèPH€€`ü@ ¨f0 Ø$Èš (&¼NÐDX%0l2¤G‚¨@06R p*2\€@Æ4h@<I @@@€ÊÐ @T°‹À€€ UU Àh€8@€@g+À@@€ÀiSЂàÐSÂt€@€ €€€€ €€À€ €€@‰@@À@‰( TAA € :AA@ A@ –À3$BF<? e:pxxpÐS~Ààpçóæ2ÞüÜ|Þüæ2çóÀàp$ f:ŽÈbaÐSÇÔ€c5ŸÍ`A"“È €ÅwñPêÿú°ÕõPC*ŸÊ o5ŸÍ`€fba Sio¶LÐSyÜ?€U@Ê ¿`RÀ)€  SÐeg‚àÐS€Ü €@* SP¥¸úè´ØÙh’ȵXÚè­¸×Xj°7`À€SÐhs‚àÐSÀŸó·ú€ÿÿà:ªª¸WÕWÔªk¬®×Õ×Þª­ëþÿÿÿþp€P !`€ÐSÄœ?ƒøeò½LR®ê”)Zõ(ªªP Zô *©@šò€J¥ªê{¼ `À€€ÀÀÀÀÀÀSÐz8ÐSÄ,îø_Tª¨nЪ D@@@N@ÛÀ×W]`n×nÀ__Îx@@?€*€*€*€*€?€ SÐhs€ÐSyÀs€@ÀÀs€SÐhs‚àÐSyàà3˜ãŽ¢ŠS”rœ+¨:¸Ðð  àÀÀ€tuÐSÔpˆˆt U€ U€»€»€»€s€€ €!@QÀ4q`lQ°TqPnS°7ÿ`ÝÀþtuÐSzpˆˆd×·³³óc '€ e€¦À4å`,¦ 7å`¾À ý€þtuÐSÃôpˆˆ4o_[[{3!€ 1€)À59`+) 5?`ïÀ ý€þ naÐSz(ÿà» » » À/€1€ TzÐSy¸jÀÎ`Õ`îàûàîàÕ`Î``À .zÐSzPÿà» » » À € €?€  ðhsÿÐSydüøp˜ý-ø¿ÿèýýøøpä~ÐSĸ€ð!xK¬UTk¬ÔVü~ÔVk¬U\k¼5øð€ SÐä~‚àÐSy8 PP(ˆ(¨E$“T«TDˆaw.rect(20,175,20+PLAYER.power*80/100,180,1,1,1) draw.text(10,218,PLAYER.score,1,8) if PLAYER.f and PLAYER.f>=2 then draw.text(49,72,"Game Over",1,12,1) PLAYER.f=PLAYER.f+1 end end, postrun=function() D=math.floor(100*PLAYER.N_destroyed/PLAYER.N_enemies) if PLAYER.N_enemies==0 then D=0 end D2=math.floor(100*PLAYER.N_hits/PLAYER.N_shots) if PLAYER.N_shots==0 then D2=0 end clearactors() if Q then return 1 end postdraw() draw.text(20,20,"Level completed",1,13,1) draw.text(20,50,"Score: "..PLAYER.score,1,10) draw.text(20,70,"Destruction: "..D.."%",1,10) draw.text(20,90,"Accuracy: "..D2.."%",1,10) draw.update() waitkey() end } LuaSource10>jÁÙif not args then return end setfenv(1,args.E) engine_mmenu={ init=function() M={ "New Game", "Load Game", "Highscores", "Options", "Quit", } S=1 end, think=function() if not kd and testkey(K_UP) and S>1 then S=S-1 kd=1 end if not kd and testkey(K_DOWN) and S<#M then S=S+1 kd=1 end if not testkey(K_DOWN) and not testkey(K_UP) then kd=nil end if testkey(K_EXE) then if S==1 then NEXTENG="game" draw.clear() draw.text((160-9*6)/2,80,"Loading...") draw.update() return 1 elseif S==5 then NEXTENG="" return 1 end end end, postdraw=function() for i=1,#M do c=0 if S==i then c=1 end draw.text((160-#M[i]*(6+c))/2,148+12*i,M[i],1,10,c) end end, postrun=function() end, } LuaSource10>jÁÙif not args then return end setfenv(1,args.E) require("draw","table") fps=0 maxfps=30 wait=0 fpscount=1 frames=0 A={} AD={} G={} -- Performs a deep copy function copy(t) if type(t)~="table" then return t end local r={} for k,v in pairs(t) do r[k]=copy(v) end return r end -- Load and display animations function pict.loadanim(fd,fl,w,h,f,l) local t,p={},pict.load(fd,fl) for i=1,f do t[i]=pict.part(p,w*i-w,0,w*i-1,h-1) end t.f,t.w,t.h,t.n,t.loop=1,w,h,f,l return t end function draw.anim(x,y,a,r) if type(a)=="userdata" then draw.pict(x,y,a,r) return end draw.pict(x,y,a[a.f],r) if a.f==a.n then if a.loop then a.f=1 else a.e=true end else a.f=a.f+1 a.e=nil end end -- Spawn an actor at the end of -- the current frame function spawn(n,args,...) local t={class=n,args=args,groups=copy(arg)} AD[t]=t end -- Spawn an actor immediatelu -- Do not use this, use spawn() -- instead function makeactor(n,...) local t=copy(ACTORS[n]) local base,q q=t repeat if not q.base then base="baseact" else base=q.base end q=ACTORS[base] for k,v in pairs(q) do if not t[k] then t[k]=copy(v) end end until base=="baseact" if t.base then t.baseact=ACTORS[t.base] else t.baseact=ACTORS.baseact end t.type=n A[t]=t if arg.n==0 and t.defgroups then arg=t.defgroups end for _,g in ipairs(arg) do if not G[g] then G[g]={} end G[g][t]=t table.insert(t.group,g) end return t end function clearactors() A={} AD={} G={} collectgarbage() end ACTORS={ baseact={ group={}, bb={0,0,0,0}, x=0, y=0, ingroup=function(a,g) for _,h in ipairs(a.group) do if h==g then return true end end return false end, ungroup=function(a,g) for i,h in ipairs(a.group) do if h==g then table.remove(a.group,i) break end end G[g][a]=nil end, collide=function(a,b) if not b or type(b)=="string" then local P=A if b then P=G[b] or {} end for _,k in pairs(P) do if a~=k and a.owner~=k then if a:collide(k) then return k end end end return nil end return a.x+a.bb[3]>=b.x+b.bb[1] and b.x+b.bb[3]>=a.x+a.bb[1] and a.y+a.bb[4]>=b.y+b.bb[2] and b.y+b.bb[4]>=a.y+a.bb[2] end, draw=function(a) draw.rect(a.x+a.bb[1],a.y+a.bb[2],a.x+a.bb[3],a.y+a.bb[4]) end, kill=function(a) for _,g in ipairs(a.group) do G[g][a]=nil end A[a]=nil collectgarbage() end, think=function(a) end, init=function(a) end, } } -- Engine events -- Override those in main -- program function init() end function think() end function postdraw() end function postrun() end function loadengine(s) if not getfenv()["engine_"..s] then pcall(include,"e_"..s) end if getfenv()["engine_"..s] then local e=getfenv()["engine_"..s] init=e.init or function() end think=e.think or function() end postdraw=e.postdraw or function() end postrun=e.postrun or function() end end end function run() init() collectgarbage() while 1 do _,_,s=gettime() if s0 and s0~=s then fps=frames wait=wait+(frames-maxfps)*60 if wait<0 then wait=0 end frames=0 end s0=s frames=frames+1 draw.clear() if think() then break end for _,v in pairs(A) do v:draw() end for _,v in pairs(A) do v:think() end postdraw() if disp_mem then local c=math.floor(collectgarbage("count")/2) local c2=math.floor(c/10) draw.rect(144,214,155,225) draw.rect(145,225-c2,154,225,1,1,1) draw.line(144,225-c2-1,145+c-10*c2-1,225-c2-1) draw.text(120,218,2*c,1,8) draw.text(133,218,"KB",1,8) end if disp_fps then draw.text(90,218,fps.." fps",1,8) end draw.update() for m,v in pairs(AD) do local t if v.groups then t=makeactor(v.class,unpack(v.groups)) else t=makeactor(v.class) end for k,w in pairs(v.args) do t[k]=w end t:init() end AD={} if wait>0 then for i=1,wait do end end end postrun() end LuaSource10>jÁÙ7if not args then return end setfenv(1,args.E) L={ --{0}, --{0,"tanktrack",{spd=4,x=0,y=-45,nodes={{10,0},{40,-30},{70,0},{40,30}},tanks={{"cannon2",1}},loop=1}}, --{0,"ship3",{x=60,y=-10}, --{0,"ship5",{x=80,y=-10}}, --{0,"ship7",{x=-20,y=-10,dx=2}}, --{20,"ship7",{x=180,y=-10,dx=-2}}, --{0,"ship8",{x=80,y=-10}}, --{0,"lgem",{x=80,y=-10}}, {50,"ship1",{x=20,y=-10}}, {70,"ship1",{x=20,y=-10}}, {90,"ship1",{x=20,y=-10}}, {110,"ship1",{x=20,y=-10}}, {115,"cannon1",{x=60,y=-10}}, {115,"cannon1",{x=100,y=-10}}, {130,"ship1",{x=20,y=-10,spawn="coin"}}, {210,"ship1",{x=140,y=-10}}, {230,"ship1",{x=140,y=-10}}, {250,"ship1",{x=140,y=-10}}, {270,"ship1",{x=140,y=-10}}, {290,"ship1",{x=140,y=-10,spawn="coin"}}, {310,"cannon1",{x=120,y=-10}}, {320,"ship2",{x=20,y=-10,ddx=0.05}}, {340,"ship2",{x=20,y=-10,ddx=0.05}}, {360,"ship2",{x=20,y=-10,ddx=0.05}}, {370,"cannon1",{x=40,y=-10}}, {380,"ship2",{x=140,y=-10,ddx=-0.05}}, {400,"ship2",{x=140,y=-10,ddx=-0.05}}, {420,"ship2",{x=140,y=-10,ddx=-0.05}}, {490,"ship3",{x=60,y=-10,spawn="gem"}}, {540,"ship3",{x=100,y=-10,spawn="gem"}}, {580,"rocket1",{x=20,y=-10}}, {600,"rocket1",{x=140,y=-10}}, {610,"ship4",{x=20,y=-10,spawn="dgem"}}, {690,"ship4",{x=140,y=-10,dx=-1,spawn="dgem"}}, {840,"cannon1",{x=30,y=-10}}, {840,"cannon1",{x=130,y=-10}}, {880,"cannon1",{x=30,y=-10}}, {880,"cannon1",{x=130,y=-10}}, {960,"ship7",{x=-20,y=-10,dx=2}}, {990,"ship7",{x=180,y=-10,dx=-2}}, {1090,"ship8",{x=50,y=-10}}, {1150,"ship8",{x=110,y=-10}}, {1210}, } LuaSource10>jÁÙ LuaSource10>jÁÙif not args then return end setfenv(1,args.E) --[[ Pictures and animations ]] PATH2="SpaceRES" function loadpict(f) return pict.load(PATH2,f) end function loadanim(f,a,b,c,d) return pict.loadanim(PATH2,f,a,b,c,d) end res={ player=loadpict("ship"), playerl=loadpict("shipl"), playerr=loadpict("shipr"), ship1=loadpict("sship"), ship2=loadpict("sship2"), ship3=loadpict("mship"), ship4=loadpict("lship"), ship5=loadpict("lship2"), ship6=loadpict("sship4"), ship7=loadpict("sship5"), ship8=loadpict("lship3"), rocket1=loadpict("sship3"), cannon1=loadpict("cannon"), cannon2=loadpict("cannon2"), bullet1=loadpict("bullet1"), mine1=loadanim("mine1",5,5,2,true), fball1=loadanim("fball1",9,9,4,true), explo=loadanim("expls",31,31,6), explo2=loadanim("explm",51,35,7), laserexplo=loadanim("explss",9,9,7), fireexplo=loadanim("explsf",15,15,7), thrust=loadanim("thrust",7,14,2,true), coin=loadanim("coin",11,11,4,true), gem=loadpict("gem"), lgem=loadpict("lgem"), } function getres(s) return res[s] end f nbullet1ôMcannon(Mcannon28(Mcoin`TMexplm´8MexplsìøMexplsfä äMexplssÈ XMfball1 @Mgem` (Mlgemˆ <MlshipÄ LMlship2dMlship3tdMmine1ØMmshipô0Mship$PMshipltPMshiprÄPMsship(Msship2<(Msship3d(Msship4Œ4Msship5À0Mthrustð(M SÐD@ÇÔÐS¾ ø¸¸¸¸¸¸¸pp  ÐSv€.€Ó`§ ¯ ¿ ß`.€ ÐSyD?€`Àß`§ ¯ ¿ ß`1€, SДy‚àÐSÃàÀ (€ ‚ (€ ‚ (€ADP(@ADP(@ADP(@"‚`( €&‚ ( € (€Àe#SÐä~‚àÐS‹ðÀ<  Àà &@ |dÀm€ðx`ò0À€™@À¾°B `" @!#H0À0 ðà&À(GˆrX@€ x@ AÈL0@ЈP `pàâ‚(à~ €€€ð°H €C@€=@È ¿@€@¡0 € €&ƒF !€pÀ) (`Gð` 1DA  À$I$$ÀH(20€€†JK 88I#†€B ( R`A€‚  „ x‰  @`@0’@˜3€¨@PD €À&$0˜ pD@€HÏ à@P, à"ð°@à`ü `ºSÐä~zÌÐS0Œ8ŒàÄ•94€ 4| € bœÀ@p0 " €€¢ 0€€BèPH€€`ü@ ¨f0 Ø$Èš (&¼NÐDX%0l2¤G‚¨@06R p*2\€@Æ4h@<I @@@€ÊÐ @T°‹À€€ UU Àh€8@€@g+À@@€ÀiSЂàÐSÂt€@€ €€€€ €€À€ €€@‰@@À@‰( TAA € :AA@ A@ –À3$BF<? e:pxxpÐS~Ààpçóæ2ÞüÜ|Þüæ2çóÀàp$ f:ŽÈbaÐSÇÔ€c5ŸÍ`A"“È €ÅwñPêÿú°ÕõPC*ŸÊ o5ŸÍ`€fba Sio¶LÐSyÜ?€U@Ê ¿`RÀ)€  SÐeg‚àÐS€Ü €@* SP¥¸úè´ØÙh’ȵXÚè­¸×Xj°7`À€SÐhs‚àÐSÀŸó·ú€ÿÿà:ªª¸WÕWÔªk¬®×Õ×Þª­ëþÿÿÿþp€P !`€ÐSÄœ?ƒøeò½LR®ê”)Zõ(ªªP Zô *©@šò€J¥ªê{¼ `À€€ÀÀÀÀÀÀSÐz8ÐSÄ,îø_Tª¨nЪ D@@@N@ÛÀ×W]`n×nÀ__Îx@@?€*€*€*€*€?€ SÐhs€ÐSyÀs€@ÀÀs€SÐhs‚àÐSyàà3˜ãŽ¢ŠS”rœ+¨:¸Ðð  àÀÀ€tuÐSÔpˆˆt U€ U€»€»€»€s€€ €!@QÀ4q`lQ°TqPnS°7ÿ`ÝÀþtuÐSzpˆˆd×·³³óc '€ e€¦À4å`,¦ 7å`¾À ý€þtuÐSÃôpˆˆ4o_[[{3!€ 1€)À59`+) 5?`ïÀ ý€þ naÐSz(ÿà» » » À/€1€ TzÐSy¸jÀÎ`Õ`îàûàîàÕ`Î``À .zÐSzPÿà» » » À € €?€  ðhsÿÐSydüøp˜ý-ø¿ÿèýýøøpä~ÐSĸ€ð!xK¬UTk¬ÔVü~ÔVk¬U\k¼5øð€ SÐä~‚àÐSy8 PP(ˆ(¨E$“T«TDˆ €€À€ €€@‰@@À@‰( TAA € :AA@ A@ –À3$BF<? e:pxxpÐS~Ààpçóæ2ÞüÜ|Þüæ2çóÀàp$ f:ŽÈbaÐSÇÔ€c5ŸÍ`A"“È €ÅwñPêÿú°ÕõPC*ŸÊ o5ŸÍ`€fba Sio¶LÐSyÜ?€U@Ê ¿`RÀ)€  SÐeg‚àÐS€Ü €@* SP¥¸úè´ØÙh’ȵXÚè­¸×Xj°7`À€SÐhs‚àÐSÀŸó·ú€ÿÿà:ªª¸WÕWÔªk¬®×Õ×Þª­ëþÿÿÿþp€P !`€ÐSÄœ?ƒøeò½LR®ê”)Zõ(ªªP Zô *©@šò€J¥ªê{¼ `À€€ÀÀÀÀÀÀSÐz8ÐSÄ,îø_Tª¨nЪ D@@@N@ÛÀ×W]`n×nÀ__Îx@@?€*€*€*€*€?€ SÐhs€ÐSyÀs€@ÀÀs€SÐhs‚àÐSyàà3˜ãŽ¢ŠS”rœ+¨:¸Ðð  àÀÀ€tuÐSÔpˆˆt U€ U€»€»€»€s€€ €!@QÀ4q`lQ°TqPnS°7ÿ`ÝÀþtuÐSzpˆˆd×·³³óc '€ e€¦À4å`,¦ 7å`¾À ý€þtuÐSÃôpˆˆ4o_[[{3!€ 1€)À59`+) 5?`ïÀ ý€þ naÐSz(ÿà» » » À/€1€ TzÐSy¸jÀÎ`Õ`îàûàîàÕ`Î``À .zÐSzPÿà» » » À € €?€  ðhsÿÐSydüøp˜ý-ø¿ÿèýýøøpä~ÐSĸ€ð!xK¬UTk¬ÔVü~ÔVk¬U\k¼5øð€ SÐä~‚àÐSy8 PP(ˆ(¨E$“T«TDˆ {50,"ship1",{x=20,y=-10}}, {70,"ship1",{x=20,y=-10}}, {90,"ship1",{x=20,y=-10}}, {110,"ship1",{x=20,y=-10}}, {115,"cannon1",{x=60,y=-10}}, {115,"cannon1",{x=100,y=-10}}, {130,"ship1",{x=20,y=-10,spawn="coin"}}, {210,"ship1",{x=140,y=-10}}, {230,"ship1",{x=140,y=-10}}, {250,"ship1",{x=140,y=-10}}, {270,"ship1",{x=140,y=-10}}, {290,"ship1",{x=140,y=-10,spawn="coin"}}, {310,"cannon1",{x=120,y=-10}}, {320,"ship2",{x=20,y=-10,ddx=0.05}}, {340,"ship2",{x=20,y=-10,ddx=0.05}}, {360,"ship2",{x=20,y=-10,ddx=0.05}}, {370,"cannon1",{x=40,y=-10}}, {380,"ship2",{x=140,y=-10,ddx=-0.05}}, {400,"ship2",{x=140,y=-10,ddx=-0.05}}, {420,"ship2",{x=140,y=-10,ddx=-0.05}}, {490,"ship3",{x=60,y=-10,spawn="gem"}}, {540,"ship3",{x=100,y=-10,spawn="gem"}}, {580,"rocket1",{x=20,y=-10}}, {600,"rocket1",{x=140,y=-10}}, {610,"ship4",{x=20,y=-10,spawn="dgem"}}, {690,"ship4",{x=140,y=-10,dx=-1,spawn="dgem"}}, {840,"cannon1",{x=30,y=-10}}, {840,"cannon1",{x=130,y=-10}}, {880,"cannon1",{x=30,y=-10}}, {880,"cannon1",{x=130,y=-10}}, {960,"ship7",{x=-20,y=-10,dx=2}}, {990,"ship7",{x=180,y=-10,dx=-2}}, {1090,"ship8",{x=50,y=-10}}, {1150,"ship8",{x=110,y=-10}}, {1210}, } LuaSource10>jÁÙ LuaSource10>jÁÙif not args then return end setfenv(1,args.E) --[[ Pictures and animations ]] PATH2="SpaceRES" function loadpict(f) return pict.load(PATH2,f) end function loadanim(f,a,b,c,d) return pict.loadanim(PATH2,f,a,b,c,d) end res={ player=loadpict("ship"), playerl=loadpict("shipl"), playerr=loadpict("shipr"), ship1=loadpict("sship"), ship2=loadpict("sship2"), ship3=loadpict("mship"), ship4=loadpict("lship"), ship5=loadpict("lship2"), ship6=loadpict("sship4"), ship7=loadpict("sship5"), ship8=loadpict("lship3"), rocket1=loadpict("sship3"), cannon1=loadpict("cannon"), cannon2=loadpict("cannon2"), bullet1=loadpict("bullet1"), mine1=loadanim("mine1",5,5,2,true), fball1=loadanim("fball1",9,9,4,true), explo=loadanim("expls",31,31,6), explo2=loadanim("explm",51,35,7), laserexplo=loadanim("explss",9,9,7), fireexplo=loadanim("explsf",15,15,7), thrust=loadanim("thrust",7,14,2,true), coin=loadanim("coin",11,11,4,true), gem=loadpict("gem"), lgem=loadpict("lgem"), } function getres(s) return res[s] end f nbullet1ôMcannon(Mcannon28(Mcoin`TMexplm´8MexplsìøMexplsfä äMexplssÈ XMfball1 @Mgem` (Mlgemˆ <MlshipÄ LMlship2dMlship3tdMmine1ØMmshipô0Mship$PMshipltPMshiprÄPMsship(Msship2<(Msship3d(Msship4Œ4Msship5À0Mthrustð(M SÐD@ÇÔÐS¾ ø¸¸¸¸¸¸¸pp  ÐSv€.€Ó`§ ¯ ¿ ß`.€ ÐSyD?€`Àß`§ ¯ ¿ ß`1€, SДy‚àÐSÃàÀ (€ ‚ (€ ‚ (€ADP(@ADP(@ADP(@"‚`( €&‚ ( € (€Àe#SÐä~‚àÐS‹ðÀ<  Àà &@ |dÀm€ðx`ò0À€™@À¾°B `" @!#H0À0 ðà&À(GˆrX@€ x@ AÈL0@ЈP `pàâ‚(à~ €€€ð°H €C@€=@È ¿@€@¡0 € €&ƒF !€pÀ) (`Gð` 1DA  À$I$$ÀH(20€€†JK 88I#†€B ( R`A€‚  „ x‰  @`@0’@˜3€¨@PD €À&$0˜ pD@€HÏ à@P, à"ð°@à`ü `ºSÐä~zÌÐS0Œ8ŒàÄ•94€ 4| € bœÀ@p0 " €€¢ 0€€BèPH€€`ü@ ¨f0 Ø$Èš (&¼NÐDX%0l2¤G‚¨@06R p*2\€@Æ4h@<I @@@€ÊÐ @T°‹À€€ UU Àh€8@€@g+À@@€ÀiSЂàÐSÂt€@€ €€€€ €€À€ €€@‰@@À@‰( TAA € :AA@ A@ –À3$BF<? e:pxxpÐS~Ààpçóæ2ÞüÜ|Þüæ2çóÀàp$ f:ŽÈbaÐSÇÔ€c5ŸÍ`A"“È €ÅwñPêÿú°ÕõPC*ŸÊ o5ŸÍ`€fba Sio¶LÐSyÜ?€U@Ê ¿`RÀ)€  SÐeg‚àÐS€Ü €@* SP¥¸úè´ØÙh’ȵXÚè­¸×Xj°7`À€SÐhs‚àÐSÀŸó·ú€ÿÿà:ªª¸WÕWÔªk¬®×Õ×Þª­ëþÿÿÿþp€P !`€ÐSÄœ?ƒøeò½LR®ê”)Zõ(ªªP Zô *©@šò€J¥ªê{¼ `À€€ÀÀÀÀÀÀSÐz8ÐSÄ,îø_Tª¨nЪ D@@@N@ÛÀ×W]`n×nÀ__Îx@@?€*€*€*€*€?€ SÐhs€ÐSyÀs€@ÀÀs€SÐhs‚àÐSyàà3˜ãŽ¢ŠS”rœ+¨:¸Ðð  àÀÀ€tuÐSÔpˆˆt U€ U€»€»€»€s€€ €!@QÀ4q`lQ°TqPnS°7ÿ`ÝÀþtuÐSzpˆˆd×·³³óc '€ e€¦À4å`,¦ 7å`¾À ý€þtuÐSÃôpˆˆ4o_[[{3!€ 1€)À59`+) 5?`ïÀ ý€þ naÐSz(ÿà» » » À/€1€ TzÐSy¸jÀÎ`Õ`îàûàîàÕ`Î``À .zÐSzPÿà» » » À € €?€  ðhsÿÐSydüøp˜ý-ø¿ÿèýýøøpä~ÐSĸ€ð!xK¬UTk¬ÔVü~ÔVk¬U\k¼5øð€ SÐä~‚àÐSy8 PP(ˆ(¨E$“T«TDˆwirei¸M- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€n(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€x][y+1]==0 then y=y+1 break else k=4 end end if k==4 then if t[x][y-1]==0 then y=y-1 break else k=1 end end end end for x=-n,n do for y=-n,n do if t[x][y]==1 then draw.rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ LuaSource10>jÁÙ»require("draw") function line(x1,y1,x2,y2) local dx,dy,e local xi,yi=1,1 local xi2,yi2=1,1 dx=(x2-x1)*2 dy=(y2-y1)*2 if dx<0 then dx,xi=-dx,-1 end if dy<0 then dy,yi=-dy,-1 end if dy>dx then if y1>y2 then yi2=-1 end e=yi2*(y2-y1) while yi2*y1<=yi2*y2 do draw.pixel(x1,y1) y1=y1+yi2 e=e-dx if e<=0 then x1=x1+xi e=e+dy end end else if x1>x2 then xi2=-1 end e=xi2*(x2-x1) while xi2*x1<=xi2*x2 do draw.pixel(x1,y1) x1=x1+xi2 e=e-dy if e<=0 then y1=y1+yi e=e+dx end end end end function draw.traceline(x1,y1,x2,y2) local dx,dy,e local xi,yi=1,1 local xi2,yi2=1,1 dx=(x2-x1)*2 dy=(y2-y1)*2 if dx<0 then dx,xi=-dx,-1 end if dy<0 then dy,yi=-dy,-1 end if dy>dx then if y1>y2 then yi2=-1 end e=yi2*(y2-y1) while yi2*y1<=yi2*y2 do if draw.pxltest(x1,y1) then return x1,y1 end y1=y1+yi2 e=e-dx if e<=0 then x1=x1+xi e=e+dy end end else if x1>x2 then xi2=-1 end e=xi2*(x2-x1) while xi2*x1<=xi2*x2 do if draw.pxltest(x1,y1) then return x1,y1 end x1=x1+xi2 e=e-dy if e<=0 then y1=y1+yi e=e+dx end end end end showgraph() draw.rect(80,0,160,240,1,1,1) draw.pixel(9,100) while 1 do x,y=getpen() if x then a,b=draw.traceline(10,100,x,y) if a then draw.circle(a,b,2,1,0,0) end end end waitkey()2 LuaSource10>jÁÙ,require("draw") showgraph() n=6 while 1 do draw.clear() t={} for i=-n,n do t[i]={} for j=-n,n do t[i][j]=0 end end x,y=0,0 for i=1,n do t[x][y]=1 if i==n then break end k=math.random(1,4) if t[x+1][y]==1 and t[x-1][y]==1 and t[x][y+1]==1 and t[x][y-1]==1 then break end for i=1,2 do if k==1 then if t[x+1][y]==0 then x=x+1 break else k=2 end end if k==2 then if t[x-1][y]==0 then x=x-1 break else k=3 end end if k==3 then if t[x][y+1]==0 then y=y+1 break else k=4 end end if k==4 then if t[x][y-1]==0 then y=y-1 break else k=1 end end end end for x=-n,n do for y=-n,n do if t[x][y]==1 then draw.rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€T*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ end end end for x=-n,n do for y=-n,n do if t[x][y]==1 then draw.rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€{} for j=-n,n do t[i][j]=0 end end x,y=0,0 for i=1,n do t[x][y]=1 if i==n then break end k=math.random(1,4) if t[x+1][y]==1 and t[x-1][y]==1 and t[x][y+1]==1 and t[x][y-1]==1 then break end for i=1,2 do if k==1 then if t[x+1][y]==0 then x=x+1 break else k=2 end end if k==2 then if t[x-1][y]==0 then x=x-1 break else k=3 end end if k==3 then if t[x][y+1]==0 then y=y+1 break else k=4 end end if k==4 then if t[x][y-1]==0 then y=y-1 break else k=1 end end end end for x=-n,n do for y=-n,n do if t[x][y]==1 then draw.rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€hen y=y-1 break else k=1 end end end end for x=-n,n do for y=-n,n do if t[x][y]==1 then draw.rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€üÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€rm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€rn p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ LuaSource10>jÁÙ»require("draw") function line(x1,y1,x2,y2) local dx,dy,e local xi,yi=1,1 local xi2,yi2=1,1 dx=(x2-x1)*2 dy=(y2-y1)*2 if dx<0 then dx,xi=-dx,-1 end if dy<0 then dy,yi=-dy,-1 end if dy>dx then if y1>y2 then yi2=-1 end e=yi2*(y2-y1) while yi2*y1<=yi2*y2 do draw.pixel(x1,y1) y1=y1+yi2 e=e-dx if e<=0 then x1=x1+xi e=e+dy end end else if x1>x2 then xi2=-1 end e=xi2*(x2-x1) while xi2*x1<=xi2*x2 do draw.pixel(x1,y1) x1=x1+xi2 e=e-dy if e<=0 then y1=y1+yi e=e+dx end end end end function draw.traceline(x1,y1,x2,y2) local dx,dy,e local xi,yi=1,1 local xi2,yi2=1,1 dx=(x2-x1)*2 dy=(y2-y1)*2 if dx<0 then dx,xi=-dx,-1 end if dy<0 then dy,yi=-dy,-1 end if dy>dx then if y1>y2 then yi2=-1 end e=yi2*(y2-y1) while yi2*y1<=yi2*y2 do if draw.pxltest(x1,y1) then return x1,y1 end y1=y1+yi2 e=e-dx if e<=0 then x1=x1+xi e=e+dy end end else if x1>x2 then xi2=-1 end e=xi2*(x2-x1) while xi2*x1<=xi2*x2 do if draw.pxltest(x1,y1) then return x1,y1 end x1=x1+xi2 e=e-dy if e<=0 then y1=y1+yi e=e+dx end end end end showgraph() draw.rect(80,0,160,240,1,1,1) draw.pixel(9,100) while 1 do x,y=getpen() if x then a,b=draw.traceline(10,100,x,y) if a then draw.circle(a,b,2,1,0,0) end end end waitkey()2 LuaSource10>jÁÙ,require("draw") showgraph() n=6 while 1 do draw.clear() t={} for i=-n,n do t[i]={} for j=-n,n do t[i][j]=0 end end x,y=0,0 for i=1,n do t[x][y]=1 if i==n then break end k=math.random(1,4) if t[x+1][y]==1 and t[x-1][y]==1 and t[x][y+1]==1 and t[x][y-1]==1 then break end for i=1,2 do if k==1 then if t[x+1][y]==0 then x=x+1 break else k=2 end end if k==2 then if t[x-1][y]==0 then x=x-1 break else k=3 end end if k==3 then if t[x][y+1]==0 then y=y+1 break else k=4 end end if k==4 then if t[x][y-1]==0 then y=y-1 break else k=1 end end end end for x=-n,n do for y=-n,n do if t[x][y]==1 then draw.rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ort{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ LuaSource10>jÁÙ»require("draw") function line(x1,y1,x2,y2) local dx,dy,e local xi,yi=1,1 local xi2,yi2=1,1 dx=(x2-x1)*2 dy=(y2-y1)*2 if dx<0 then dx,xi=-dx,-1 end if dy<0 then dy,yi=-dy,-1 end if dy>dx then if y1>y2 then yi2=-1 end e=yi2*(y2-y1) while yi2*y1<=yi2*y2 do draw.pixel(x1,y1) y1=y1+yi2 e=e-dx if e<=0 then x1=x1+xi e=e+dy end end else if x1>x2 then xi2=-1 end e=xi2*(x2-x1) while xi2*x1<=xi2*x2 do draw.pixel(x1,y1) x1=x1+xi2 e=e-dy if e<=0 then y1=y1+yi e=e+dx end end end end function draw.traceline(x1,y1,x2,y2) local dx,dy,e local xi,yi=1,1 local xi2,yi2=1,1 dx=(x2-x1)*2 dy=(y2-y1)*2 if dx<0 then dx,xi=-dx,-1 end if dy<0 then dy,yi=-dy,-1 end if dy>dx then if y1>y2 then yi2=-1 end e=yi2*(y2-y1) while yi2*y1<=yi2*y2 do if draw.pxltest(x1,y1) then return x1,y1 end y1=y1+yi2 e=e-dx if e<=0 then x1=x1+xi e=e+dy end end else if x1>x2 then xi2=-1 end e=xi2*(x2-x1) while xi2*x1<=xi2*x2 do if draw.pxltest(x1,y1) then return x1,y1 end x1=x1+xi2 e=e-dy if e<=0 then y1=y1+yi e=e+dx end end end end showgraph() draw.rect(80,0,160,240,1,1,1) draw.pixel(9,100) while 1 do x,y=getpen() if x then a,b=draw.traceline(10,100,x,y) if a then draw.circle(a,b,2,1,0,0) end end end waitkey()2 LuaSource10>jÁÙ,require("draw") showgraph() n=6 while 1 do draw.clear() t={} for i=-n,n do t[i]={} for j=-n,n do t[i][j]=0 end end x,y=0,0 for i=1,n do t[x][y]=1 if i==n then break end k=math.random(1,4) if t[x+1][y]==1 and t[x-1][y]==1 and t[x][y+1]==1 and t[x][y-1]==1 then break end for i=1,2 do if k==1 then if t[x+1][y]==0 then x=x+1 break else k=2 end end if k==2 then if t[x-1][y]==0 then x=x-1 break else k=3 end end if k==3 then if t[x][y+1]==0 then y=y+1 break else k=4 end end if k==4 then if t[x][y-1]==0 then y=y-1 break else k=1 end end end end for x=-n,n do for y=-n,n do if t[x][y]==1 then draw.rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€n do if t[x][y]==1 then draw.rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ else k=4 end end if k==4 then if t[x][y-1]==0 then y=y-1 break else k=1 end end end end for x=-n,n do for y=-n,n do if t[x][y]==1 then draw.rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€xel(x1,y1) y1=y1+yi2 e=e-dx if e<=0 then x1=x1+xi e=e+dy end end else if x1>x2 then xi2=-1 end e=xi2*(x2-x1) while xi2*x1<=xi2*x2 do draw.pixel(x1,y1) x1=x1+xi2 e=e-dy if e<=0 then y1=y1+yi e=e+dx end end end end function draw.traceline(x1,y1,x2,y2) local dx,dy,e local xi,yi=1,1 local xi2,yi2=1,1 dx=(x2-x1)*2 dy=(y2-y1)*2 if dx<0 then dx,xi=-dx,-1 end if dy<0 then dy,yi=-dy,-1 end if dy>dx then if y1>y2 then yi2=-1 end e=yi2*(y2-y1) while yi2*y1<=yi2*y2 do if draw.pxltest(x1,y1) then return x1,y1 end y1=y1+yi2 e=e-dx if e<=0 then x1=x1+xi e=e+dy end end else if x1>x2 then xi2=-1 end e=xi2*(x2-x1) while xi2*x1<=xi2*x2 do if draw.pxltest(x1,y1) then return x1,y1 end x1=x1+xi2 e=e-dy if e<=0 then y1=y1+yi e=e+dx end end end end showgraph() draw.rect(80,0,160,240,1,1,1) draw.pixel(9,100) while 1 do x,y=getpen() if x then a,b=draw.traceline(10,100,x,y) if a then draw.circle(a,b,2,1,0,0) end end end waitkey()2 LuaSource10>jÁÙ,require("draw") showgraph() n=6 while 1 do draw.clear() t={} for i=-n,n do t[i]={} for j=-n,n do t[i][j]=0 end end x,y=0,0 for i=1,n do t[x][y]=1 if i==n then break end k=math.random(1,4) if t[x+1][y]==1 and t[x-1][y]==1 and t[x][y+1]==1 and t[x][y-1]==1 then break end for i=1,2 do if k==1 then if t[x+1][y]==0 then x=x+1 break else k=2 end end if k==2 then if t[x-1][y]==0 then x=x-1 break else k=3 end end if k==3 then if t[x][y+1]==0 then y=y+1 break else k=4 end end if k==4 then if t[x][y-1]==0 then y=y-1 break else k=1 end end end end for x=-n,n do for y=-n,n do if t[x][y]==1 then draw.rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€xel(x1,y1) y1=y1+yi2 e=e-dx if e<=0 then x1=x1+xi e=e+dy end end else if x1>x2 then xi2=-1 end e=xi2*(x2-x1) while xi2*x1<=xi2*x2 do draw.pixel(x1,y1) x1=x1+xi2 e=e-dy if e<=0 then y1=y1+yi e=e+dx end end end end function draw.traceline(x1,y1,x2,y2) local dx,dy,e local xi,yi=1,1 local xi2,yi2=1,1 dx=(x2-x1)*2 dy=(y2-y1)*2 if dx<0 then dx,xi=-dx,-1 end if dy<0 then dy,yi=-dy,-1 end if dy>dx then if y1>y2 then yi2=-1 end e=yi2*(y2-y1) while yi2*y1<=yi2*y2 do if draw.pxltest(x1,y1) then return x1,y1 end y1=y1+yi2 e=e-dx if e<=0 then x1=x1+xi e=e+dy end end else if x1>x2 then xi2=-1 end e=xi2*(x2-x1) while xi2*x1<=xi2*x2 do if draw.pxltest(x1,y1) then return x1,y1 end x1=x1+xi2 e=e-dy if e<=0 then y1=y1+yi e=e+dx end end end end showgraph() draw.rect(80,0,160,240,1,1,1) draw.pixel(9,100) while 1 do x,y=getpen() if x then a,b=draw.traceline(10,100,x,y) if a then draw.circle(a,b,2,1,0,0) end end end waitkey()2 LuaSource10>jÁÙ,require("draw") showgraph() n=6 while 1 do draw.clear() t={} for i=-n,n do t[i]={} for j=-n,n do t[i][j]=0 end end x,y=0,0 for i=1,n do t[x][y]=1 if i==n then break end k=math.random(1,4) if t[x+1][y]==1 and t[x-1][y]==1 and t[x][y+1]==1 and t[x][y-1]==1 then break end for i=1,2 do if k==1 then if t[x+1][y]==0 then x=x+1 break else k=2 end end if k==2 then if t[x-1][y]==0 then x=x-1 break else k=3 end end if k==3 then if t[x][y+1]==0 then y=y+1 break else k=4 end end if k==4 then if t[x][y-1]==0 then y=y-1 break else k=1 end end end end for x=-n,n do for y=-n,n do if t[x][y]==1 then draw.rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€€Ï€€p†P„pÌPp LuaSource10>jÁÙ»require("draw") function line(x1,y1,x2,y2) local dx,dy,e local xi,yi=1,1 local xi2,yi2=1,1 dx=(x2-x1)*2 dy=(y2-y1)*2 if dx<0 then dx,xi=-dx,-1 end if dy<0 then dy,yi=-dy,-1 end if dy>dx then if y1>y2 then yi2=-1 end e=yi2*(y2-y1) while yi2*y1<=yi2*y2 do draw.pixel(x1,y1) y1=y1+yi2 e=e-dx if e<=0 then x1=x1+xi e=e+dy end end else if x1>x2 then xi2=-1 end e=xi2*(x2-x1) while xi2*x1<=xi2*x2 do draw.pixel(x1,y1) x1=x1+xi2 e=e-dy if e<=0 then y1=y1+yi e=e+dx end end end end function draw.traceline(x1,y1,x2,y2) local dx,dy,e local xi,yi=1,1 local xi2,yi2=1,1 dx=(x2-x1)*2 dy=(y2-y1)*2 if dx<0 then dx,xi=-dx,-1 end if dy<0 then dy,yi=-dy,-1 end if dy>dx then if y1>y2 then yi2=-1 end e=yi2*(y2-y1) while yi2*y1<=yi2*y2 do if draw.pxltest(x1,y1) then return x1,y1 end y1=y1+yi2 e=e-dx if e<=0 then x1=x1+xi e=e+dy end end else if x1>x2 then xi2=-1 end e=xi2*(x2-x1) while xi2*x1<=xi2*x2 do if draw.pxltest(x1,y1) then return x1,y1 end x1=x1+xi2 e=e-dy if e<=0 then y1=y1+yi e=e+dx end end end end showgraph() draw.rect(80,0,160,240,1,1,1) draw.pixel(9,100) while 1 do x,y=getpen() if x then a,b=draw.traceline(10,100,x,y) if a then draw.circle(a,b,2,1,0,0) end end end waitkey()2 LuaSource10>jÁÙ,require("draw") showgraph() n=6 while 1 do draw.clear() t={} for i=-n,n do t[i]={} for j=-n,n do t[i][j]=0 end end x,y=0,0 for i=1,n do t[x][y]=1 if i==n then break end k=math.random(1,4) if t[x+1][y]==1 and t[x-1][y]==1 and t[x][y+1]==1 and t[x][y-1]==1 then break end for i=1,2 do if k==1 then if t[x+1][y]==0 then x=x+1 break else k=2 end end if k==2 then if t[x-1][y]==0 then x=x-1 break else k=3 end end if k==3 then if t[x][y+1]==0 then y=y+1 break else k=4 end end if k==4 then if t[x][y-1]==0 then y=y-1 break else k=1 end end end end for x=-n,n do for y=-n,n do if t[x][y]==1 then draw.rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€-x1) while xi2*x1<=xi2*x2 do if draw.pxltest(x1,y1) then return x1,y1 end x1=x1+xi2 e=e-dy if e<=0 then y1=y1+yi e=e+dx end end end end showgraph() draw.rect(80,0,160,240,1,1,1) draw.pixel(9,100) while 1 do x,y=getpen() if x then a,b=draw.traceline(10,100,x,y) if a then draw.circle(a,b,2,1,0,0) end end end waitkey()2 LuaSource10>jÁÙ,require("draw") showgraph() n=6 while 1 do draw.clear() t={} for i=-n,n do t[i]={} for j=-n,n do t[i][j]=0 end end x,y=0,0 for i=1,n do t[x][y]=1 if i==n then break end k=math.random(1,4) if t[x+1][y]==1 and t[x-1][y]==1 and t[x][y+1]==1 and t[x][y-1]==1 then break end for i=1,2 do if k==1 then if t[x+1][y]==0 then x=x+1 break else k=2 end end if k==2 then if t[x-1][y]==0 then x=x-1 break else k=3 end end if k==3 then if t[x][y+1]==0 then y=y+1 break else k=4 end end if k==4 then if t[x][y-1]==0 then y=y-1 break else k=1 end end end end for x=-n,n do for y=-n,n do if t[x][y]==1 then draw.rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ if e<=0 then x1=x1+xi e=e+dy end end else if x1>x2 then xi2=-1 end e=xi2*(x2-x1) while xi2*x1<=xi2*x2 do draw.pixel(x1,y1) x1=x1+xi2 e=e-dy if e<=0 then y1=y1+yi e=e+dx end end end end function draw.traceline(x1,y1,x2,y2) local dx,dy,e local xi,yi=1,1 local xi2,yi2=1,1 dx=(x2-x1)*2 dy=(y2-y1)*2 if dx<0 then dx,xi=-dx,-1 end if dy<0 then dy,yi=-dy,-1 end if dy>dx then if y1>y2 then yi2=-1 end e=yi2*(y2-y1) while yi2*y1<=yi2*y2 do if draw.pxltest(x1,y1) then return x1,y1 end y1=y1+yi2 e=e-dx if e<=0 then x1=x1+xi e=e+dy end end else if x1>x2 then xi2=-1 end e=xi2*(x2-x1) while xi2*x1<=xi2*x2 do if draw.pxltest(x1,y1) then return x1,y1 end x1=x1+xi2 e=e-dy if e<=0 then y1=y1+yi e=e+dx end end end end showgraph() draw.rect(80,0,160,240,1,1,1) draw.pixel(9,100) while 1 do x,y=getpen() if x then a,b=draw.traceline(10,100,x,y) if a then draw.circle(a,b,2,1,0,0) end end end waitkey()2 LuaSource10>jÁÙ,require("draw") showgraph() n=6 while 1 do draw.clear() t={} for i=-n,n do t[i]={} for j=-n,n do t[i][j]=0 end end x,y=0,0 for i=1,n do t[x][y]=1 if i==n then break end k=math.random(1,4) if t[x+1][y]==1 and t[x-1][y]==1 and t[x][y+1]==1 and t[x][y-1]==1 then break end for i=1,2 do if k==1 then if t[x+1][y]==0 then x=x+1 break else k=2 end end if k==2 then if t[x-1][y]==0 then x=x-1 break else k=3 end end if k==3 then if t[x][y+1]==0 then y=y+1 break else k=4 end end if k==4 then if t[x][y-1]==0 then y=y-1 break else k=1 end end end end for x=-n,n do for y=-n,n do if t[x][y]==1 then draw.rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ort{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ if t[x][y+1]==0 then y=y+1 break else k=4 end end if k==4 then if t[x][y-1]==0 then y=y-1 break else k=1 end end end end for x=-n,n do for y=-n,n do if t[x][y]==1 then draw.rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ort{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€üÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ yi2=-1 end e=yi2*(y2-y1) while yi2*y1<=yi2*y2 do draw.pixel(x1,y1) y1=y1+yi2 e=e-dx if e<=0 then x1=x1+xi e=e+dy end end else if x1>x2 then xi2=-1 end e=xi2*(x2-x1) while xi2*x1<=xi2*x2 do draw.pixel(x1,y1) x1=x1+xi2 e=e-dy if e<=0 then y1=y1+yi e=e+dx end end end end function draw.traceline(x1,y1,x2,y2) local dx,dy,e local xi,yi=1,1 local xi2,yi2=1,1 dx=(x2-x1)*2 dy=(y2-y1)*2 if dx<0 then dx,xi=-dx,-1 end if dy<0 then dy,yi=-dy,-1 end if dy>dx then if y1>y2 then yi2=-1 end e=yi2*(y2-y1) while yi2*y1<=yi2*y2 do if draw.pxltest(x1,y1) then return x1,y1 end y1=y1+yi2 e=e-dx if e<=0 then x1=x1+xi e=e+dy end end else if x1>x2 then xi2=-1 end e=xi2*(x2-x1) while xi2*x1<=xi2*x2 do if draw.pxltest(x1,y1) then return x1,y1 end x1=x1+xi2 e=e-dy if e<=0 then y1=y1+yi e=e+dx end end end end showgraph() draw.rect(80,0,160,240,1,1,1) draw.pixel(9,100) while 1 do x,y=getpen() if x then a,b=draw.traceline(10,100,x,y) if a then draw.circle(a,b,2,1,0,0) end end end waitkey()2 LuaSource10>jÁÙ,require("draw") showgraph() n=6 while 1 do draw.clear() t={} for i=-n,n do t[i]={} for j=-n,n do t[i][j]=0 end end x,y=0,0 for i=1,n do t[x][y]=1 if i==n then break end k=math.random(1,4) if t[x+1][y]==1 and t[x-1][y]==1 and t[x][y+1]==1 and t[x][y-1]==1 then break end for i=1,2 do if k==1 then if t[x+1][y]==0 then x=x+1 break else k=2 end end if k==2 then if t[x-1][y]==0 then x=x-1 break else k=3 end end if k==3 then if t[x][y+1]==0 then y=y+1 break else k=4 end end if k==4 then if t[x][y-1]==0 then y=y-1 break else k=1 end end end end for x=-n,n do for y=-n,n do if t[x][y]==1 then draw.rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€circle(a,b,2,1,0,0) end end end waitkey()2 LuaSource10>jÁÙ,require("draw") showgraph() n=6 while 1 do draw.clear() t={} for i=-n,n do t[i]={} for j=-n,n do t[i][j]=0 end end x,y=0,0 for i=1,n do t[x][y]=1 if i==n then break end k=math.random(1,4) if t[x+1][y]==1 and t[x-1][y]==1 and t[x][y+1]==1 and t[x][y-1]==1 then break end for i=1,2 do if k==1 then if t[x+1][y]==0 then x=x+1 break else k=2 end end if k==2 then if t[x-1][y]==0 then x=x-1 break else k=3 end end if k==3 then if t[x][y+1]==0 then y=y+1 break else k=4 end end if k==4 then if t[x][y-1]==0 then y=y-1 break else k=1 end end end end for x=-n,n do for y=-n,n do if t[x][y]==1 then draw.rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€T*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€k=1 end end end end for x=-n,n do for y=-n,n do if t[x][y]==1 then draw.rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€@„ ÀÌ€HH€€H ÀHHÀÌ ÀHÌHHÌÌH†Ì„NÈHÆL€Ï€€p†P„pÌPp LuaSource10>jÁÙ»require("draw") function line(x1,y1,x2,y2) local dx,dy,e local xi,yi=1,1 local xi2,yi2=1,1 dx=(x2-x1)*2 dy=(y2-y1)*2 if dx<0 then dx,xi=-dx,-1 end if dy<0 then dy,yi=-dy,-1 end if dy>dx then if y1>y2 then yi2=-1 end e=yi2*(y2-y1) while yi2*y1<=yi2*y2 do draw.pixel(x1,y1) y1=y1+yi2 e=e-dx if e<=0 then x1=x1+xi e=e+dy end end else if x1>x2 then xi2=-1 end e=xi2*(x2-x1) while xi2*x1<=xi2*x2 do draw.pixel(x1,y1) x1=x1+xi2 e=e-dy if e<=0 then y1=y1+yi e=e+dx end end end end function draw.traceline(x1,y1,x2,y2) local dx,dy,e local xi,yi=1,1 local xi2,yi2=1,1 dx=(x2-x1)*2 dy=(y2-y1)*2 if dx<0 then dx,xi=-dx,-1 end if dy<0 then dy,yi=-dy,-1 end if dy>dx then if y1>y2 then yi2=-1 end e=yi2*(y2-y1) while yi2*y1<=yi2*y2 do if draw.pxltest(x1,y1) then return x1,y1 end y1=y1+yi2 e=e-dx if e<=0 then x1=x1+xi e=e+dy end end else if x1>x2 then xi2=-1 end e=xi2*(x2-x1) while xi2*x1<=xi2*x2 do if draw.pxltest(x1,y1) then return x1,y1 end x1=x1+xi2 e=e-dy if e<=0 then y1=y1+yi e=e+dx end end end end showgraph() draw.rect(80,0,160,240,1,1,1) draw.pixel(9,100) while 1 do x,y=getpen() if x then a,b=draw.traceline(10,100,x,y) if a then draw.circle(a,b,2,1,0,0) end end end waitkey()2 LuaSource10>jÁÙ,require("draw") showgraph() n=6 while 1 do draw.clear() t={} for i=-n,n do t[i]={} for j=-n,n do t[i][j]=0 end end x,y=0,0 for i=1,n do t[x][y]=1 if i==n then break end k=math.random(1,4) if t[x+1][y]==1 and t[x-1][y]==1 and t[x][y+1]==1 and t[x][y-1]==1 then break end for i=1,2 do if k==1 then if t[x+1][y]==0 then x=x+1 break else k=2 end end if k==2 then if t[x-1][y]==0 then x=x-1 break else k=3 end end if k==3 then if t[x][y+1]==0 then y=y+1 break else k=4 end end if k==4 then if t[x][y-1]==0 then y=y-1 break else k=1 end end end end for x=-n,n do for y=-n,n do if t[x][y]==1 then draw.rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ function draw.traceline(x1,y1,x2,y2) local dx,dy,e local xi,yi=1,1 local xi2,yi2=1,1 dx=(x2-x1)*2 dy=(y2-y1)*2 if dx<0 then dx,xi=-dx,-1 end if dy<0 then dy,yi=-dy,-1 end if dy>dx then if y1>y2 then yi2=-1 end e=yi2*(y2-y1) while yi2*y1<=yi2*y2 do if draw.pxltest(x1,y1) then return x1,y1 end y1=y1+yi2 e=e-dx if e<=0 then x1=x1+xi e=e+dy end end else if x1>x2 then xi2=-1 end e=xi2*(x2-x1) while xi2*x1<=xi2*x2 do if draw.pxltest(x1,y1) then return x1,y1 end x1=x1+xi2 e=e-dy if e<=0 then y1=y1+yi e=e+dx end end end end showgraph() draw.rect(80,0,160,240,1,1,1) draw.pixel(9,100) while 1 do x,y=getpen() if x then a,b=draw.traceline(10,100,x,y) if a then draw.circle(a,b,2,1,0,0) end end end waitkey()2 LuaSource10>jÁÙ,require("draw") showgraph() n=6 while 1 do draw.clear() t={} for i=-n,n do t[i]={} for j=-n,n do t[i][j]=0 end end x,y=0,0 for i=1,n do t[x][y]=1 if i==n then break end k=math.random(1,4) if t[x+1][y]==1 and t[x-1][y]==1 and t[x][y+1]==1 and t[x][y-1]==1 then break end for i=1,2 do if k==1 then if t[x+1][y]==0 then x=x+1 break else k=2 end end if k==2 then if t[x-1][y]==0 then x=x-1 break else k=3 end end if k==3 then if t[x][y+1]==0 then y=y+1 break else k=4 end end if k==4 then if t[x][y-1]==0 then y=y-1 break else k=1 end end end end for x=-n,n do for y=-n,n do if t[x][y]==1 then draw.rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ draw.pxltest(x1,y1) then return x1,y1 end y1=y1+yi2 e=e-dx if e<=0 then x1=x1+xi e=e+dy end end else if x1>x2 then xi2=-1 end e=xi2*(x2-x1) while xi2*x1<=xi2*x2 do if draw.pxltest(x1,y1) then return x1,y1 end x1=x1+xi2 e=e-dy if e<=0 then y1=y1+yi e=e+dx end end end end showgraph() draw.rect(80,0,160,240,1,1,1) draw.pixel(9,100) while 1 do x,y=getpen() if x then a,b=draw.traceline(10,100,x,y) if a then draw.circle(a,b,2,1,0,0) end end end waitkey()2 LuaSource10>jÁÙ,require("draw") showgraph() n=6 while 1 do draw.clear() t={} for i=-n,n do t[i]={} for j=-n,n do t[i][j]=0 end end x,y=0,0 for i=1,n do t[x][y]=1 if i==n then break end k=math.random(1,4) if t[x+1][y]==1 and t[x-1][y]==1 and t[x][y+1]==1 and t[x][y-1]==1 then break end for i=1,2 do if k==1 then if t[x+1][y]==0 then x=x+1 break else k=2 end end if k==2 then if t[x-1][y]==0 then x=x-1 break else k=3 end end if k==3 then if t[x][y+1]==0 then y=y+1 break else k=4 end end if k==4 then if t[x][y-1]==0 then y=y-1 break else k=1 end end end end for x=-n,n do for y=-n,n do if t[x][y]==1 then draw.rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€T*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ LuaSource10>jÁÙ»require("draw") function line(x1,y1,x2,y2) local dx,dy,e local xi,yi=1,1 local xi2,yi2=1,1 dx=(x2-x1)*2 dy=(y2-y1)*2 if dx<0 then dx,xi=-dx,-1 end if dy<0 then dy,yi=-dy,-1 end if dy>dx then if y1>y2 then yi2=-1 end e=yi2*(y2-y1) while yi2*y1<=yi2*y2 do draw.pixel(x1,y1) y1=y1+yi2 e=e-dx if e<=0 then x1=x1+xi e=e+dy end end else if x1>x2 then xi2=-1 end e=xi2*(x2-x1) while xi2*x1<=xi2*x2 do draw.pixel(x1,y1) x1=x1+xi2 e=e-dy if e<=0 then y1=y1+yi e=e+dx end end end end function draw.traceline(x1,y1,x2,y2) local dx,dy,e local xi,yi=1,1 local xi2,yi2=1,1 dx=(x2-x1)*2 dy=(y2-y1)*2 if dx<0 then dx,xi=-dx,-1 end if dy<0 then dy,yi=-dy,-1 end if dy>dx then if y1>y2 then yi2=-1 end e=yi2*(y2-y1) while yi2*y1<=yi2*y2 do if draw.pxltest(x1,y1) then return x1,y1 end y1=y1+yi2 e=e-dx if e<=0 then x1=x1+xi e=e+dy end end else if x1>x2 then xi2=-1 end e=xi2*(x2-x1) while xi2*x1<=xi2*x2 do if draw.pxltest(x1,y1) then return x1,y1 end x1=x1+xi2 e=e-dy if e<=0 then y1=y1+yi e=e+dx end end end end showgraph() draw.rect(80,0,160,240,1,1,1) draw.pixel(9,100) while 1 do x,y=getpen() if x then a,b=draw.traceline(10,100,x,y) if a then draw.circle(a,b,2,1,0,0) end end end waitkey()2 LuaSource10>jÁÙ,require("draw") showgraph() n=6 while 1 do draw.clear() t={} for i=-n,n do t[i]={} for j=-n,n do t[i][j]=0 end end x,y=0,0 for i=1,n do t[x][y]=1 if i==n then break end k=math.random(1,4) if t[x+1][y]==1 and t[x-1][y]==1 and t[x][y+1]==1 and t[x][y-1]==1 then break end for i=1,2 do if k==1 then if t[x+1][y]==0 then x=x+1 break else k=2 end end if k==2 then if t[x-1][y]==0 then x=x-1 break else k=3 end end if k==3 then if t[x][y+1]==0 then y=y+1 break else k=4 end end if k==4 then if t[x][y-1]==0 then y=y-1 break else k=1 end end end end for x=-n,n do for y=-n,n do if t[x][y]==1 then draw.rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ while xi2*x1<=xi2*x2 do draw.pixel(x1,y1) x1=x1+xi2 e=e-dy if e<=0 then y1=y1+yi e=e+dx end end end end function draw.traceline(x1,y1,x2,y2) local dx,dy,e local xi,yi=1,1 local xi2,yi2=1,1 dx=(x2-x1)*2 dy=(y2-y1)*2 if dx<0 then dx,xi=-dx,-1 end if dy<0 then dy,yi=-dy,-1 end if dy>dx then if y1>y2 then yi2=-1 end e=yi2*(y2-y1) while yi2*y1<=yi2*y2 do if draw.pxltest(x1,y1) then return x1,y1 end y1=y1+yi2 e=e-dx if e<=0 then x1=x1+xi e=e+dy end end else if x1>x2 then xi2=-1 end e=xi2*(x2-x1) while xi2*x1<=xi2*x2 do if draw.pxltest(x1,y1) then return x1,y1 end x1=x1+xi2 e=e-dy if e<=0 then y1=y1+yi e=e+dx end end end end showgraph() draw.rect(80,0,160,240,1,1,1) draw.pixel(9,100) while 1 do x,y=getpen() if x then a,b=draw.traceline(10,100,x,y) if a then draw.circle(a,b,2,1,0,0) end end end waitkey()2 LuaSource10>jÁÙ,require("draw") showgraph() n=6 while 1 do draw.clear() t={} for i=-n,n do t[i]={} for j=-n,n do t[i][j]=0 end end x,y=0,0 for i=1,n do t[x][y]=1 if i==n then break end k=math.random(1,4) if t[x+1][y]==1 and t[x-1][y]==1 and t[x][y+1]==1 and t[x][y-1]==1 then break end for i=1,2 do if k==1 then if t[x+1][y]==0 then x=x+1 break else k=2 end end if k==2 then if t[x-1][y]==0 then x=x-1 break else k=3 end end if k==3 then if t[x][y+1]==0 then y=y+1 break else k=4 end end if k==4 then if t[x][y-1]==0 then y=y-1 break else k=1 end end end end for x=-n,n do for y=-n,n do if t[x][y]==1 then draw.rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€, {{-1,0,1,0,0}, {0,0,0,-1,1}}, {{-1,0,1,0,0}, {1,1,1,0,-1}}, {{-1,0,1,-1,1}, {0,0,0,-1,-1}}, {{-1,-1,0,0,1}, {-1,0,0,1,1}}, {{-2,-1,0,1,2}, {0,0,0,0,0}}, {{0}, {0},sp=1}, {{0}, {0},sp=2}, {{0,1}, {0,0},sp=3}, } function copy(t) local q={} for k,v in pairs(t) do if type(v)=="table" then q[k]=copy(v) else q[k]=v end end return q end p=pict.load("tetrisbk") B=pict.new(8*12,8*19+1) draw.onpict(B) for y=0,25 do draw.pict(0,6*y,p) draw.pict(88,6*y,p) end for x=1,10 do draw.pict(8*x,24*6,p) draw.pict(8*x,25*6,p) end function redraw() draw.pict(X0,Y0,B) draw.rect(0,Y0,X0-2,Y0+8*19,1,1,1) draw.rect(X0+8*12+1,Y0,159,Y0+8*19,1,1,0) draw.rect(0,1,159,Y0-2,1,1,0) end G={ init=function(o) for i=1,24 do o[i]={} for j=1,10 do o[i][j]=0 end end end, get=function(o,x,y) if x<1 or y<1 or x>10 or y>24 then return 99 end return o[y][x] end, set=function(o,x,y,n) if x<1 or y<1 or x>10 or y>24 then return end o[y][x]=n end, remove=function(o,l) for i=#l,1,-1 do table.remove(o,l[i]) table.insert(o,{0,0,0,0,0,0,0,0,0,0}) end end, } N=7+13+3 P={} p=pict.load("tetrisbl") for i=1,N do P[i]=pict.part(p,8*i-8,0,8*i-1,7) end LuaSource10>jÁÙ0if not args then return end setfenv(1,args.E) C={ d={}, n=1, bb={}, get=function(o,s) o.d=copy(T[s]) o:recalc() end, drop=function(o,x,y) draw.onpict(B) C:draw(x,y,1) draw.onbuffer() for i=1,#o.d[1] do G:set(x+o.d[1][i],y+o.d[2][i],o.n) end o.x=nil o.grabx=nil end, check=function(o,dx,dy,abs) local x,y if abs then x,y=0,0 else x,y=o.x,o.y end for i=1,#o.d[1] do if G:get(x+o.d[1][i]+dx,y+o.d[2][i]+dy)>0 then return false end end return true end, recalc=function(o) o.bb= {8*math.min(unpack(o.d[1]))-1,-8*math.max(unpack(o.d[2]))-1,8*math.max(unpack(o.d[1]))+8,-8*math.min(unpack(o.d[2]))+8} end, calcshadow=function(o) o.sh=o.y while C:check(o.x,o.sh,1) do o.sh=o.sh-1 end o.sh=o.sh+1 end, abspos=function(o) return X0+8*o.x,Y0+8*(18-o.y) end, draw=function(o,x,y,p) local x0,y0 if p then x0,y0=0,0 else x0,y0=X0,Y0 end for i=1,#o.d[1] do local a,b,c=x0+8*(x+o.d[1][i]),y0+8*(18-y-o.d[2][i]),y0+8*(18-C.sh-o.d[2][i]) if y+o.d[2][i]<=18 then draw.pict(a,b,P[o.n]) end if not p then draw.rect(a,c,a+7,c+7) end end end, rot=function(o,d) if o.d.nr then return end for i=1,#o.d[1] do o.d[1][i],o.d[2][i]=d*o.d[2][i],-d*o.d[1][i] end end, } 0/1/ÐSyHDDÿÿð50ÐS¥,ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÛÛÿÿ«««£ÿ‰íÿÿÿ™™™ýÕ½½¡Á©Å½­¥ÿ•ÛÃӃ參§™«¥½……›•‹­µç«·ßç›û‰™™—å™Õ¥½…¡Ù©•µ™çÕíßË“ß™™™«¿«½½½‰ƒ•«½­¥ÿ©Ûÿ׃ÿ—ÕÕÕÕÿ‘·ÿÿÿû™™™ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÛÛÿÿœÁt:$etÐS—@„ ÀÌ€HH€€H ÀHHÀÌ ÀHÌHHÌÌH†Ì„NÈHÆL€Ï€€p†P„pÌPp LuaSource10>jÁÙ»require("draw") function line(x1,y1,x2,y2) local dx,dy,e local xi,yi=1,1 local xi2,yi2=1,1 dx=(x2-x1)*2 dy=(y2-y1)*2 if dx<0 then dx,xi=-dx,-1 end if dy<0 then dy,yi=-dy,-1 end if dy>dx then if y1>y2 then yi2=-1 end e=yi2*(y2-y1) while yi2*y1<=yi2*y2 do draw.pixel(x1,y1) y1=y1+yi2 e=e-dx if e<=0 then x1=x1+xi e=e+dy end end else if x1>x2 then xi2=-1 end e=xi2*(x2-x1) while xi2*x1<=xi2*x2 do draw.pixel(x1,y1) x1=x1+xi2 e=e-dy if e<=0 then y1=y1+yi e=e+dx end end end end function draw.traceline(x1,y1,x2,y2) local dx,dy,e local xi,yi=1,1 local xi2,yi2=1,1 dx=(x2-x1)*2 dy=(y2-y1)*2 if dx<0 then dx,xi=-dx,-1 end if dy<0 then dy,yi=-dy,-1 end if dy>dx then if y1>y2 then yi2=-1 end e=yi2*(y2-y1) while yi2*y1<=yi2*y2 do if draw.pxltest(x1,y1) then return x1,y1 end y1=y1+yi2 e=e-dx if e<=0 then x1=x1+xi e=e+dy end end else if x1>x2 then xi2=-1 end e=xi2*(x2-x1) while xi2*x1<=xi2*x2 do if draw.pxltest(x1,y1) then return x1,y1 end x1=x1+xi2 e=e-dy if e<=0 then y1=y1+yi e=e+dx end end end end showgraph() draw.rect(80,0,160,240,1,1,1) draw.pixel(9,100) while 1 do x,y=getpen() if x then a,b=draw.traceline(10,100,x,y) if a then draw.circle(a,b,2,1,0,0) end end end waitkey()2 LuaSource10>jÁÙ,require("draw") showgraph() n=6 while 1 do draw.clear() t={} for i=-n,n do t[i]={} for j=-n,n do t[i][j]=0 end end x,y=0,0 for i=1,n do t[x][y]=1 if i==n then break end k=math.random(1,4) if t[x+1][y]==1 and t[x-1][y]==1 and t[x][y+1]==1 and t[x][y-1]==1 then break end for i=1,2 do if k==1 then if t[x+1][y]==0 then x=x+1 break else k=2 end end if k==2 then if t[x-1][y]==0 then x=x-1 break else k=3 end end if k==3 then if t[x][y+1]==0 then y=y+1 break else k=4 end end if k==4 then if t[x][y-1]==0 then y=y-1 break else k=1 end end end end for x=-n,n do for y=-n,n do if t[x][y]==1 then draw.rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ draw.pxltest(x1,y1) then return x1,y1 end y1=y1+yi2 e=e-dx if e<=0 then x1=x1+xi e=e+dy end end else if x1>x2 then xi2=-1 end e=xi2*(x2-x1) while xi2*x1<=xi2*x2 do if draw.pxltest(x1,y1) then return x1,y1 end x1=x1+xi2 e=e-dy if e<=0 then y1=y1+yi e=e+dx end end end end showgraph() draw.rect(80,0,160,240,1,1,1) draw.pixel(9,100) while 1 do x,y=getpen() if x then a,b=draw.traceline(10,100,x,y) if a then draw.circle(a,b,2,1,0,0) end end end waitkey()2 LuaSource10>jÁÙ,require("draw") showgraph() n=6 while 1 do draw.clear() t={} for i=-n,n do t[i]={} for j=-n,n do t[i][j]=0 end end x,y=0,0 for i=1,n do t[x][y]=1 if i==n then break end k=math.random(1,4) if t[x+1][y]==1 and t[x-1][y]==1 and t[x][y+1]==1 and t[x][y-1]==1 then break end for i=1,2 do if k==1 then if t[x+1][y]==0 then x=x+1 break else k=2 end end if k==2 then if t[x-1][y]==0 then x=x-1 break else k=3 end end if k==3 then if t[x][y+1]==0 then y=y+1 break else k=4 end end if k==4 then if t[x][y-1]==0 then y=y-1 break else k=1 end end end end for x=-n,n do for y=-n,n do if t[x][y]==1 then draw.rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€1=x1+xi e=e+dy end end else if x1>x2 then xi2=-1 end e=xi2*(x2-x1) while xi2*x1<=xi2*x2 do if draw.pxltest(x1,y1) then return x1,y1 end x1=x1+xi2 e=e-dy if e<=0 then y1=y1+yi e=e+dx end end end end showgraph() draw.rect(80,0,160,240,1,1,1) draw.pixel(9,100) while 1 do x,y=getpen() if x then a,b=draw.traceline(10,100,x,y) if a then draw.circle(a,b,2,1,0,0) end end end waitkey()2 LuaSource10>jÁÙ,require("draw") showgraph() n=6 while 1 do draw.clear() t={} for i=-n,n do t[i]={} for j=-n,n do t[i][j]=0 end end x,y=0,0 for i=1,n do t[x][y]=1 if i==n then break end k=math.random(1,4) if t[x+1][y]==1 and t[x-1][y]==1 and t[x][y+1]==1 and t[x][y-1]==1 then break end for i=1,2 do if k==1 then if t[x+1][y]==0 then x=x+1 break else k=2 end end if k==2 then if t[x-1][y]==0 then x=x-1 break else k=3 end end if k==3 then if t[x][y+1]==0 then y=y+1 break else k=4 end end if k==4 then if t[x][y-1]==0 then y=y-1 break else k=1 end end end end for x=-n,n do for y=-n,n do if t[x][y]==1 then draw.rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ion(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€;"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ion(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ end end end for x=-n,n do for y=-n,n do if t[x][y]==1 then draw.rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ draw.rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€en() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€.")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€À ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€n(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€=-n,n do if t[x][y]==1 then draw.rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€UUUUUP*ªªªª UUUT ªª€üÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ if a then draw.circle(a,b,2,1,0,0) end end end waitkey()2 LuaSource10>jÁÙ,require("draw") showgraph() n=6 while 1 do draw.clear() t={} for i=-n,n do t[i]={} for j=-n,n do t[i][j]=0 end end x,y=0,0 for i=1,n do t[x][y]=1 if i==n then break end k=math.random(1,4) if t[x+1][y]==1 and t[x-1][y]==1 and t[x][y+1]==1 and t[x][y-1]==1 then break end for i=1,2 do if k==1 then if t[x+1][y]==0 then x=x+1 break else k=2 end end if k==2 then if t[x-1][y]==0 then x=x-1 break else k=3 end end if k==3 then if t[x][y+1]==0 then y=y+1 break else k=4 end end if k==4 then if t[x][y-1]==0 then y=y-1 break else k=1 end end end end for x=-n,n do for y=-n,n do if t[x][y]==1 then draw.rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€ draw.rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€€Ï€€p†P„pÌPp LuaSource10>jÁÙ»require("draw") function line(x1,y1,x2,y2) local dx,dy,e local xi,yi=1,1 local xi2,yi2=1,1 dx=(x2-x1)*2 dy=(y2-y1)*2 if dx<0 then dx,xi=-dx,-1 end if dy<0 then dy,yi=-dy,-1 end if dy>dx then if y1>y2 then yi2=-1 end e=yi2*(y2-y1) while yi2*y1<=yi2*y2 do draw.pixel(x1,y1) y1=y1+yi2 e=e-dx if e<=0 then x1=x1+xi e=e+dy end end else if x1>x2 then xi2=-1 end e=xi2*(x2-x1) while xi2*x1<=xi2*x2 do draw.pixel(x1,y1) x1=x1+xi2 e=e-dy if e<=0 then y1=y1+yi e=e+dx end end end end function draw.traceline(x1,y1,x2,y2) local dx,dy,e local xi,yi=1,1 local xi2,yi2=1,1 dx=(x2-x1)*2 dy=(y2-y1)*2 if dx<0 then dx,xi=-dx,-1 end if dy<0 then dy,yi=-dy,-1 end if dy>dx then if y1>y2 then yi2=-1 end e=yi2*(y2-y1) while yi2*y1<=yi2*y2 do if draw.pxltest(x1,y1) then return x1,y1 end y1=y1+yi2 e=e-dx if e<=0 then x1=x1+xi e=e+dy end end else if x1>x2 then xi2=-1 end e=xi2*(x2-x1) while xi2*x1<=xi2*x2 do if draw.pxltest(x1,y1) then return x1,y1 end x1=x1+xi2 e=e-dy if e<=0 then y1=y1+yi e=e+dx end end end end showgraph() draw.rect(80,0,160,240,1,1,1) draw.pixel(9,100) while 1 do x,y=getpen() if x then a,b=draw.traceline(10,100,x,y) if a then draw.circle(a,b,2,1,0,0) end end end waitkey()2 LuaSource10>jÁÙ,require("draw") showgraph() n=6 while 1 do draw.clear() t={} for i=-n,n do t[i]={} for j=-n,n do t[i][j]=0 end end x,y=0,0 for i=1,n do t[x][y]=1 if i==n then break end k=math.random(1,4) if t[x+1][y]==1 and t[x-1][y]==1 and t[x][y+1]==1 and t[x][y-1]==1 then break end for i=1,2 do if k==1 then if t[x+1][y]==0 then x=x+1 break else k=2 end end if k==2 then if t[x-1][y]==0 then x=x-1 break else k=3 end end if k==3 then if t[x][y+1]==0 then y=y+1 break else k=4 end end if k==4 then if t[x][y-1]==0 then y=y-1 break else k=1 end end end end for x=-n,n do for y=-n,n do if t[x][y]==1 then draw.rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€rect(80+8*x,100+8*y,80+8*x+7,100+8*y+7) end end end waitkey() end LuaSource10>jÁÙïvector=function(a,b) local v={x=a,y=b} setmetatable(v,{ __add=function(p,q) return vector(p.x+q.x,p.y+q.y) end, __sub=function(p,q) return vector(p.x-q.x,p.y-q.y) end, __unm=function(p) return vector(-p.x,-p.y) end, __mul=function(p,q) return vector(p.x*q,p.y*q) end, __div=function(p,q) return vector(p.x/q,p.y/q) end, __eq=function(p,q) return p.x==q.x and p.y==q.y end, __index={ dot=function(p,q) return p.x*q.x+p.y*q.y end, len=function(p) return math.sqrt(p.x^2+p.y^2) end, ang=function(p) return math.deg(math.atan2(p.y,p.x)) end, rot=function(p,a) a=math.rad(a) return vector(p.x*math.cos(a)-p.y*math.sin(a),p.x*math.sin(a)+p.y*math.cos(a)) end, norm=function(p) return p/p:len() end, dist=function(p,q) return (p-q):len() end, }, __tostring=function(p) return "("..p.x..";"..p.y..")" end, }) return v end export{vector=vector}e- oc22ÐSÂ4À ÿà?€ € Q@À¸ J@8D@À€(J@ €(Q@?€( € ÿèÀüÀ ?÷ü Ê°€UPT*ª°ª UU_ýUPªªªªª¨UUUUUP*ªªªª UUUT ªª€