Jump to content
  • entries
    4,967
  • comments
    2,721
  • views
    1,810,868

pineapples in october.


atari2600land

188 views

Not to be confused with "Lemons in August." So I wondered today while looking at my incredibly long code about the banana movement in my pineapple game, if I could shorten it by adding a couple of extra variables. As a result, the code is a lot shorter with only three variables added. Right now I'm up to var47. The highest I got on GoSub was var39. So while it may seem that there's a lot less involved in this game, there actually is a lot more happening. This is the banana moving code.

 


movementtt_of_banana
    if bananadir=1 && bananay>150 then bananadir=3 : bananawall=1
    if bananadir=1 && bananax<8 then bananadir=2 : bananawall=1
    if bananadir=2 && bananay>150 then bananadir=4 : bananawall=1
    if bananadir=2 && bananax>144 then bananadir=1 : bananawall=1
    if bananadir=3 && bananay<18 then bananadir=1 : bananawall=1
    if bananadir=3 && bananax<8 then bananadir=4 : bananawall=1
    if bananadir=4 && bananay<18 then bananadir=2 : bananawall=1
    if bananadir=4 && bananax>144 then bananadir=3 : bananawall=1

    if bananadir=1 then bananax=bananax-1 : bananay=bananay+2
    if bananadir=2 then bananax=bananax+1 : bananay=bananay+2
    if bananadir=3 then bananax=bananax-1 : bananay=bananay-2
    if bananadir=4 then bananax=bananax+1 : bananay=bananay-2
    return

To use it, I call up a banana's x, y and direction, feed it into the code, and then put the result back, like so:


    bananadir=banana1dir : bananay=banana1y : bananax=banana1x
    gosub movementtt_of_banana
    banana1dir=bananadir : banana1y=bananay : banana1x=bananax

Pretty clever, huh? The way it was before was having code keep track of each banana this way. Now there's a lot less code.

 

While I was at it, I also changed some colors. I thought the purplish-brown color was too dark, so I made it pink. Now it looks like strawberry ice cream. I made the papaya a darker green. So now at least I can add more bananas way easier. My limit of the number of stuff I can have in a certain ZONE is 31. I just think of that as the entire screen because I doubt that I'll add 22 extra bananas bouncing around. I think the limit to the number of variables I can have is var99, so I'm good with that. Now I'm bored again.

pineapple2players.png.18e08c74f526a51a0549b48a33d7ae9e.png

0 Comments


Recommended Comments

There are no comments to display.

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...