Program name: Qbert!
(v. 1.0)


CTF file name:

qbert.ctf

Author:

Tom Lynn

Date:

19957

Models:

9750, 9850, 9950

Screenshot:

Description:
This is a calc version of the arcade classic, Qbert.
I have tried to make it as fast as possible, but it's still
a bit on the slow side, and there's no snake at the moment.
It does look good though.
In case you don't know the game, the object is to paint every
tile in the pyramid while avoiding getting crushed by the
cascading balls. The TARDISes either side will take you to the
top of the pyramid.
* Before running the program *
Run the program "QBDRAWPY", which draws the pyramid, and then store
it in picture memory 2 by pressing [OPTN][F1][F2]. (You can use other
picture memories if you change the line "RclPict 2" in Prog "~QBERT").
If you haven't got enough free memory, uncomment the marked lines in
Prog "~QBERT", which will make the screen redraw whenever you change
level.
* How to play *
Run "~QBERT". The default keys are 7,4,9 and 6. If you change the keys,
you will be asked to choose keys for Up, Down, Left and Right. On
the pyramid, these correspond to TopLeft, BottomRight, BottomLeft and
TopRight.

Global subroutines:
This game also uses these subroutines from tlgames.ctf:
+GAMEOVR  Draws the "Game Over" screen
GO2 /
+SETKEYS Set up keys
+YESNO Wait for either Y or N to be pressed
+GK Wait for any key to be pressed

Program source code:
Program "~QBERT"
[Main routine]
" ~~~ QBERT! ~~~"
74>U:53>D:73>L:54>R
Prog "+SETKEYS"
0>K:0>T:5>V
Lbl R:'NEW LEVEL
K=>Graph Y>0
K=>Graph Y<0
Isz K
Seq(0,X,1,53,1>List6
'Prog "QBDRAWPY" ; Uncomment this line and
RclVWin 1 ; \ comment these two if you haven't
RclPict 2 ; / got enough space to store the pyramid in Pict 2
For 1>A To V
Text 2+7A,120,"Q"
Next
3>A~B
Prog "QBPAINT"
499>N
1>P
0>E
Lbl 0:'MAIN LOOP
Text 2,107,N(N>0
N<=99=>N>90=>Text 2,115," "
N<=9=>Text 2,111," "
Dsz N:0
Text 6A+6B9,627(BA,"Q"
If E<2+(K>2)+(K>3) And Ran#<=.5.3/K
ThenIsz E
1>List6[44+2E
1>List6[45+2E
IfEnd
If E
ThenFor 1>C To E
Ran#>1/3E=>Prog "QBMOVEME"
List6[44+2C>\r
List6[45+2C>\th
\r+\th1
List6[\th+.5Ans(Ans1
Ans=0=>Text 6\r+6\th9,637(\th\r," "
Ans<>0=>Text 6\r+6\th9,637(\th\r,""
If Ran#<.5
Then1+List6[44+2C>List6[44+2C
Else1+List6[45+2C>List6[45+2C
IfEnd
List6[44+2C>\r
List6[45+2C>\th
If \r+\th>10
ThenDsz E:0
For 1>X To 2E
List6[47+X>List6[45+X
Next
Dsz C:0
ElseText 6\r+6\th9,637(\th\r,"O"
\r=A=>\th=B=>Prog "QBDISC"
IfEnd
Next
IfEnd
Prog "QBMOVEME"
P=0=>Goto R
Goto 0

Program "QBDRAWPY"
[Draws pyramid]
RclVWin 1
For 1>A To 9
For 1>B To A
Plot 577A+14B,696A
Prog "QBDRAWCB"
Next
Next
Lbl 0
'TARDISES
For 0>A To 1
Plot 25+78A,50
For 0>B To 12 Step 9
B=9=>3>B
B<>0
FLine X5Ans,YB,X+55Ans,Y2B
FLine X5+5Ans,Y2B,X+5Ans,YB
Next
For ()5>B To 5 Step 5
62(B<>0
FLine X+B,YAns,X+B,Y7Ans
Next
Next
Text 2,7,"SCORE:"
Text 2,80,"BONUS:"

Program "QBDRAWCB"
[Draws cubes making up pyramid]
FLine X+1,Y1,X+7,Y4
For 3>Z To 4
FLine X+7,Y2Z,X,Y6Z
FLine X,Y6Z,X7,Y2Z
Next
FLine X7,Y4,X,Y

Program "QBPAINT"
[Sets cube as 'painted']
A+B1
B+.5Ans(Ans1
List6[Ans]<>0=>Return
1>List6[Ans
Isz P
T+10K>T
Text 2,32,T
P<45=>Return
T+N>T
0>P
Text 6A+6B9,627(BA,"Q"

Program "QBMOVEME"
[Move Qbert]
GetKey>J
J<>U=>J<>D=>J<>L=>J<>R=>Return
Dsz N:0
Text 6A+6B9,627(BA,""
J=U=>Dsz A:0
J=D=>Isz A
J=L=>Isz B
J=R=>Dsz B:0
A=0 Or B=0 Or A+B>10=>Goto 2
Text 6A+6B9,627(BA,"Q"
If E
ThenFor 1>W To E
A=List6[44+2E] And B=List6[45+2E]=>Prog "QBDISC"
Next
IfEnd
Prog "QBPAINT"
Return
Lbl 2
'OFFPYR
A+B=5=>Goto 3
Prog "QBDIE"
V=0=>Goto Z
Return
Lbl 3
N3>N
For 1>J To 4
Orange PlotChg 24+78(A<>0,48
Orange PlotChg X+1,Y
Orange PlotChg X+1,Y
Next
1>A~B
Prog "QBPAINT"

Program "QBDIE"
[Kill Qbert, end game if dead]
For 1>A To 9
Text 2+7V,120,"Q"
Text 64Y,X," "
Next
3>A~B
Dsz V
Return
Prog "+GAMEOVR"
Stop

Program "QBDISC"
[Kill Qbert with cascading balls]
For 1>H To 3
Text 6A+6B9,627(BA,"Q"
Text 64Y,X," "
Text 64Y,X+1,"O"
Next
Prog "QBDIE"

This page was created by Tom Lynn (tomcalcs@mythicbeasts.com).
This page last updated: Friday, 30 April, 1999
Written in notepad and compiled with
WTA,
for clean, consistent HTML.
Part of the Casio Graphical Calculator Encyclopaedia.
