home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMOS PD CD
/
amospdcd.iso
/
sourcecode
/
demos
/
sonicscramble.amos
/
sonicscramble.amosSourceCode
Wrap
AMOS Source Code
|
1978-01-13
|
17KB
|
614 lines
Screen Open 0,640,256,16,Hires
Flash Off
Load Iff "Sonic-Screen",1
'
' First Reserve some Zones for Buttons & Pad
Reserve Zone 10
Dim NTS(8),SND(4),SZONE(4),SEQ(20)
'
' Here are the Pad Zones
'
Set Zone 1,88,43 To 188,93
Set Zone 2,210,43 To 310,93
Set Zone 3,88,105 To 188,155
Set Zone 4,210,105 To 310,155
'
' Here are the Button Zones
'
Set Zone 5,460,91 To 620,103
Set Zone 6,460,105 To 620,117
Set Zone 7,460,119 To 620,131
Set Zone 8,460,133 To 620,145
Set Zone 9,460,147 To 620,159
Set Zone 10,460,161 To 620,173
'
' Now we create our 8 possible Notes
For I=1 To 8
Read NTS(I)
Next I
Data 1,13,25,37,49,61,73,85
'
' Lets setup our menus
MAKEMENU
On Menu Proc MENU1
' GAME2 is made our default game
Gosub GAME2
' Set two areas for our scores
Paper 3
Pen 12
Locate 10,27
Print "CORRECT"
Pen 6
Locate 34,27
Print " WRONG "
'
' We Wait for a Mouse Click in a Button Zone
Z=0
While(Z=0)
MKEY=0
While(MKEY=0)
MKEY=Mouse Key
On Menu On
Wend
If MKEY=1 Then Z=Mouse Zone
'
' Check if Zone is a Button
If Z>4
' Animate the Selected Button
Z=Z+1
Ink 2
Draw 461,Z*14+18 To 461,Z*14+7
Polyline 460,Z*14+18 To 460,Z*14+7 To 618,Z*14+7
Ink 1
Draw 619,Z*14+8 To 619,Z*14+19
Polyline 620,Z*14+8 To 620,Z*14+19 To 462,Z*14+19
For I=1 To 5
Bell I
Next I
' Wait for Mouse Button to be released
While Mouse Key<>0
MKEY=Mouse Key
Wend
' Then redraw original Button
Ink 1
Draw 461,Z*14+18 To 461,Z*14+7
Polyline 460,Z*14+18 To 460,Z*14+7 To 618,Z*14+7
Ink 2
Draw 619,Z*14+8 To 619,Z*14+19
Polyline 620,Z*14+8 To 620,Z*14+19 To 462,Z*14+19
'
' Now we Do something based on that Button
'
On(Z-5) Gosub GAME1,GAME2,GAME3,GAME,TRYOUT,QUIT
End If
Z=0
Wend
'
'
GAME:
' Clear out any old Scores
WON=0
LOST=0
Pen 0
Locate 10,28
Print " "
Locate 34,28
Print " "
Wait 100
' Create Sequence
SEQUENCE=BEGIN_NOTES
SPEED=BEGIN_TIME
Do
' Do we need to Speed up the game?
'
If SEQUENCE>MOST_NOTES
If SPEED_UP<>0
SPEED=SPEED-SPEED_UP
Else
SEQUENCE=MOST_NOTES
End If
End If
'
For J=1 To ROUND_SIZE
' Clear old sequence
'
For I=1 To SEQUENCE
SEQ(I)=0
Next I
' Get a new random sequence
'
For I=1 To SEQUENCE
S=Rnd(3)+1
SEQ(I)=SND(S)
Next I
'
If LIGHT_UP=1
' Play Sequence and Lightup Pad
'
For I=1 To SEQUENCE
If SEQ(I)=SND(1)
OLDCOL=Colour(5)
Colour 5,$F00
End If
If SEQ(I)=SND(2)
OLDCOL=Colour(8)
Colour 8,$FF0
End If
If SEQ(I)=SND(3)
OLDCOL=Colour(11)
Colour 11,$F0
End If
If SEQ(I)=SND(4)
OLDCOL=Colour(14)
Colour 14,$F
End If
Play 3,SEQ(I),SPEED
If SEQ(I)=SND(1)
Colour 5,OLDCOL
End If
If SEQ(I)=SND(2)
Colour 8,OLDCOL
End If
If SEQ(I)=SND(3)
Colour 11,OLDCOL
End If
If SEQ(I)=SND(4)
Colour 14,OLDCOL
End If
Next I
Else
' Or Play Sequence Only
Volume ,63
For I=1 To SEQUENCE
Play 3,SEQ(I),SPEED
Next I
End If
'
'
' Use Pad to Guess each Note
NOGOOD=0
For I=1 To SEQUENCE
'
' Wait for Mouse Click in Zone
MZONE=0
MKEY=0
While(MZONE=0) or(MKEY<>1)
MKEY=Mouse Key
If MKEY=1
MZONE=Mouse Zone
End If
Wend
If MZONE=10
' You've Pushed The QUIT Button
Z=11
Ink 2
Draw 461,Z*14+18 To 461,Z*14+7
Polyline 460,Z*14+18 To 460,Z*14+7 To 618,Z*14+7
Ink 1
Draw 619,Z*14+8 To 619,Z*14+19
Polyline 620,Z*14+8 To 620,Z*14+19 To 462,Z*14+19
For I=1 To 5
Bell I
Next I
While Mouse Key<>0
MKEY=Mouse Key
Wend
Ink 1
Draw 461,Z*14+18 To 461,Z*14+7
Polyline 460,Z*14+18 To 460,Z*14+7 To 618,Z*14+7
Ink 2
Draw 619,Z*14+8 To 619,Z*14+19
Polyline 620,Z*14+8 To 620,Z*14+19 To 462,Z*14+19
'
' Let's Exit the For-Next Loop nicely
I=SEQUENCE
Goto LEAVE1
End If
' You've Clicked in a Pad Zone
' Let's Light it up and Play it
If MZONE=1
OLDCOL=Colour(5)
Colour 5,$F00
End If
If MZONE=2
OLDCOL=Colour(8)
Colour 8,$FF0
End If
If MZONE=3
OLDCOL=Colour(11)
Colour 11,$F0
End If
If MZONE=4
OLDCOL=Colour(14)
Colour 14,$F
End If
Play 3,SND(SZONE(MZONE)),20
If MZONE=1
Colour 5,OLDCOL
End If
If MZONE=2
Colour 8,OLDCOL
End If
If MZONE=3
Colour 11,OLDCOL
End If
If MZONE=4
Colour 14,OLDCOL
End If
' But was it the Wrong Note?
'
If SEQ(I)<>SND(SZONE(MZONE))
NOGOOD=1
End If
' Go back for the next Note?
LEAVE1:
Next I
'
' If you pressed Quit earlier we will
' continue leaving the For-Next Loop nicely
If MZONE=10
J=ROUND_SIZE
Goto LEAVE2
End If
' Or we will Add one to the Correct Score
If NOGOOD=0
Inc WON
Pen 12
S$=Str$(WON)
Locate 14-(Len(S$)-1),28
Print WON
Locate 22,27
Print "CORRECT"
Else
' Or we will Add one to the Wrong Score
Inc LOST
Pen 6
S$=Str$(LOST)
Locate 38-(Len(S$)-1),28
Print LOST
Locate 22,27
Print " WRONG "
End If
'
Wait 50
Locate 21,27
Print " "
' Clear out any stored mouse clicks
LEAVE2:
While MKEY=1
MKEY=Mouse Key
Wend
' Go back for another sequence?
Next J
' If QUIT was pressed earlier we will
' now Exit the Do-Loop Loop
If MZONE=10
Exit
End If
' Add another note to the sequence
Inc SEQUENCE
' NOW let's go back for another sequence
Loop
' Or we can start from the beginning again
' and maybe change some things
Return
'
' --- SUBROUTINES START HERE ---
'
' Setup the Game you want to play
GAME1:
BEGIN_NOTES=3
MOST_NOTES=3
ROUND_SIZE=500
BEGIN_TIME=50
SPEED_UP=0
LIGHT_UP=1
STD_TONES=1
STD_PAD=1
Gosub SETUP
Return
'
GAME2:
BEGIN_NOTES=3
MOST_NOTES=7
ROUND_SIZE=4
BEGIN_TIME=50
SPEED_UP=0
LIGHT_UP=1
STD_TONES=1
STD_PAD=1
Gosub SETUP
Return
'
GAME3:
BEGIN_NOTES=3
MOST_NOTES=7
ROUND_SIZE=4
BEGIN_TIME=50
SPEED_UP=2
LIGHT_UP=0
STD_TONES=0
STD_PAD=0
Gosub SETUP
Return
'
' Sample the Game Pad before playing
TRYOUT:
LEAVE=0
Repeat
' Wait for Mouse Click in Pad Zone
MZONE=0
MKEY=0
While(MZONE=0) or(MKEY<>1)
MKEY=Mouse Key
If MKEY=1
MZONE=Mouse Zone
End If
On Menu On
Wend
' Check if Zone is Pad
If MZONE<5
' Light up the Pad
If MZONE=1
OLDCOL=Colour(5)
Colour 5,$F00
End If
If MZONE=2
OLDCOL=Colour(8)
Colour 8,$FF0
End If
If MZONE=3
OLDCOL=Colour(11)
Colour 11,$F0
End If
If MZONE=4
OLDCOL=Colour(14)
Colour 14,$F
End If
'
' Play the Note for this Pad
'
Play 3,SND(SZONE(MZONE)),20
'
' Return Pad to original Colour
If MZONE=1
Colour 5,OLDCOL
End If
If MZONE=2
Colour 8,OLDCOL
End If
If MZONE=3
Colour 11,OLDCOL
End If
If MZONE=4
Colour 14,OLDCOL
End If
End If
' If Zone wasn't Pad check for QUIT
If MZONE=10
LEAVE=1
' You Pushed The QUIT Button
Z=11
Ink 2
Draw 461,Z*14+18 To 461,Z*14+7
Polyline 460,Z*14+18 To 460,Z*14+7 To 618,Z*14+7
Ink 1
Draw 619,Z*14+8 To 619,Z*14+19
Polyline 620,Z*14+8 To 620,Z*14+19 To 462,Z*14+19
For I=1 To 5
Bell I
Next I
While Mouse Key<>0
MKEY=Mouse Key
Wend
Ink 1
Draw 461,Z*14+18 To 461,Z*14+7
Polyline 460,Z*14+18 To 460,Z*14+7 To 618,Z*14+7
Ink 2
Draw 619,Z*14+8 To 619,Z*14+19
Polyline 620,Z*14+8 To 620,Z*14+19 To 462,Z*14+19
End If
Until LEAVE=1
' We have finished Sampling the Pad
Return
' We are leaving the program
QUIT:
End
Return
'
'
SETUP:
For I=1 To 4
SZONE(I)=0
Next I
'
If STD_TONES=1
' Get Standard Notes
SND(1)=NTS(1)
SND(2)=NTS(3)
SND(3)=NTS(5)
SND(4)=NTS(7)
Else
' Get Random Notes
For I=1 To 4
SND(I)=0
Next I
For I=1 To 4
Repeat
NOGOOD=0
PICK=Rnd(7)+1
If I=1
SND(I)=NTS(PICK)
Else
For J=1 To I-1
If SND(J)=NTS(PICK)
NOGOOD=1
End If
Next J
End If
Until NOGOOD=0
SND(I)=NTS(PICK)
Next I
End If
' Now sort the random notes
Repeat
NOGOOD=0
For I=1 To 3
If SND(I)>SND(I+1)
Swap SND(I),SND(I+1)
NOGOOD=1
End If
Next I
Until NOGOOD=0
'
'
If STD_PAD=1
' Assign Standard Pad
For I=1 To 4
SZONE(I)=I
Next I
Else
' Assign Random Pad
CYCLE=1
While CYCLE<5
S=Rnd(3)+1
If SZONE(S)=0
SZONE(S)=CYCLE
Inc CYCLE
End If
Wend
End If
Return
' --- PROCEDURES ARE HERE ---
Procedure MAKEMENU
Paper 0
Pen 0
Print At(0,0);" ";
Paper 7
Pen 2
Menu$(1)=" Game "
Menu$(1,1)=" About "
Menu$(1,2)=" Help "
Menu$(1,3)=" Quit "
Menu$(1,1,1)=" Sonic- " : Menu Inactive(1,1,1)
Menu$(1,1,2)=" Scramble " : Menu Inactive(1,1,2)
Menu$(1,1,3)=" v1.0 " : Menu Inactive(1,1,3)
Menu$(1,1,4)=" " : Menu Inactive(1,1,4)
Menu$(1,1,5)=" Written by " : Menu Inactive(1,1,5)
Menu$(1,1,6)=" Garry Dan " : Menu Inactive(1,1,6)
Menu$(1,1,7)=" 1993 " : Menu Inactive(1,1,7)
Menu On
End Proc
Procedure MENU1
Bell
If Choice(2)=2
Screen To Front 0
Screen 0
Get Palette 1
Paper 3
Pen 15
Restore
Cls
Data "GENERAL OPERATION."
Data " "
Data "The game is fairly straight foreward. Four notes are assigned to the game pad,"
Data "then a sequence of notes is played and by clicking on the pad with the mouse"
Data "you try to duplicate that sequence. Simple eh?"
Data " "
Data "The buttons GAME1, GAME2 & GAME3 allow you to select one of three variations"
Data "which you pre-define in the code (more later). PLAY starts your selected game"
Data "and after a slight pause the first sequence will be played. SAMPLE allows you"
Data "to click on the pad and listen to the different notes before playing a game."
Data "This is needed if either Random Notes or Random Pad are active (more later)."
Data "QUIT is used to exit from SAMPLE, to exit from the current GAME or leave the"
Data "PROGRAM. The QUIT option from the pull down menu will always quit the program."
Data " "
Data "So, the usual sequence of events will be:"
Data " "
Data " 1 - Select the GAME to play"
Data " 2 - If necessary SAMPLE to learn what notes are assigned to the pad."
Data " 3 - If necessary QUIT after sampling the new pad."
Data " 4 - PLAY the game."
Data " 5 - QUIT when finished."
Data " 6 - Select another GAME or QUIT to leave program."
Data " "
Data " "
Data " "
Data " "
Data " "
Data "CHANGING CODE FOR GAMES"
Data " "
Data "The program contains three subroutines GAME1, GAME2 & GAME3 which contain the"
Data "settings for the three games. The program will use GAME2 as it's default game"
Data "when it first loads up. Line 35 - Gosub GAME2"
Data " "
Data "You can alter any of the following variables to design the games that best"
Data "suit your needs. The subroutines begin at line 299."
Data " "
Data " BEGIN_NOTES = The number of notes in the first sequence."
Data " MOST_NOTES = The maximum number of notes possible in a sequence."
Data " ROUND_SIZE = The number of turns before any change in notes or time."
Data " BEGIN_TIME = The length of time between notes in the first sequence."
Data " SPEED_UP = The amount of time deducted at each time change."
Data " LIGHT_UP = Does the pad light up when playing the sequence."
Data " STD_TONES = Use the 4 standard tones (or a random set from a possible 8)."
Data " STD_PAD = Assign notes from lowest to highest (or random layout on pad)."
Data " "
Data "With the last three settings a 0 = NO and a 1 = YES."
Data " "
Data "You could also alter the IFF screen (a file called Sonic-Screen) so instead of"
Data "having GAME1 etc. on each button, there could be personal names or difficulty"
Data "ratings."
Data " "
Data " "
Data " "
Data " "
Data "POSSIBLE VARIATIONS"
Data " "
Data "At present the game simply keeps track of the number of correct and incorrect"
Data "guesses, and continues playing until you quit. So, the first thing you could"
Data "consider is a scoring system with a difficulty factor and some predefined end"
Data "to the game. Another option would be a multi-player game where ROUND_SIZE will"
Data "decrement with each wrong guess and the incorrect player drops out, thus a"
Data "round of 4 players would decrease to 3 at the first wrong guess, and so on."
Data "You could also then allow the players to enter their names at the beginning of"
Data "the game and the program could keep track of who's turn it is. People with an"
Data "interest in music may find the 8 note range too easy and would rather a 16"
Data "note range, or more."
Data " "
Data "The trouble with this sort of game is in fact the large number of possible"
Data "variations, but what is challenging for an adult is impossible for a 5 year"
Data "old and what a 5 year old will play all day, no one else would play twice. So"
Data "I decided that the best thing would be to provide a basic game with routines"
Data "that could be altered to suit anybody. I have tried to keep the code as plain"
Data "as possible with lots of REMs. The game screen is loaded from disk, rather"
Data "than being unpacked from a bank, so that it can be modified. The button code"
Data "is in 'long hand' so that the routine for each button can be followed (see my"
Data "program MATRIX MANIA for the same routine done as a procedure). As already"
Data "mentioned, the subroutines for the 3 games settings can be easily altered for"
Data "different styles of game without the need to understand any of the main code."
Data "The worst that can happen if you enter a strange value is a sulking program,"
Data "but then failure can also be a learning experience. If you turn this program"
Data "into something sensible don't forget to send it to the AMOS PD Library."
For J=1 To 3
For I=1 To 27
Locate 1,I
Read A$
Print A$
Next I
MKEY=0
While MKEY=0
MKEY=Mouse Key
Wend
Cls
Next J
Screen To Front 1
Screen 1
End If
If Choice(2)=3
End
End If
Menu On
End Proc