Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- frogX=0
- frogY=0
- died=0
- camX=frogX
- camY=frogY
- ::_::
- flip()
- cls(1)
- // weird arrow key input
- z=btnp()
- // add +/- 5 to x for right/left arrows
- frogX+=(flr(z/2)%2-z%2)*5
- // add +/- 1 to y for up/down arrows
- frogY-=flr(z/8)%2-flr(z/4)%2
- // camera eases toward frog position
- camX+=(frogX-camX)/3
- camY+=(frogY-camY)/3
- // draw road lanes
- for laneY=frogY+25,frogY-2,-1 do
- // each lane has its own randomized properties
- srand(laneY)
- // car animation properties
- cycleOffset=rnd()
- carSpeed=8+rnd(16)
- // perspective distortion strength
- // (persp=0 means "infinitely far away")
- persp=(laneY-camY+2.3)/12
- // draw the road
- // (but draw it offscreen if persp<0)
- rectfill(-1,64+9/persp,sgn(persp)*127,127,6-laneY%2)
- // draw a frog in every lane...
- // but offset it off the screen if the
- // frog isn't actually in this lane
- print("🐱",61+(frogX-camX)/persp+(laneY-frogY)*99,62+7.5/persp,3)
- // each lane has a different # of cars
- // (early/negative lanes have no cars)
- for i=1,sgn(laneY-2)*rnd(8) do
- // a car has two halves, parallel to the lane
- // (near-half and far-half)
- for k=0,1 do
- // each car has five sub-circles for the body
- for j=-2,2 do
- // x-position of this sub-circle
- worldX=(i*carSpeed*4+j+t()*carSpeed+cycleOffset-camX)%198-99
- // collision detection for the frog
- if laneY==frogY and abs(worldX-frogX+camX)<2 then
- died=1
- end
- // far-half of car uses a different persp value
- persp2=persp-k/60
- // get screen position of this sub-circle
- screenX=worldX/persp2+64
- screenY=5/persp2+64
- // draw this sub-circle
- circfill(screenX,screenY,2/persp2,laneY%5)
- // draw a wheel, but only if j equals +/- 2
- circfill(screenX,screenY+2/persp2,(abs(j)-1)/persp2,0)
- end
- end
- end
- end
- // self-explanatory death check
- if (died>0) then
- goto dead
- end
- // if you're not dead, continue the game loop
- goto _
- ::dead::
- // you done goofed
- // random red/orange noise
- pset(rnd(128),rnd(128),8+rnd(2))
- // death UI
- print("❎ reset",46,62,7)
- // your score is your distance, literally
- print("score: "..frogY,3,3)
- // restart command
- if btn(5) then
- run()
- end
- // haven't reset yet. resume death
- goto dead
Advertisement
Add Comment
Please, Sign In to add comment