home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMOS PD CD
/
amospdcd.iso
/
351-375
/
apd372
/
jason_banks
/
clock.amos
/
clock.amosSourceCode
< prev
next >
Wrap
AMOS Source Code
|
1991-06-13
|
6KB
|
160 lines
'
' RUBIK's CLOCK
'
' Amiga Conversion - Jason D Banks
'
' unfold the docs procedure for some instructions.
'
Dim CFACE(18),SWITCH(4),CHANGES(18) : SIDE=0 : Randomize 1
Global CFACE(),SWITCH(),SIDE,CHANGES(),SD,MZ,DNE
INITSCREEN : INITALL : _DRAWSCREEN : _UPDATE : _UPDATESWITCH
DNE=False : Locate 0,1 : Centre "Complete the clock...."
X=Timer
While Not DNE
Limit Mouse
While Mouse Key<>0 : Wend
While Mouse Key=0 : Wend
If Mouse Zone=13 Then SIDE=SIDE xor 1 : _UPDATE : _UPDATESWITCH
If(Mouse Zone>0) and(Mouse Zone<5) Then SWITCH(Mouse Zone)=SWITCH(Mouse Zone) xor 1 : _UPDATESWITCH
If(Mouse Zone=5) or(Mouse Zone=7) or(Mouse Zone=8) or(Mouse Zone=10) Then MZ=1 Else MZ=-1
If(Mouse Zone=5) or(Mouse Zone=12) Then SWITCH=1
If(Mouse Zone=6) or(Mouse Zone=7) Then SWITCH=2
If(Mouse Zone=8) or(Mouse Zone=9) Then SWITCH=4
If(Mouse Zone=10) or(Mouse Zone=11) Then SWITCH=3
If(Mouse Zone>4) and(Mouse Zone<13) Then On(SWITCH(SWITCH) xor SIDE)+1 Proc UPPER,LOWER
Wend
Cls 0 : Bob Off : Locate 0,4 : Centre "Well Done!!!!!....."
Locate 0,7 : Centre "You completed it!!!!!"
Locate 0,10 : Centre "time taken ="+Str$(Int((Timer-X)/50))+" seconds!"
Procedure LOWER
BLANKCHANGES
If SIDE=1 Then SD=0 Else SD=1
If 1=(SWITCH(1) xor SIDE)
CHANGES(1+SIDE)=MZ
CHANGES(1+SD)=-MZ
CHANGES(3+SD)=-MZ
CHANGES(7+SD)=-MZ
CHANGES(9+SD)=-MZ
End If
If 1=(SWITCH(2) xor SIDE)
CHANGES(3+SD)=-MZ
CHANGES(5+SIDE)=MZ : CHANGES(5+SD)=-MZ
CHANGES(9+SD)=-MZ
CHANGES(11+SD)=-MZ
End If
If 1=(SWITCH(3) xor SIDE)
CHANGES(7+SD)=-MZ
CHANGES(9+SD)=-MZ
CHANGES(13+SIDE)=MZ : CHANGES(13+SD)=-MZ
CHANGES(15+SD)=-MZ
End If
If 1=(SWITCH(4) xor SIDE)
CHANGES(9+SD)=-MZ
CHANGES(11+SD)=-MZ
CHANGES(15+SD)=-MZ
CHANGES(17+SD)=-MZ : CHANGES(17+SIDE)=MZ
End If
For R=1 To 18 : Add CFACE(R),CHANGES(R),1 To 12 : Next R
_UPDATE
End Proc
Procedure BLANKCHANGES
For R=1 To 18 : CHANGES(R)=0 : Next R
End Proc
Procedure UPPER
BLANKCHANGES
If SIDE=1 Then SD=0 Else SD=1
If 0=(SWITCH(1) xor SIDE)
CHANGES(1+SIDE)=MZ : CHANGES(1+SD)=-MZ
CHANGES(3+SIDE)=MZ
CHANGES(7+SIDE)=MZ
CHANGES(9+SIDE)=MZ
End If
If 0=(SWITCH(2) xor SIDE)
CHANGES(3+SIDE)=MZ
CHANGES(5+SIDE)=MZ : CHANGES(5+SD)=-MZ
CHANGES(9+SIDE)=MZ
CHANGES(11+SIDE)=MZ
End If
If 0=(SWITCH(3) xor SIDE)
CHANGES(7+SIDE)=MZ
CHANGES(9+SIDE)=MZ
CHANGES(13+SIDE)=MZ : CHANGES(13+SD)=-MZ
CHANGES(15+SIDE)=MZ
End If
If 0=(SWITCH(4) xor SIDE)
CHANGES(9+SIDE)=MZ
CHANGES(11+SIDE)=MZ
CHANGES(15+SIDE)=MZ
CHANGES(17+SIDE)=MZ : CHANGES(17+SD)=-MZ
End If
For R=1 To 18 : Add CFACE(R),CHANGES(R),1 To 12 : Next R
_UPDATE
End Proc
Procedure INITSCREEN
While Screen>-1 : Screen Close Screen : Wend
Screen Open 0,320,256,16,Lowres : Curs Off : Flash Off : Pen 0 : Paper 1 : Cls : Get Sprite Palette
Reserve Zone 13
Set Zone 1,100,80 To 116,96 : Set Zone 2,160,80 To 176,96
Set Zone 3,100,140 To 116,156 : Set Zone 4,160,140 To 176,156
'
Set Zone 5,50,30 To 66,46 : Set Zone 12,30,50 To 46,66
'
Set Zone 11,30,190 To 46,206 : Set Zone 10,50,210 To 66,226
'
Set Zone 6,204,30 To 220,46 : Set Zone 7,224,50 To 240,66
'
Set Zone 8,224,190 To 240,206 : Set Zone 9,204,210 To 220,226
'
Set Zone 13,260,220 To 300,250
End Proc
Procedure INITALL
For R=1 To 18 : CFACE(R)=Rnd(11)+1 : Next R
FLIP[CFACE(1)] : CFACE(2)=Param
FLIP[CFACE(5)] : CFACE(6)=Param
FLIP[CFACE(13)] : CFACE(14)=Param
FLIP[CFACE(17)] : CFACE(18)=Param
For R=1 To 4 : SWITCH(R)=Rnd(1) : Next R
End Proc
Procedure FLIP[FACEIN]
If(FACEIN=1) or(FACEIN=7)
FACEOUT=FACEIN
Else
FACEOUT=14-FACEIN
End If
End Proc[FACEOUT]
Procedure _DRAWSCREEN
Cls
Paste Bob 30,50,15 : Paste Bob 50,30,15 : Paste Bob 30,190,15 : Paste Bob 50,210,15
Paste Bob 224,50,15 : Paste Bob 204,30,15 : Paste Bob 224,190,15 : Paste Bob 204,210,15
Box 260,220 To 300,250
End Proc
Procedure _UPDATE
Paste Bob 60,50,CFACE(1+SIDE) : Paste Bob 120,50,CFACE(3+SIDE) : Paste Bob 180,50,CFACE(5+SIDE)
Paste Bob 60,110,CFACE(7+SIDE) : Paste Bob 120,110,CFACE(9+SIDE) : Paste Bob 180,110,CFACE(11+SIDE)
Paste Bob 60,170,CFACE(13+SIDE) : Paste Bob 120,170,CFACE(15+SIDE) : Paste Bob 180,170,CFACE(17+SIDE)
COUNT=0 : For R=1 To 18 : COUNT=COUNT+CFACE(R) : Next R : If COUNT=18 Then DNE=True
End Proc
Procedure _UPDATESWITCH
XXX=3 : Rem 3 sprite conversion modifier - it stops the switches looking strange when you toggle them
Bob 1,100,80+XXX*(SWITCH(1) xor SIDE),13+(SWITCH(1) xor SIDE) : Bob 3,160,80+XXX*(SWITCH(2) xor SIDE),13+(SWITCH(2) xor SIDE)
Bob 2,100,140+XXX*(SWITCH(3) xor SIDE),13+(SWITCH(3) xor SIDE) : Bob 4,160,140+XXX*(SWITCH(4) xor SIDE),13+(SWITCH(4) xor SIDE)
End Proc
Procedure _DOCS
' Welcome to the Rubik's Clock Simulator program
' This was set up to imitate a rubiks clock, and allow the player
' to attempt to solve it. I know that the original device (of torture)
' is the only ever rubiks puzzle that I've managed to solve - but what
' the hell, there are people with nobel prizes out there who probally
' are still struggling with the cube!
'
' Ok, so this is the idea of the game. You are trying to get both sides
' of the puzzle to have all of the clock faces pointing to twelve o'clock
' easy huh? well, we'll see about that later! To do this, you can manipulate
' the faces by spinning the four corner pieces. The effect this has varies
' on the position of the 4 buttons of the puzzle. I won't spoil the puzzle
' by explaining everything though - it took me a week to work out what I
' was supposed to actually do with the cube, let alone solve it!....
' (I can't!) One more thing thought, the clock has two sides to it - to get
' at the other side, click on the box in the bottom right corner - the problem
' is that what you do on one side, effects what you do on the other!
End Proc