Virus Defender (JimOfLeisure)
About
Keep the virus from getting your precious cell which is now defended by a light-infused bleach cannon that you must aim and fire! They keep coming faster and faster, and it is up to you to save the day!
Controls: Left and right arrows rotate the turret, and the Z key fires the weapon.
This is my first Itch, Jam, and fantasy console game. I'm more of a devops production support developer, but I recently found Itch and Jams and have some free time to play. Thanks for checking it out!
This was made for TweetTweetJam 4, a Jam needing source code that would fit into two tweets and can have no assets beyond the framework/console.
I started off wanting to make battle tanks, then started with a center turret, then thought an asteroids-like game might be necessary, then by the time I got one bullet, one enemy, and scoring working I was about out of characters allowed for the jam.
The bullet will fly forever until it hits the virus or until you fire again. There is only one bullet flying at a time.
The virus speeds up 20% every time you kill it. It also always starts at the top-left, and after the game starts it always moves in the direction your turret is pointing when the bullet hits it.
When the virus gets close enough to infect your cell, the high score is updated if necessary then the game instantly starts over.
The high score does not preserve in the virtual cartridge, but it gives you a goal to beat.
Here is 558 characters comprising all the lua code for this game. Actually there are even 3 extra newlines for 'readability', so this could have been done in 555 characters:
a=math b=240 c=138 d=120 e=69 f=0 g=0 h=0 i=.5 j=.2 k=.5 function l()m=d n=e o=0 p=0 q=0 r=0 end l() function TIC()t=a.sin(a.rad(f))u=-a.cos(a.rad(f))m=m+o n=n+p q=q+i r=r+j if btnp(4)then m=d+t*9 n=e+u*9 o=t*2 p=u*2 end if btn(2)then f=f-4 end if btn(3)then f=f+4 end cls()circ(d,e,7,8)print("*",(q-6)%b,(r-4)%c,6,true,2)circ(q%b,r%c,2,6) if pix(m%b,n%c)==6 then g=g+1 k=k*1.2 i=k*t j=k*u l()end print("SCORE "..g.." HI "..h,9,0)pix(m%b,n%c,15)line(d,e,d+t*9,e+u*9,15) if a.abs(q%b-d)<9 and a.abs(r%c-e)<9 then h=g>h and g or h g=0 k=.5 i=.5 j=.2 l()end endAnd here is the pre-minified, commented version. :
-- for extra manual minifying m=math screenwidth=240 screenheight=138 middlex=120 middley=69 -- starting turrent angle angle=0 score=0 highscore=0 edx=.5 edy=.2 espeed=.5 function resetmovers() -- init bullet x, y, dx, and dy (velocity) bx=middlex by=middley dx=0 dy=0 -- init enemy ex=0 ey=0 end resetmovers() function TIC() x=m.sin(m.rad(angle)) -- negating Y because screen coords -- and I want starting position up -- and 0 is shorter than 180 -- only saving 1 char, though y=-m.cos(m.rad(angle)) bx=bx+dx by=by+dy ex=ex+edx ey=ey+edy if btnp(4) then -- pew pew bx=middlex+x*9 by=middley+y*9 dx=x*2 dy=y*2 end if btn(2) then angle=angle-4 end if btn(3) then angle=angle+4 end cls() -- cell circ(middlex,middley,7,8) -- enemy print("*", (ex-6)%screenwidth, (ey-4)%screenheight, 6, true, 2) circ(ex%screenwidth,ey%screenheight,2,6) -- bullet hit detect if pix(bx%screenwidth,by%screenheight) == 6 then score = score + 1 -- -- reset enemy espeed=espeed*1.2 edx=espeed*x edy=espeed*y resetmovers() end -- score print("SCORE "..score.." HI "..highscore,9,0) -- bullet pix(bx%screenwidth,by%screenheight,15) -- turret line(middlex,middley,middlex+x*9,middley+y*9,15) if m.abs(ex%screenwidth-middlex)<9 and m.abs(ey%screenheight-middley)<9 then -- game over! man. game over! highscore = score > highscore and score or highscore score=0 espeed=.5 edx=.5 edy=.2 resetmovers() end end