A downloadable game

Chicken

by keyscompany

Platform: BBC Micro Model B or later models

Language: BBC Basic

Category: PUR-80


Instructions

------------

You are in the path of an oncoming train.

You have three seconds to jump out of harm's way by pressing 'Y'.

Score as much as you can over five rounds by jumping as late as you dare.

The later you jump, the more you score. Jump too late and you lose all the points you have gained.

Ready to play? What's the matter, you chicken?


Code

----

---------1---------2---------3---------4---------5---------6---------7---------8
0MODE7:@%=&20209:VDU23,1,0;0;0;0;:ENVELOPE 1,3,0,16,12,1,1,1,126,-10,0,-10,126,0
1S=0:C=0:R=1:PRINTTAB(8,14)"Score "STR$C''SPC8"High Score "STR$H%TAB(8,4)"ROUND"
2FORN=6TO12:PRINTTAB(6,N)SPC18TAB(14,4)STR$R''SPC8:NEXT:FORN=1TO1500:NEXT
3PRINTTAB(8,6)"Train coming"''SPC8"PLAY CHICKEN?"''SPC8"Impact in":TIME=0:T=3
4Y=INKEY-69:IFY=-1:E=TIME:PRINTTAB(18,10);ABS(T-E/100)''CHR$(130);SPC7;:GOTO7
5IFTIME>300:GOTO6:ELSEPRINTTAB(18,10);ABS(T-TIME/100):GOTO4
6PRINTTAB(18,10);0TAB(7,12)CHR$(129)"SQUISH":C=0:S=0:SOUND0,-15,2,5:GOTO8
7IFE>=300:GOTO6:ELSE S=10000/(300-E)DIV1:SOUND1,1,80,2:PRINT"YOU SCORED "STR$S
8C=C+S:R=R+1:PRINTTAB(14,14)STR$C SPC4:FORN=1TO3000:NEXT:IFR<6GOTO2
9PRINTTAB(8,18)"END":REPEATUNTILINKEY(0)=-1:K=GET:IF C>H% H%=C:GOTO0:ELSE GOTO0


Overview

--------

SETUP

Line 0 - sets the screen mode (clearing the screen), tells the BBC Micro to print all numbers to two decimal places,

              turns the cursor off and defines a sound envelope

Line 1 - initiallises the score, high score and round number variables and prints the scoreboard


ROUND BEGINS

Line 2 - clears the game area in the middle of the screen for the start of each round, prints the current round and pauses briefly before the round begins

Line 3 - prints the game area instructions and sets the internal timer (TIME) to 0 and initial time (T) to 3 (seconds)


TIMER LOOP

Line 4 - checks to see if Y is being pressed, if YES: records TIME, converts it to seconds and prints it to the screen then skips to line   7

Line 5 - checks to see if 3 seconds have elapsed, if YES: skips to line 6, if NO: print the current time to the screen and loops back to line 4

SCORING

Line 6 - indicates time has run out, prints 'SQUISH' in red, sets the score for this round to 0, resets any cumulative score to 0 (harsh but fair), makes a buzz from the noise channel before skipping to line 8.

Line 7 - calculates and displays the score (100 divided by the players remaining time in seconds so that for example 0.1 scores 1000) rounded down to the nearest whole number, plays reward sound, also error corrects for if the player stops the clock with 0 seconds left, in which case the program loops back to line 6

Line 8 - adds this rounds score to the cumulative score, prints it to the scoreboard, briefly pauses between rounds increments the round and loops back to line 2 for the next round until all five rounds have been played

Line 9 - prints 'END' when all five rounds are complete, waits until a key is pressed, checks to see if the high score is beaten and passes on the value if YES, leaving it unchanged if NO before looping back to line 0 for a new game

GOTO LINE 0


Variables

---------

S - records the score each round

C - cumulative score

R - keeps track of the round number

H% - high score

TIME - sets the internal timer of the BBC Micro

T - start time in seconds

Y - Y=INKEY-69 used to determine keypress 'Y'

E - time left when player presses 'Y'


Detailed Breakdown

------------------

0

  MODE7 - sets the screen mode to mode 7, it also clears the screen when the game loops back to round 1.

  @%=&20209 - alters the default values for field width and number of decimal places printed so that every numberis printed to two fixed decimal places. This was necessary for the countdown timer to display properly once it gets below 0.1. Otherwise the BBC Micro defaults to exponential notation (Scientific format), ie. 9E-2 instead of the more obviously readable 0.09.

  VDU23,1,0;0;0;0; - turns the cursor off

  ENVELOPE 1,3,0,16,12,1,1,1,126,-10,0,-10,126 - defines a sound envelope for the point scoring sound


1

  S=0 - variable for score in each round set to 0

  C=0 - cumulative score as the rounds progress set to 0

  R=1 - round number initially set to 1

  PRINTTAB(8,14)"Score "STR$C''SPC8"High Score "STR$H% TAB(8,4)"ROUND" - This is a single PRINT statement that prints  'Score', 'High Score' and 'ROUND' plus their variable (except for the round variable for reasons of space).

        'Score' is followed by the cumulative score variable (C) converted to a string (STR$C). This was necessary with all the scores and round numbers to avoid printing them all to two decimal places as was set in line zero with @%=&20209. 'High Score' is followed by the integer variable H% (again converted to a string) which on startup of a BBC Micro (or emulator) will be set to 0. 'ROUND' is then printing further up the page but without the R variable yet as we've reached the 80 character limit for this line.

2

 FOR N=6 TO 12:PRINTTAB(6,N)SPC18 TAB(14,4)STR$R''SPC8:NEXT - This FOR loop prints a space 18 characters long on every text line between lines 6 and 12 to clear the area in the middle of the screen between rounds. It also prints the round number (R) converted to a string (STR$R), it does this 7 times which is of course unnecessary but R had to be included in this FOR loop for reasons of space.

 FOR N=1 TO 1500:NEXT - this FOR loop creates a slight pause before the round commences.


3

 PRINTTAB(8,6)"Train coming"''SPC8"PLAY CHICKEN?"''SPC8"Impact in" - this PRINT statement lays out the play area where the countdown will be happening. It prints 'Train coming' at coordinates (8,6), skips two lines ('') prints a space 8 characters long (SPC8) followed by 'PLAY CHICKEN?' (to which the answer is always YES), does the same again and prints 'Impact in' which will be followed by the countdown timer on the next line.

 TIME=0 - sets the internal timer which counts up in hundreths of a second to 0.

 T=3 - this is the start time which is set to 3 seconds.

Lines 4 and 5 are the main game loop. The program checks to see if 'Y' has been pressed, checks to see if 3 seconds have elapsed, prints the time and then repeats until one of those two conditions have been met. If Y is pressed in time the program jumps ahead to line 7 then 8. If the time runs out it moves to line 6 then 8.

4

 Y=INKEY-69 - tests to see if 'Y' is being pressed

 IF Y=-1 - IF Y is being pressed then E=TIME - the time (in hundreths) of the timer was at when 'Y' was pressed is passed into the variable 'E' here  defined for the first time in the program.

 PRINTTAB(18,10);ABS(T-E/100)''CHR$(130);SPC7; - Prints the time when Y was pressed converted into seconds  in place of the timer which has now stopped. This is to prevent printing errors if the timer overshoots.

E/100 converts the players stopped time to seconds which is subtracted from the initial time (T). ABS converts any negative numbers to positive, again this is to prevent any printing errors and glitches.

 ''CHR$(130) - two text lines are skipped ('') and an invisible character is printed at the beginning of line 14 which turns any text in front of it green for the score routine.

 GOTO7 - goes to line 7 if the condition of 'Y' being pressed is met


5

 IF TIME>300:GOTO6 - timeout, if the time has elapsed (TIME>300) go to line 6.

 ELSE - if not ...

 PRINTTAB(18,10);ABS(T-TIME/100):GOTO4 - prints the time and goes back to line 4.


6

 PRINTTAB(18,10);0 TAB(7,12)CHR$(129)"SQUISH" - prints an invisible red character which overrides the green character from line 4, turning any text red, and the word 'SQUISH' C=0:S=0 - sets the score for this round (S) to 0 and resets any cumulative score (C) to 0.

 SOUND0,-15,2,5 - plays a buzzer from the noise channel of the BBC Micro

 GOTO8 - go to line 8


7

 IF E>=300 GOTO6 - this is too prevent division by 0 errors in the event the player stops the clock at 300, ie. 0 seconds exactly. If this happens the program reverts to line 6 then 8 and the score isn't calculated.

 ELSE - if not ...

 S=10000/(300-E)DIV1 - A score (S) is calculated. Essentially the scoring system is 100 divided by the players  remaining time in seconds. A time of 1 seconds scores 100, 0.1 scores 1000 and 0.01 scores 10000, the  maximum possible per round. Since E is in hundreds the formula is 10000/(300-E). DIV1 rounds this down to the nearest whole number.

 SOUND1,1,80,2 - play a sound on channel 1 using the ENVELOPE defined in line 0.

 PRINT"YOU SCORED "STR$S - prints 'YOU SCORED ' followed by the score converted to a string all in green thanks to the invisible character left at the side of the screen in line 4

8

 C=C+S - score is added to the cumulative score for the five rounds (C)

 R=R+1 - the round number is incremented by 1

 PRINTTAB(14,14)STR$C SPC4 - prints the cumulative score variable C converted to a string followed by 4 spaces  to prevent anything being left on the screen in the event of a 0 score.

 FOR N=1 TO 3000:NEXT - short pause between rounds

 IF R<6 GOTO2 - loops back to line 2 for the next round until five rounds are complete


9

 PRINTTAB(8,18)"END" - when all five rounds are finished the word END appears

 REPEAT UNTIL INKEY(0)=-1:K=GET - this waits until a key is pressed

 IF C>H% H%=C:GOTO0 - if the high score is beaten this is passed to H% and the game restarts at line 0

 ELSE GOTO0 - if not the game restarts with H% unchanged



Published 13 days ago
StatusReleased
AuthorBASIC 10Liner
GenreAction
Tags10liner, 8-Bit, acorn, basic, bbc-micro

Download

Download
Chicken.ssd 23 kB
Download
Chicken_Instructions_and_Description 10 kB
Download
How_to_Start_the_Game 597 bytes

Install instructions

RECOMMENDED EMULATOR: b2 - https://github.com/tom-seddon/b2

How to start the game in b2:

1. Go to File - Disc Image ...

2. Select and open Chicken.ssd

3. CHAIN"C-INSTR" - for Instructions followed by Game

       OR

   LOAD"CHICKEN" - for Game file only - LIST or RUN


RECOMMENDED ONLINE EMULATOR: jsbeeb - https://bbc.xania.org/

How to start the game in jsbeeb:

1. Go to Discs - From examples or local

2. Browse - select Chicken.ssd from local hard drive

3. CHAIN"C-INSTR" - for Instructions followed by Game

       OR

   LOAD"CHICKEN" - for Game file only - LIST or RUN

Comments

Log in with itch.io to leave a comment.

very good