Thrust 10 (Oric Atmos) by RAX
About
10 Line BASIC
=============
Category : PUR-80
TITLE : Thrust
PLATFORM : Oric Atmos
LANGUAGE : BASIC 1.1b
AUTHOR : RAX
VIDEO :
CODE:
0---------1---------2---------3---------4---------5---------6---------7-----78 0D$="3;_E+'1)+??E++??'/AE+3[S":FORI=1TO24:T=ASC(MID$(D$,I,1))-35:POKE#B507+I,T 1NEXT:G=.07:H=22:B=34:A$="<+#DVD')#J$L#6$K#Fa'8793;B&^VT#A#D/#\#ZF#8#\DB#a%3B" 2L$=A$+"#_#_SJ&2#`CTR+5)?\V&*":PING:HIRES:POKE#26A,10:E=0:IFL=8THEN?"WIN";:END 3P=0:GOSUB9:PLAY0,7,0,0:FILL200,40,127:FORY=0TO8:LD=ASC(MID$(L$,L*9+1+Y,1))-35 4FORK=0TO5:A=2^K:C=64+((LDANDA)>0)*-63:CURSET16+K*36,Y*H,3:FILLH,6,C:NEXT:NEXT 5M=3:L=L+1:X=120:Y=190:V=-.7:REPEAT:Y=Y+V:V=V+G:K=PEEK(#208):IFK=156THENV=V-.2 6X=X+E:E=E-((K=188)*.3)+((K=172)*.3):SOUND1,7000,(K<>56)*-10:P=34+(E<-1)-(E>1) 7CURSETQ,W,3:CHARB,0,M:M=2:CURSETX,Y,3:CHARP,0,M:Q=X:U=Y+8:W=Y:B=P:IFY<10THEN2 8P=POINT(X,U)ORPOINT(X+5,U)ORPOINT(X+3,Y-1):UNTILP:EXPLODE:F=F+1:IFF=3THENEND' 9IFP=0THEN?" Level:"L+1" -=Thrust=- Ships:"3-F:RETURNELSE:L=L-1:WAIT300:GOTO2RUN
CODE EXPLANATION:
----------------------------
0D$="3;_E+'1)+??E++??'/AE+3[S":FORI=1TO24:T=ASC(MID$(D$,I,1))-35:POKE#B507+I,T
D$="3;_E+'1)+??E++??'/AE+3[S" - chars/sprites data
FORI=1TO24 - change characters loop
T=ASC(MID$(D$,I,1))-35 - get data from D$
POKE#B507+I,T - change line of char/sprite
----------------------------
1NEXT:G=.07:H=22:B=34:A$="<+#DVD')#J$L#6$K#Fa'8793;B&^VT#A#D/#\#ZF#8#\DB#a%3B"
NEXT - next
G=.07 - gravity constant
H=22 - grid height in pixels
B=34 - player character sprite (vertical ship)
A$="<+#DVD')#J$L#6$K#Fa'8793;B&^VT#A#D/#\#ZF#8#\DB#a%3B" - first part of level data
----------------------------
2L$=A$+"#_#_SJ&2#`CTR+5)?\V&*":PING:HIRES:POKE#26A,10:E=0:IFL=8THEN?"WIN";:END
L$=A$+"#_#_SJ&2#`CTR+5)?\V&*" - level data -
PING - litle sound efsect
HIRES - set hires mode
POKE#26A,10 - stop system blinking cursor and the sounds when press a key
E=0 - reset horisontal(E) velosity
IF L=8 THEN - if level == 8 then you have passed all levels successfully. congratulations!
?"WIN";: - print "win"
END - end
----------------------------
3P=0:GOSUB9:PLAY0,7,0,0:FILL200,40,127:FORY=0TO8:LD=ASC(MID$(L$,L*9+1+Y,1))-35
P=0 - if this variable is equal to zero. the game has not started
GOSUB9 - go to print game board texts subroutine (level, ships, game name)
PLAY0,7,0,0 - set the sound chip to generate noises
FILL200,40,127
FORY=0TO8 - print level map loop (vertical)
LD=ASC(MID$(L$,L*9+1+Y,1))-35 - calculate and get char from level data string (level data byte)
----------------------------
4FORK=0TO5:A=2^K:C=64+((LDANDA)>0)*-63:CURSET16+K*36,Y*H,3:FILLH,6,C:NEXT:NEXT
FORK=0TO5 - horizontal loop
A=2^K - calc current bit. this variable will be used for mask
C=64+( (LD AND A) > 0 )*-63 - if the current bit is set ((LD AND A)), and is greater than zero, it means that we have a set white block (c=127) of the level grid or set blank block (c=127)
CURSET16+K*36,Y*H,3 - set hires cursor to current grid block position
FILLH,6,C - fill the field ( 6*6pixels x 22pixels) with the pre-calculated variable C
NEXT - next
NEXT - next
----------------------------
5M=3:L=L+1:X=120:Y=190:V=-.7:REPEAT:Y=Y+V:V=V+G:K=PEEK(#208):IFK=156THENV=V-.2
M=3 - M=3 - mode to show char (sprite) 3 -hidden
L=L+1 - level = level +1
X=120 - player x
Y=190 - player y
V=-.7 - set vertical start velosity
REPEAT - game loop
Y=Y+V - add vertical(V) velosity to Y position
V=V+G - increase the velosity with gravity
K=PEEK(#208) - read key
IF K=156 THEN - if pressed key is "UP" then
V=V-.2 - decrease vertial velosity
----------------------------
6X=X+E:E=E-((K=188)*.3)+((K=172)*.3):SOUND1,7000,(K<>56)*-10:P=34+(E<-1)-(E>1)
X=X+E - add horisontal(E) velosity to player X position
E=E-((K=188)*.3)+((K=172)*.3) - calculates the horizontal velocity depending on whether it is pressed left or right
SOUND 1, 7000, (K<>56)*-10 - makes a sound/noise similar to rocket engines. the third variable shows the volume. if a key is pressed ( k <> 56), then the sound level becomes equal to 10, if not the sound level is equal to 0 (no sound)
P=34+(E<-1)-(E>1) - calculates which sprite to display. if the horizontal acceleration is less than -1 P= 33 (rocket tilted to the left), if it is greater than 1 P=35 (rocket tilted to the right)
----------------------------
7CURSETQ,W,3:CHARB,0,M:M=2:CURSETX,Y,3:CHARP,0,M:Q=X:U=Y+8:W=Y:B=P:IFY<10THEN2
CURSET Q,W,3 - set hires cursor to old player position
CHAR B,0,M - print old player char/sprite in mode M (3- hidden; 2 - XOR)
M=2 - set mode to 2
CURSETX,Y,3 - set hires cursor to new player position
CHARP,0,M - print new player char/sprite in mode M (3- hidden; 2 - XOR)
Q=X - old X pos
U=Y+8 - calc absolute Y pos plus player sprite height
W=Y - old X pos
B=P - set current sprite into B var
IF Y<10 THEN - if Y < 10 then you complete level
GOTO 2 - next level
----------------------------
8P=POINT(X,U)ORPOINT(X+5,U)ORPOINT(X+3,Y-1):UNTILP:EXPLODE:F=F+1:IFF=3THENEND'
P=POINT(X,U) OR POINT(X+5,U) OR POINT(X+3,Y-1) - calculate whether there is a collision. two points are taken from the bottom of the sprite and one (in the middle) from the top. if there is a collision then P=1 and game loop break.
UNTIL P - game loop
EXPLODE - sound of explosion
F=F+1 - increase player attempts
IF F=3 THEN - if F = 3 then you have no more animals
END - end
----------------------------
9IFP=0THEN?" Level:"L+1" -=Thrust=- Ships:"3-F:RETURNELSE:L=L-1:WAIT300:GOTO2
'this line has two purposes. if it is called once in the GOSUB command and P=0 then it will print a game board.
'if P<>0 this means that this line is the same as the previous one and will restart the level at which the player died
IF P=0 THEN - if we need to print out a game board
?" Level:"L+1" -=Thrust=- Ships:"3-F - print
RETURN - return
ELSE
: - nothing
L=L-1 - level = level -1 - we have to subtract one level because after we increased it by 1 on row 5
WAIT300 - wait 3 sec
GOTO2 - goto print level and reset game variables