A downloadable game

10 Line BASIC 

=============

Category : PUR-80 

TITLE    : Flappy bird

PLATFORM : Oric Atmos

LANGUAGE : BASIC 1.1b

AUTHOR   : Rax

VIDEO    :


Code:

0---------1---------2---------3---------4---------5---------6---------7-----78
0PAPER4:INK6:POKE#26A,10:DEFFNR(X)=INT(RND(1)*X):G$=CHR$(8):V=0:IFH<STHENH=S''
1Z$=CHR$(160):A$=Z$+CHR$(162)+CHR$(186):B$=Z$+Z$+Z$+Z$+Z$:S=-1:GOSUB7:C$="  "'
2PLOTX1-5,R+4,G$+"Flappy bird":REPEAT:PLOTX1,R+2,P$(U):U=1-U:K$=KEY$:WAIT15'''
3UNTILK$<>"":G=.3:S=-1:GOSUB7:X=3:Y=12:REPEAT:K$=KEY$:Q=X:W=Y:IFV>0THENU=0''''
4X=X+1:Y=Y+V:IFY<1ORY>27THENY=Y-VELSE:Z=SCRN(X,Y)ORSCRN(X+1,Y):V=V+G:U=1-U''''
5PLOTQ,W,C$:PLOTX,Y,P$(U):IFX>36THENGOSUB7ELSE:IFK$<>""THENV=-1.5:PLAY0,7,2,M'
6UNTILY>24ORZ>128:PING:PLOTX1-4,R+3,CHR$(12)+"Game Over":WAIT200:GOTO0''''''''
7CLS:FORI=1TO26:PLOT2,I,9:NEXT:X1=25+FNR(9)-5:R=FNR(12)+4:FORI=1TOR'''''''''''
8PLOTX1,I,A$:NEXT:FORI=R+7TO26:PLOTX1,I,A$:NEXT:PLOTX1-1,R,B$:PLOTX1-1,R+7,B$'
9S=S+1:?@2,0;"Score:"S,SPC(15)"Hi:"H:M=99:P$(0)="PP":P$(1)="^U":X=3:RETURN''''

0PAPER4:INK6:POKE#26A,10:DEFFNR(X)=INT(RND(1)*X):G$=CHR$(8):V=0:IFH<STHENH=S

PAPER4                                                      - set screen background color to 4 

INK6                                                        - set text/graphics color to 6

POKE#26A,10                                                 - disable blinking cursor and key click sound

DEFFNR(X)=INT(RND(1)*X)                                     - define function FNR that returns random integer from 0 to X-1

G$=CHR$(8)                                                  - graphics control character (standart chars mode) used before printing text

V=0                                                         - initial vertical velocity of the bird

IF H<S THEN H=S                                             - update high score if current score S is greater than H


1Z$=CHR$(160):A$=Z$+CHR$(162)+CHR$(186):B$=Z$+Z$+Z$+Z$+Z$:S=-1:GOSUB7:C$=" "

Z$=CHR$(160)                                                - block character used for drawing pipes

A$=Z$+CHR$(162)+CHR$(186)                                   - pipe body graphics made from 3 characters

B$=Z$+Z$+Z$+Z$+Z$                                           - horizontal pipe cap graphics (five block characters)

S=-1                                                        - reset score (will become 0 after increment later)

GOSUB7                                                      - call subroutine that draws the playfield and a new pipe

C$="  "                                                     - two blank characters used to erase old bird position


2PLOTX1-5,R+4,G$+"Flappy bird":REPEAT:PLOTX1,R+2,P$(U):U=1-U:K$=KEY$:WAIT15

'title screen

PLOT X1-5,R+4,G$+"Flappy bird"                              - print the game title on screen

REPEAT                                                      - wait loop until a key is pressed

PLOT X1,R+2,P$(U)                                       - draw animated bird sprite

U=1-U                                                   - toggle sprite frame (wing animation)

K$=KEY$                                                 - read keyboard input

WAIT15                                                  - short delay


3UNTILK$<>"":G=.3:S=-1:GOSUB7:X=3:Y=12:REPEAT:K$=KEY$:Q=X:W=Y:IFV>0THENU=0

UNTIL K$<>""                                                - exit loop when a key is pressed

G=.3                                                        - gravity constant

S=-1                                                        - reset score

GOSUB7                                                      - draw new pipe and reset screen

X=3                                                         - initial bird X position

Y=12                                                        - initial bird Y position

REPEAT                                                      - main game loop

K$=KEY$                                                 - read keyboard input

Q=X                                                     - store previous X position

W=Y                                                     - store previous Y position

IF V>0 THEN U=0                                         - change sprite if bird is falling

    

    

4X=X+1:Y=Y+V:IFY<1ORY>27THENY=Y-VELSE:Z=SCRN(X,Y)ORSCRN(X+1,Y):V=V+G:U=1-U

    X=X+1                                                   - move bird to the right

    Y=Y+V                                                   - update vertical position using velocity

    IF Y<1 OR Y>27 THEN                                     - if bird leaves screen vertically

        Y=Y-V                                               - restore previous Y position

    ELSE

: - nothing 

    Z=SCRN(X,Y) OR SCRN(X+1,Y)                              - check for collision with pipe

    V=V+G                                                   - apply gravity to velocity

    U=1-U                                                   - toggle bird animation frame

    

    

5PLOTQ,W,C$:PLOTX,Y,P$(U):IFX>36THENGOSUB7ELSE:IFK$<>""THENV=-1.5:PLAY0,7,2,M

    PLOT Q,W,C$                                             - erase old bird position

    PLOT X,Y,P$(U)                                          - draw bird at new position

    IF X>36 THEN                                            - if bird reaches right side of screen

        GOSUB7                                              - generate new pipe and reset scroll area

    ELSE

: - nothing 

IF K$<>"" THEN                                      - if any key is pressed

V=-1.5                                          - give bird upward velocity (flap)

PLAY0,7,2,M                                      - play flap sound

            

            

6UNTILY>24ORZ>128:PING:PLOTX1-4,R+3,G$+"Game Over":WAIT200:GOTO0

UNTIL Y>24 OR Z>128                                         - end game loop if bird hits ground or pipe

PING                                                        - play sound effect

PLOTX1-4,R+3,CHR$(12)+"Game Over"                           - display Game Over message

WAIT200                                                     - delay before restart

GOTO0                                                       - restart game


7CLS:FORI=1TO26:PLOT2,I,9:NEXT:X1=25+FNR(9)-5:R=FNR(12)+4:FORI=1TOR

'Draw playfield

CLS                                                         - clear screen

FOR I=1 TO 26                                               - draw left screen border

PLOT 2,I,9                                              - set alternative chars mode in this line

NEXT

X1=25+FNR(9)-5                                              - random horizontal pipe position

R=FNR(12)+4                                                 - random vertical position of pipe gap

FOR I=1 TO R                                                - draw top pipe section


8PLOTX1,I,A$:NEXT:FORI=R+7TO26:PLOTX1,I,A$:NEXT:PLOTX1-1,R,B$:PLOTX1-1,R+7,B$

PLOT X1,I,A$                                            - draw pipe block

NEXT

FOR I=R+7 TO 26                                             - draw bottom pipe section

PLOT X1,I,A$

NEXT

PLOT X1-1,R,B$                                              - draw upper pipe edge

PLOT X1-1,R+7,B$                                            - draw lower pipe edge


9S=S+1:?@2,0;"Score:"S,SPC(15)"Hi:"H:M=99:P$(0)="PP":P$(1)="^U":X=3:RETURN

S=S+1                                                       - increase score

PRINT @2,0;"Score:"S,SPC(15)"Hi:"H                          - display score and high score

M=99                                                        - sound parameter value

P$(0)="PP"                                                  - first bird sprite frame

P$(1)="^U"                                                  - second bird sprite frame (wing animation)

X=3                                                         - reset bird X position

RETURN                                                      - return from subroutine

Download

Download
flappy10.txt 8.2 kB
Download
FLAPPY10.tap 673 bytes

Install instructions

INSTALLATION INSTRUCTIONS:

1. Download the zip file from here: http://www.petergordon.org.uk/oricutron/files/Oricutron_win32_v12.zip

2. Copy the file FLAPPY10.TAP to the Oric\tapes folder

3. Start the emulator oricutron.exe

4. Type CLOAD"FLAPPY10" and press enter

5. LIST to show the program

6. Type RUN to play the game

Comments

Log in with itch.io to leave a comment.

very good

Very good.  Always great to see Oric games coming out.  I've got a 1 and Atmos :)