0 Members and 1 Guest are viewing this topic.
function on.charIn(ch) if ch=="r" then blocks={5,5,5,5,5,5,5,5,5,5,5,5} blockAttacked=0 game="notfinished" score=0 player=100 shotX=0 shotY=0 level=1 wait=0.04 aliensDir="right" down="no" aliensX={} aliensY={} shotsX={} shotsY={} lives=3 for i=1,21,1 do aliensX[i]=(i-1)%7*31+1 aliensY[i]=math.floor((i-1)/7)*25+10 shotsX[i]=aliensX[i] shotsY[i]=200 end end if ch=="c" then originalColors=not originalColors endendfunction blocktest(x,y) blockAttacked=0 if y>170 and y<177 then if x>30 and x<40 and blocks[1]>0 then blockAttacked=1 elseif x>40 and x<=50 and blocks[2]>0 then blockAttacked=2 elseif x>50 and x<=60 and blocks[3]>0 then blockAttacked=3 elseif x>60 and x<=70 and blocks[4]>0 then blockAttacked=4 elseif x>140 and x<=150 and blocks[5]>0 then blockAttacked=5 elseif x>150 and x<=160 and blocks[6]>0 then blockAttacked=6 elseif x>160 and x<=170 and blocks[7]>0 then blockAttacked=7 elseif x>170 and x<=180 and blocks[8]>0 then blockAttacked=8 elseif x>250 and x<=260 and blocks[9]>0 then blockAttacked=9 elseif x>260 and x<=270 and blocks[10]>0 then blockAttacked=10 elseif x>270 and x<=280 and blocks[11]>0 then blockAttacked=11 elseif x>280 and x<=290 and blocks[12]>0 then blockAttacked=12 end endendon.charIn("r")function on.arrowLeft() if player>0 then player=player-10 endendfunction on.arrowRight() if player<290 then player=player+10 endendfunction on.tabKey() if shotY<=0 then shotY=195 shotX=player+13 endendfunction on.paint(gc) if originalColors then gc:setColorRGB(0,0,0) gc:fillRect(0,0,platform.window:width(),platform.window:height()) end if not originalColors then gc:setColorRGB(0,0,0) else gc:setColorRGB(255,255,255) end gc:setPen("thin","smooth") gc:setFont("sansserif","r",8) gc:drawString("Lua Alien Invaders - Par Loic Pujet",10,200,"top") if game=="notfinished" then if not originalColors then gc:setColorRGB(200,0,0) else gc:setColorRGB(255,255,255) end for i=1,21,1 do if aliensY[i]~=0 then gc:drawArc(aliensX[i]+4,aliensY[i]-9,10,10,0,360) gc:fillArc(aliensX[i]-5,aliensY[i]-4,28,8,0,360) end end if not originalColors then gc:setColorRGB(0,0,200) else gc:setColorRGB(255,255,0) end for i=1,21,1 do if shotsY[i]<200 then gc:fillRect(shotsX[i],shotsY[i],2,5) end end if shotY>0 then gc:fillRect(shotX,shotY,4,6) end if not originalColors then gc:setColorRGB(100,0,255) else gc:setColorRGB(0,255,0) end gc:fillRect(player,195,30,10) gc:fillRect(player+13,191,4,4) gc:setFont("sansserif","r",10) gc:drawString("Vies:"..tostring(lives).." Score:"..tostring(score).." Niveau:"..tostring(level),0,0,"top") if not originalColors then add=3 else add=0 end for i=1,12,1 do if blocks[i]>0 then gc:fillRect(i*10+math.floor((i-1)/4)*70+20,180-blocks[i]*2,10,blocks[i]*2) end end else if not originalColors then gc:setColorRGB(0,0,0) else gc:setColorRGB(255,255,255) end gc:setFont("sansserif","b",15) gc:drawString("Score : "..tostring(score),100,50, "top") if not originalColors then gc:setColorRGB(0,0,255) end gc:drawString("Appuyez sur R pour rejouer",50,150,"top") end timer.start(wait)endfunction on.timer() timer.stop() if game=="notfinished" then if aliensDir=="right" then for i=1,21,1 do if aliensY[i]>0 then aliensX[i]=aliensX[i]+1 end end else for i=1,21,1 do if aliensY[i]>0 then aliensX[i]=aliensX[i]-1 end end end if aliensDir=="right" then for i=1,21,1 do if aliensX[i]>305 then down="yes" end end else for i=1,21,1 do if aliensX[i]<15 then down="yes" end end end if down=="yes" then down="no" for i=1,21,1 do if aliensY[i]>0 then aliensY[i]=aliensY[i]+25 end end if aliensDir=="left" then aliensDir="right" else aliensDir="left" end end for i=1,21,1 do if aliensY[i]>180 then game="finished" end if shotsY[i]>=200 and aliensY[i]~=0 then if math.random(1,100)==5 then shotsY[i]=aliensY[i]+math.random(1,10) shotsX[i]=aliensX[i] end else shotsY[i]=shotsY[i]+3 end blocktest(shotsX[i],shotsY[i]) if blockAttacked>0 then shotsY[i]=201 blocks[blockAttacked]=blocks[blockAttacked]-1 end if shotsY[i]<200 then if shotsY[i]>195 and shotsX[i]>player and shotsX[i]<player+30 then lives=lives-1 shotsY[i]=200 end end if shotY>0 and shotY>aliensY[i]-5 and shotY<aliensY[i]+5 and shotX>aliensX[i]-10 and shotX<aliensX[i]+21 then aliensY[i]=0 aliensX[i]=100 shotY=0 score=score+1 end end blocktest(shotX,shotY) if blockAttacked>0 then shotY=-1 blocks[blockAttacked]=blocks[blockAttacked]-1 end if shotY>=0 then shotY=shotY-5 end if lives<=0 then game="finished" end wintest=0 for i=1,21,1 do wintest=wintest+aliensY[i] end if wintest==0 then if wait>0.01 then wait=wait-0.005 end level=level+1 aliensDir="right" down="no" for i=1,21,1 do aliensX[i]=(i-1)%7*31+1 aliensY[i]=math.floor((i-1)/7)*25+10 shotsX[i]=aliensX[i] shotsY[i]=200 end end end platform.window:invalidate()end
Space Invaders 0.8 is already in my calc and it's pretty great. However, I'd still like an English version and highscores I really like it though.
because a lot of French people (including me) have their calc in English..