20X2 Games with a 20x4 LCD and Keyboard: Brain game (Simon says)

Jamster

Senior Member
Yes this has been done before...

This is my version of the popular Simon says (which i call Brain Game) unlike the example code suplied by Rev-Ed it uses an LCD which gives it a nicer output in my opinion.

Comments Welcome,

Jamster

__________________________________________

Code:
[SIZE=2];*************************************
;*            Brain Game             *
;*************************************
;*    Sometimes called Simon Says    *
;*************************************[/SIZE]
[SIZE=2];This is a classic game that has been reinvented into many 
;forms, it has fetured in the Lego starwars minigames and 
;has been reencarnated into many different circuits with 
;input ranging from simple buttons to touchscreens.
;The aim is to copy the sequence shown on the LCD and 
;then press the correct keys in the correct order.[/SIZE]
[SIZE=2]
;To play this version you need a 20x4 serial LCD connected 
;to pin B.6 of a PICAXE 20X2 (To simulate goto Options>>
;Simulation>>Simulate Serial LCD with 'serout' commands 
;on output: and change the pin name to B.6), and a keyboard 
;or numpad connected to C.1 and C.2.
;
#picaxe 20X2
;
;The aim is to copy the sequence shown on the LCD and 
;then press the correct keys in the correct order.
;
;
;************************************
;*REVISIONS:                        *
;*~~~~~~~~~~                        *
;*#Created: 5.7.11                  *
;*#Completed: 3.8.11                *
;*                                  *
;************************************
SYMBOL key=b0
SYMBOL correctkey=b1
SYMBOL looper=b2
SYMBOL location=b3
SYMBOL lgtemp=w2
SYMBOL temp1=b6
SYMBOL Score=b7
SYMBOL readtime=w4
location=255
readtime=2000
 gosub add
 
main: gosub add
 
 'Clear Screen
 '~~~~~~~~~~~~
 serout B.6,N2400,(254,1)
 
 'Cover Old Numbers
 '~~~~~~~~~~~~~~~~~
 temp1=location/2                     '\
 temp1=10-temp1                       ' |  set cursor
 temp1=temp1+128                      ' |
 serout B.6,N2400,(254,temp1)         '/
 for looper=0 to location             '\
  serout B.6,N2400,("#")              ' |  Cover
 next looper                          '/
 
 wait 3
 
 'Play routine
 '~~~~~~~~~~~~
 for looper=0 to location  
  get looper,correctkey               'get correct answer
  temp1=location/2                    '\
  temp1=10-temp1                      ' | Move cursor
  temp1=temp1+128+looper              ' |
  serout B.6,N2400,(254,temp1)        '/
  serout B.6,N2400,(#correctkey)      'write answer
  pause readtime                      'give time to read
 next looper
 
 'Cover Numbers
 '~~~~~~~~~~~~~
 temp1=location/2                     '\
 temp1=10-temp1                       ' |  set cursor
 temp1=temp1+128                      ' |
 serout B.6,N2400,(254,temp1)         '/
 for looper=0 to location             '\
  serout B.6,N2400,("#")              ' |  Cover
 next looper                          '/
 
 serout B.6,N2400,(254,192)
 serout B.6,N2400,("Type the numbers:")
 
 'Add "-"s
 '~~~~~~~~
 temp1=location/2                     '\
 temp1=10-temp1                       ' |  set cursor
 temp1=temp1+148                      ' |
 serout B.6,N2400,(254,temp1)         '/
 for looper=0 to location             '\
  serout B.6,N2400,("-")              ' |  Cover
 next looper                          '/
 
 'Get sequence
 '~~~~~~~~~~~~ 
 temp1=location/2                     '\
 temp1=10-temp1                       ' | set cursor
 temp1=temp1+148                      ' |
 serout B.6,N2400,(254,temp1)         '/
 
 for looper=0 to location
  get looper,correctkey               'get correct answer
  kbin key                            'get user input
  read key,key                        'translate user input
  if key<>correctkey then loose       'test if correct
  serout B.6,N2400,(#key)             'out put answer
 next looper
 inc Score                            'increase score
 
 'Reduce Time
 '~~~~~~~~~~~
 if location=6 then 
  readtime=readtime-500
  location=255
  serout B.6,N2400,(254,1)
  serout B.6,N2400,(254,194)
  serout B.6,N2400,("New time to read:")
  serout B.6,N2400,(254,156)
  serout B.6,N2400,(#readtime)
  wait 3
 endif
 
 goto main
 
 'Adds a new number to the game
 '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
add: inc location
 random lgtemp                        'get random number
 key=lgtemp/6553                      'translate
 put location,key                     'store
 return
 
 'Loose routine
 '~~~~~~~~~~~~~
loose:serout B.6,N2400,(254,1)
 serout B.6,N2400,(254,198)
 serout B.6,N2400,("You lose")
 serout B.6,N2400,(254,154)
 serout B.6,N2400,("Score:  ",#Score)
 wait 5
 end
 
EEPROM $45,(0,9)
EEPROM $16,(1)
EEPROM $1E,(2)
EEPROM $25,(4,3)
EEPROM $2E,(5)
EEPROM $36,(6)
EEPROM $3D,(7,8)[/SIZE]
 

Jamster

Senior Member
Oh no... it's just occured to me I've written "loose" instead of "lose"...
I feel so ashamed....:(
Only taken me a year and a quater to notice...
 
Top