Busy Bee (MSX) by Keith Erickson
A downloadable game
In Busy Bee, the object of the game is to collect flowers while avoiding spikes and to get home safely before the bear gets to your beehive.
When you have collected enough flowers, the beehive will flash to indicate that you can go home. While the beehive is flashing, all flowers are worth double points.
Each stage, The number of spikes and the number of flowers to collect will increase.
Try to beat 250 points!
0: Start off by setting up the screen mode, screen width, screen colors, turn the key shortcut display off, and set all variables as integers.
Define string A$ with a big chunk of the game's graphics: beehive, grass, spikes, flower, bee1, bee2, flower colors, beehive layout.
Set the bee's starting X and Y coordinates, and vpoke the color for the spikes
1: Define string B$ with the graphics for the bear sprite.
The for loop reads graphics from A$ using the MID$ command. This saves a little space over using a data statement which requires a lot of commas. This loop reads and pokes the beehive graphics into memory. After the first 4 are written, the counter jumps back by 32 and makes duplicates of the first 2 characters (for collision purposes)
Then poke colors for the flowers.
2: Putting sprite 0 at Y position 208 hides all sprites. This is used when the game restarts after a game over.
G is both the stage number (G\5) and number of spikes in a stage. Everything else is just setting text strings for various text and music.
Did you see the hidden message in music string O$?
3: The first for loop is 2 different loops in 1. part 1 pokes the spikes and the grass characters (the (i>7)*-504 is used to change between poking the spikes and the grass). Part 2 pokes the bee sprite definitions into memory (again, the (i>7)*-24 is used to jump between sprite def 0 and 1 which are 16x16 sprites, but only using the first 8x8 chunk)
The next for loop is a nested loop that pokes the flower characters into memory (reuse the same graphic, but put them in 4 separate locations)
The last for loop pokes the bear sprite into memory.
Lastly, start playing a tune before the screen is drawn.
4: Poke the grass color.
The first for loop pokes the nametable with the grass character (fill the whole screen).
The second for loop repeatedly prints a blank character until we have a nice grass border (this is why the screen width was set to 30 and not 32)
The third for loop draws the spikes and the flowers: N is a random location on the screen. O looks at which character is at the random location, and if it is not a blank space, the loop is extended by 1 so it can try again to find a blank space. C is which character is being drawn - if the loop is lower than G, the spike will be drawn. otherwise, 1 of the 4 flower characters will be drawn.
Set the colors for the bee and bear sprite so it won't have to set it during the main loop.
5: Reset some values before the stage begins.
The for loop pokes the beehive into the nametable.
Poke the beehive colors, then put a blank space at the bee's starting position to prevent a spike from being drawn there.
Print "Busy bee" and the stage # at the top of the screen.
Unless the space bar is pressed, keep repeating this line.
Once the spacebar is pressed, erase "busy bee" and the stage #.
6: Always toggle B between 1 and 0 (used for the bee's animation)
Add B to value D (used for moving and animating the bear)
If the arrow keys are pressed, (but not diagonals) set value A to the joystick value (1,3,5,7) and set M to 1. Otherwise M=0 and F=10
If a direction key is pressed, then reduce F by 2. F is the "force" value, it allows the bee to change direction more quickly, but still drift.
7: Add or subtract from Y speed and X speed depending on what direction is pressed and the current "force" value.
If the speed in any direction is greater than 55 then reduce it to a max of 55
8: Start the bear sprite at X position 232 and move it left based on value D and animate it based on value D as well.
Add the X and Y speeds to the X2 and Y2 positions.
Put the bee sprite at X2\10 and Y2\10. This gives it more of a floating point type positioning without having to use slow floating point numbers.
Set value Q to the current nametable position of the bee.
Use value R to look at which character is at the bee's current position.
If the bee is over a character lower than 32 (any of the 4 flowers), then blank that character, play a sound and add 1 to E (# of flowers collected) if 10 or fewer flowers remain, then they are worth 2 points instead of 1.
If R is greater than 99, then that means the bee hit something it is intended to bounce off of, so reverse the bee's X and Y speeds.
If the bee has collected enough flowers then flash the beehive and set K to 1 to indicate that the bee has collected enough flowers.
9: If the bee returned home after collecting enough flowers, then play a tune, hide the sprites, print "Success!", increase the stage number, reset K and go to line 3.
Otherwise, if the bee hits a spike or the bear got to the beehive, then print "Game over", print the final score, play the game over tune and set the game over tune to nothing as to not repeat it over and over.
If the space bar is pressed, then clear the flowers collected value and restart the game.
Otherwise, repeat this line until the spacebar is pressed.
Otherwise, if none of these conditions is true, then go to line 6.
0 SCREEN1,2,0:WIDTH30:COLOR15,1,1:KEYOFF:DEFINTA-Z:A$="C0E0F0F0F0F0E000C381000000000000FFFFFFFFFFFFFF00FCFEFFFFFFFFFE0048293EEC377C941225AA56753EBE7F5E6C7FFFE667FFFE3636361C56AFAB6F1600087F56AFAB6F16444445484444444044414243":X2=88:Y2=214:VPOKE8197,97 1 B$="1B341E3F27F77FFF1F3F031F1737376E0080808000B2BDBD7EFEFEFEFFFF0733001B341E3F27F77FFF1F3F030B0B0D1B000080808070BABDBD7EFEFEFEFCDCB8":FORI=0TO47:VPOKE768+I,VAL("&H"+MID$(A$,1+(I>31)*32+I*2,2)):NEXT:VPOKE8192,113:VPOKE8193,241:VPOKE8194,81:VPOKE8195,209 2 PUTSPRITE0,(0,208):G=5:O$="o3l6abeecafefedabadbear":C$="GAME OVER":D$="SCORE":F$="GOOD JOB!":G$="BUSY BEE":H$="ROUND":I$=" ":S=0:J$="o4l32cdefgr32l7eaa":K$="o4l32efgabr32l7go5cc":L$="o5l32cgg":M$="o3l8cdefgr8l4er32aa":N$="o3l8efgabr8l4gr32o4cc" 3 FORI=0TO15:VPOKE320+I+(I>7)*-504,VAL("&H"+MID$(A$,65+I*2,2)):VPOKE14336+I+(I>7)*-24,VAL("&H"+MID$(A$,113+I*2,2)):NEXT:FORI=0TO7:FORJ=0TO3:VPOKEI+J*64,VAL("&H"+MID$(A$,97+I*2,2)):NEXT:NEXT:FORI=0TO63:VPOKE14400+I,VAL("&H"+MID$(B$,1+I*2,2)):NEXT:PLAYO$ 4 VPOKE8205,33:FORI=0TO767:VPOKE6144+I,104:NEXT:LOCATE0,1:FORI=0TO659:PRINT" ";:NEXT:FORI=0TO19+G*2:N=6240+(RND(2023)*640):O=VPEEK(N):I=I+(O<>32):C=RND(33)*4:C=C*-(I>G)-((I<G)*5):VPOKEN,-C*8*(O=32)+O*-(O<>32):NEXT:PUTSPRITE0,,11:PUTSPRITE1,,6 5 D=0:S=S+E:E=0:X=0:X2=88:Y=0:Y2=214:FORI=0TO11:VPOKE6144+I+(I\4)*28,56+VAL(MID$(A$,145+I*2,2)):NEXT:VPOKE8204,161:VPOKE6241,32:LOCATE11,1:PRINTG$:LOCATE11,2:PRINTH$;:PRINTG\5:IFNOTSTRIG(0)GOTO5ELSELOCATE11,1:PRINTI$:LOCATE11,2:PRINTI$ 6 B=(B+1)MOD2:D=D+B:IFSTICK(0)MOD2THENA=STICK(0):M=1ELSEM=0:F=10ELSEIFMANDFTHENF=F-2 7 Y=Y+((A=1)-(A=5))*M*F:X=X+((A=7)-(A=3))*M*F:IFABS(X)>55THENX=SGN(X)*55ELSEIFABS(Y)>55THENY=SGN(Y)*55 8 PUTSPRITE1,(232-D\2,7),,3+(DMOD7>3):Y2=Y2+Y:X2=X2+X:PUTSPRITE0,(X2\10,Y2\10),,B:Q=6144+((Y2+40)\80)*32+(X2+40)\80:R=VPEEK(Q):IFR<32THENVPOKEQ,32:PLAYL$:E=E+1-(E>9+G)ELSEIFR>99THENY=Y*-1:X=X*-1ELSEIFE>9+GTHENK=1:VPOKE8204,161+B*80 9 IFK=1ANDR=97THENPLAYJ$,K$:PUTSPRITE0,(0,208):LOCATE11,11:PRINTF$:G=G+5:K=0:GOTO3:ELSEIFR=40ORD>420THENLOCATE11,12:PRINTC$:LOCATE12,13:PRINTD$;:PRINTS+E:PLAYM$,N$:M$="":N$="":IFSTRIG(0)THENE=0:GOTO2ELSE9ELSE6
To load game, type: load"bee.bas"
To start the game or start the next stage, press the spacebar.
To control the bee, use the arrow keys.