Log In  


Cart #gorillas-0 | 2024-09-22 | Embed ▽ | No License
3

ABOUT

Your mission is to hit your opponent with the exploding banana by varying the angle and power of your throw, taking into account wind speed*, gravity, and the city skyline.

GORILLAS.1K was an attempt to demake the classic QBASIC game GORILLA.BAS, using only 1,024 compressed bytes of code, for #Pico1k Jam 2024.

*(Alas, I ran out of code space to implement wind - instead u got fancy animations!)

FEATURES

đŸ‘Ĩ 2-Player Gameplay
🕹ī¸ Endless Levels
🌚 Moon Collision
đŸ’¯ Scoring
đŸ”ŧ Simplified Controls *(Compared to orig)

CONTROLS

◀ī¸/â–ļī¸ = Increase/Decrease Angle
đŸ”ŧ/đŸ”Ŋ = Increase/Decrease Speed
X = Fire Banana 🍌

REFERENCES/LINKS

📖 Gorillas (video game) (Wikipedia)
📖 GORILLAS QBASIC (Archive.org)
🎞ī¸ QBasic Gorillas (Gorilla.BAS) 1991 - IBM
🎞ī¸ Gorillas (a.k.a. QBasic Gorillas or GORILLAS.BAS)
📖 GORILLA.BAS: How to Play the Secret MS-DOS Game From Your Childhood

SOURCE CODE (1024 Compressed Bytes)*

*(before "safe" minification to Tiny .ROM with Shrinko8)

----------------------------- GORILLA.1K -----------------------------
-- global vars
players = {{},{}}
curr_plr = 1
g=unpod("b64:bHo0AD4AAAA8AAAA8C1weHUAQyAHEgQAEzATQBMQJBMAFAAEIzQAEwAUIEQAEiQAIiQAIiAEEgA0EgA0AAI0ICQgJDAkMCRAJBA=")
b=unpod("b64:bHo0ABgAAAAWAAAA8AdweHUAQyAFBQQwCTAKIBoQGgQJGgQA")
--srand(19)--seed for screenshot/demo

-- game_init -------------------
function _init()
   _f = 0 -- frame counter
   -- init city --
   city = {}
   damage = {}
   xpos = 1
   chkpxl = 0
   while xpos<482 do
      w=(4+(rnd(2)))*9
      add(city, {
         x = xpos,
         y = 30+rnd(150),
         w = w
      })
      xpos+=w+1
   end

   -- init players
   for playernum=1,2 do
      plr=players[playernum]
      if playernum==1 then
         bld=city[2]
         sa=0.125
      else
         bld=city[#city-1]
         sa=0.375
      end
      plr.a=sa
      plr.x=bld.x+bld.w/2
      plr.y=270-bld.y
      plr.p=5
      plr.d=false
      if (t()<1) plr.s=0
   end
end

function _draw()
   -- update -------------------
   srand(0)
   _f+=1
   -- update positions
   plr=players[curr_plr]
   -- inputs
   -- power
   plr.p = mid(plr.p-(btn()\8%2-btn()\4%2)/10, 20)
   -- adjust angle
   plr.a = mid(plr.a-(btn()\2%2-btn()%2)/400, 0.5)
   if btnp(5) and not banana then
      -- throw banana --
      banana = {
         x = plr.x,
         y = plr.y-20,
         vx = plr.p*cos(plr.a),
         vy = plr.p*sin(plr.a)
      }
   end

   -- draw -------------------
   if (_f%2==1) return -- update 60fps (better collision), but draw at 30fps

   -- draw_city --
   cls(1)
   lastbuilding_end = 0
   for b in all(city) do
      -- building
      rectfill(b.x,270-b.y,lastbuilding_end+b.w,270,rnd{17,24,6})
      -- windows
      for wy=270-b.y+2,270,6 do
         for wx=b.x+2,b.x+b.w-3,4 do
            ?"\^x2\^y3\16",wx,wy,rnd{5,10}
         end
      end
      lastbuilding_end = b.x+b.w
   end
   -- draw damage
   for d in all(damage) do
      circfill(d.x,d.y,d.m,1)
   end
   -- draw gorillas --
   for playernum=1,2 do
      plr=players[playernum]
      if not plr.d then
         -- col switch based on state/anim
         pal(2,4)
         pal(3,1)
         if banana and playernum==curr_plr and playernum==1 or chkpxl==4 and t()*2\1%2==1 then
            pal(2,1)
            pal(3,4)
         end
         spr(g,plr.x-6,plr.y-18)
         pal(2,4)
         pal(3,1)
         if banana and playernum==curr_plr and playernum==2 or chkpxl==4 and t()*2\1%2==0 then
            pal(2,1)
            pal(3,4)
         end
         spr(g,plr.x,plr.y-18,true)
      end
      -- draw_ui --
      ui_x = playernum==2 and 425 or 5
      ?"Player "..playernum,ui_x,5,7
      ?"\rScore:"..plr.s
      if (playernum==curr_plr) then
         ?"\rAngle:"..flr(plr.a*360)%360
         ?"\rPower:"..plr.p
      end
   end

   -- draw moon --
   ?"\^w\^t\140",232,16
   if (h) ?"\134",235,24,1 -- hit

   if banana then
      -- move banana --
      banana.vy += 0.25 --gravity
      banana.x += banana.vx
      banana.y += banana.vy
      -- check collision
      chkpxl = pget(banana.x,banana.y)
      if banana.y < 0 then
         -- in sky, wait...
      else
         -- draw banana --
         spr(b,banana.x,banana.y, _f\8%4>0 and _f\8%4<3, _f\8%4>1)
         if chkpxl > 1 then
            -- hit something
            if (chkpxl==7) h=1 return
            if chkpxl==4 then
               -- hit self?
               if (abs(banana.x-players[curr_plr].x)<100) then
                  -- hit self!
                  players[curr_plr].d=true -- self dead
                  players[curr_plr].s-=1
               else
                  -- hit other player
                  players[3 - curr_plr].d=true -- other dead
                  players[curr_plr].s+=1
               end
            else
               -- hit building
            end
            explode()
            banana = nil
            -- switch turn
            curr_plr = 3-curr_plr
         elseif chkpxl==0 then
            -- out of bounds
            banana = nil
            -- switch turn
            curr_plr = 3-curr_plr
         end --if(chkpxl > 1) then
      end -- if in sky
   else -- banana
      h = nil
   end

   if exp then
      if exp.r > -100 then
         exp.r -= 1
         circfill(exp.x,exp.y,exp.r,8+(_f%3))
      else
         -- kill explosion
         exp = nil
         -- end of round?
         if (chkpxl==4) _init()
      end
   end
end

function explode()
   exp = {
      x = banana.x,
      y = banana.y,
      m = chkpxl==4 and 25 or 5,
      r = chkpxl==4 and 25 or 5
   }
   -- add damage
   add(damage,exp)
end

3



[Please log in to post a comment]