Oruga

Copyright © 2017 by Víctor Parada

Oruga

This is a little game for the 2017 NOMAM's BASIC 10-liners Contest. This program fits in the PUR-80 category, and it was written using TurboBASIC XL 1.5 for the 8-bits ATARI XL/XE. Development started on 2017-04-12, and it took 1+2 days. The final version's date is 2017-04-14.

UPDATE: It obtained the 8th place of 26 entries in the category.


Description

You are a starveling caterpillar. Eat the clovers and avoid the flowers on different gardens.


Instructions

ORUGA start The game starts in a small garden surrounded by purple flowers. You are a starveling caterpillar in the middle of the garden.
ORUGA goes for clovers Purple flowers are like poison... you can only eat those sweet green clovers. Go for them!
ORUGA grows Every time you eat a clover, you will grow. When there are no more clovers in a garden, you are ready.
ORUGA walls Now, you are another baby caterpillar in a new garden. Some wall of flowers would difficult your way to clovers.
ORUGA moves You can start moving to any direction.
ORUGA gameover When you eat a poisoned flower or when you bite yourself, the game is over. Press FIRE button to start a new game.

Development of the game

Back in 1994, I programmed a game in AtariBASIC called "Oruga". I think I got the idea from an article in a non computer related magazine. I vaguely remember a screenshot with a small description of the game for the Apple// or Apple//e. It might be one of my first games using ANTIC mode 4 with a ANTIC 5 line for the score, redefining the full character set. As I set the rules, it allowed diagonal movement and many walls aperared in the playfield in every new level.

1984

The original Oruga from 1984

Some years later, the NOKIA 6610 GSM mobile phone included some minigames, and one off them was "Snake", which is almost the same!!!

For the 2017's BASIC 10-liners Contest I was planning to rewrite small versions of all the games I wrote more than 30 years ago, and Oruga was not in the top of the list. Actually, the one in the top was "Babosa", which turned into "Surround" as it was based in that Atari 2600 game.

But it was just a coincidence that another entry in the Contest had a redefined font that looked like the dancing flowers in "Oruga". This was just a three days before the Contest's deadline for submissions. That night, I wrote a draft of a 10-liner version of it just as other drafts I have as 10-liner projects, but it seemed to be complete it in a couple of hours. It only required a new charset for the "sprites" instead of plain ATASCII, and some adjustments to fit the PUR-80 category.

One thing I HAD to change was the item to be eaten: in 1984 it was a mushroom. This year I've already published two more games full of mushrooms and caterpillars: "Minipede" and "Decipede". Now, it is a green clover, but the caterpillar's body is almost the same in another colour. About the dancing flowers, I decided to change them at all, and designed a stylish flower, with stem and leaves.

To make the game harder every new level, I included some walls as obstacles. I drawed in a paper a maze design, but I finally decided to keep only a few and include some of them using a binary pattern. I mean, no walls in round 0, wall 1 in round 1, wall 2 in round 2, walls 1 and 2 in round 3, and so on... four walls allowed 24=16 different playfields. Also, I had to add a delay at every step, so I decided to reduce the delay every 4 levels, and the game will become faster. Finally, each new round requires one more clover than the previous to finish it, making the caterpillar larger and larger.


Download and try

Get the ORUGA.ATR file and set it as drive 1 in a real Atari (or emulator). Turn on the computer and the game should start after loading. A joystick in port 1 is required.


The code

The abbreviated BASIC code is the following:

The full and expanded BASIC listing is:

graphics 28
Sets graphics mode 12+16: ANTIC 4 without text box. Resolution is 40x24.
move $E000,$B000,512
Copies first half of the charset to an unused area of RAM.
move adr("{data}"),$B008,24
Updates chars 33 to 35 with bitmaps for flowers, clover and caterpillar.
poke 756,$B0
Enables the new charset.
s=$BBA0
Sets S as the static point of memory where display data starts in this graphics mode. It's the same as S=DPEEK(88).
poke s-4,6
Just before the display data is the display list's configuration. This POKE sets the last line of the screen as ANTIC 6 (a line of graphics mode 1, 20 chars width).
o=adr("{data}")
Coordinate values for the 8 walls of flowers of the game. Each wall uses 4 bytes: [X1,Y1],[X2,Y2].
z=999
dim p(z)
Sets the length and the array to store the screen position of each piece of the caterpillar.
do
Infinite loop.
  g=1
When G is zero, the game is over.
  n=8
Sets the initial number of clovers to eat in the first garden.
  m=0
Sets number of the first garden to be drawn. There are 16 different gardens.
  q=0
Resets the score. It is total number of clovers eaten.
  cls #6
Clears the whole screen in current graphics mode, without reinitializing the display list.
  while g
Start of game loop.
    poke 77,0
Disables attract mode.
    -move s+1,s,920
Clears the playfield.
    h=0
Sets the index of the header in the list of caterpillar segments in screen.
    l=10
Sets the initial length of the caterpillar on each garden.
    color 161
Sets the palette color as the flowers to draw the garden.
    for a=0 to 7
Loop to draw the walls of flowers.
      b=o+a*4
Selects the coordinates for the current wall.
      if a<4 or m&2^((a>3)*(a-4))
Draw the wall if it is one of the four borders (the first 4 walls), or if it is a wall for this level. The last 4 walls act as 4 bits, and are drawn if the corresponding bit is "on" in the garden number, and the range is 0 to 15.
        plot peek(b),peek(b+1)
        drawto peek(b+2),peek(b+3)
Draws a wall.
      endif
    next a
End of the loop. The garden is ready!
    n=n+(n<20)
Increments the number of cloves required to complete a garden.
    c=0
Reset the counter of cloves eaten in a garden.
    d=1
Sets the initial moving direction to the right.
    p(h)=460+s
    poke p(h),3
Palaces the caterpillar in the middle of the garden.
    position 4,23
Positions the cursor where the "game over" message will be printed.
    pause 30
A small pause before starting the play.
    repeat
Level loop:
      repeat
        a=rand(880)+s
      until peek(a)=0
Finds randomly an empty place in the garden.
      poke a,2
Puts a clover in that place.
      repeat
Game loop until a clover is eaten or the caterpillar crashed.
        pause 5-m/4
A small pause between steps. It gets slightly faster every 4 gardens.
        t=stick(0)
        j=(t=7)-(t=11)+40*((t=13)-(t=14))
Calculates the next step of the caterpillar based on the joystick position.
        if j
          d=j
        endif
If it a valid direction, sets that as the new direction. If it isn't, continue ahead.
        sound 0,160,10,8
Starts a sound for a step.
        b=p(h)+d
Calculates the new position for the head in the garden.
        h=(h+z-1) mod z
Calculates the new index position to store that info in the pointers array.
        f=(h+l) mod z
Finds the index position of the tail.
        p(h)=b
Stores in the array the new screen position of the head.
        r=peek(b)
Gets whatever is in the new position of the head in the screen.
        t=p(f)
        if t
          poke t,0
          p(f)=0
        endif
If the pointer of the tail is available, cleans that screen position and the pointer.
        poke b,3
Puts a new head in the screen.
        sound
Turns off the sound of the step.
      until r
End of the game loop.
      if r=2
Checks if the head hit the clover.
        c=c+1
Increments the number of clovers in the round (garden).
        q=q+1
Increments the score.
        l=l+10*(l<200)
Increments the length of the caterpillar. 200 segments is the maximum. That's almost half of the screen!
        position 4,23
        ? #6;q;
Prints the new score.
      else
        g=0
If the caterpillar hit a wall (flower) of itself, the game ends.
      endif
      sound 0,200-99*g,12,8
Plays a short buzzer. The pitch is high if a clover was eaten, and is low if the caterpillar crashed.
    until g=0 or c>n
End of the level (garden) loop.
    m=m+(m<15)
Increments the number of the garden (up to 15, then it stucks in that level).
    t=0
    while t
Cleans the pointers array.
    pause 9
    sound
A small delay, then turns off the buzzer.
  wend
End of the game loop.
  ? #6;"  game over"
Prints the game over message.
  while strig(0)
  wend
Waits for the joystick trigger to be pressed.
loop
End of the infinite loop.

Return to my 10-liners page.

© 2017 by Víctor Parada - 2017-04-17 (updated: 2020-08-15)