random cirlces,press  buttom and score 
	 
	
		| Author | 
		Message | 
	 
		 
		needhelp101
 
 
 
    
		 | 
		
		
			
				  Posted: Sat Jan 19, 2008 2:51 pm    Post subject: random cirlces,press  buttom and score  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				I am suppose to make a game in which the computer should generate a random sequence of which light(s) to turn on. The program displays the pattern and then expects the user to enter the same pattern using selected keys on the keyboard.
 
 
So far i have the random circles: And i need help on if the users presses the button, he gets a point. and if all lights comes on he loses.
 
 
var light1 : int := 0
 
var light2 : int := 0
 
var light3 : int := 0
 
var light4 : int := 0
 
 
drawoval (180, 200, 20, 20, 41)
 
drawoval (250, 200, 20, 20, green)
 
drawoval (320, 200, 20, 20, 44)
 
drawoval (390, 200, 20, 20, 4)
 
 
loop
 
randomize
 
    light1 := Rand.Int (0, 1)
 
    if light1 = 1 then
 
        drawfilloval (180, 200, 20, 20, 41)
 
 
        light2 := Rand.Int (0, 1)
 
        if light2 = 1 then
 
            drawfilloval (250, 200, 20, 20, green)
 
 
            light3 := Rand.Int (0, 1)
 
            if light3 = 1 then
 
                drawfilloval (320, 200, 20, 20, 44)
 
 
                light4 := Rand.Int (0, 1)
 
                if light4 = 1 then
 
                    drawfilloval (390, 200, 20, 20, 4)
 
 
                end if
 
            end if
 
        end if
 
end if
 
 
    var key : string (1)
 
 
    if hasch then
 
        getch (key)
 
 
        if key = KEY_UP_ARROW then
 
            drawfilloval (180, 200, 20, 20, white)
 
            drawoval (180, 200, 20, 20, 41)
 
            score := score + 1
 
 
        elsif key = KEY_LEFT_ARROW then
 
            drawfilloval (250, 200, 20, 20, white)
 
            drawoval (250, 200, 20, 20, green)
 
 
        elsif key = KEY_RIGHT_ARROW then
 
            drawfilloval (320, 200, 20, 20, white)
 
            drawoval (320, 200, 20, 20, 44)
 
 
        elsif key = KEY_DOWN_ARROW then
 
            drawfilloval (390, 200, 20, 20, white)
 
            drawoval (390, 200, 20, 20, 4)
 
 
        end if
 
    end if | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
		 
		Sponsor Sponsor 
		 
  
		 | 
		
 | 
	 
	 
		  | 
	 
				 
		TopBypass
 
 
 
    
		 | 
		
		
			
				  Posted: Sat Jan 19, 2008 3:37 pm    Post subject: RE:random cirlces,press  buttom and score  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| Well for one you dont have score as a variable so the code wont even work. | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		ericfourfour
 
 
 
    
		 | 
		
		
			
				  Posted: Sat Jan 19, 2008 7:10 pm    Post subject: RE:random cirlces,press  buttom and score  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| I'm guessing he copied his program and missed a bit of the top. Probably, you can add: var score : int := 0 to the top and it will run. | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		 | 
	 
 
	
	
	 
	
	 |