Blocksies Game for Summative 
	 
	
		| Author | 
		Message | 
	 
		 
		benQ
 
 
 
    
		 | 
		
		
			
				  Posted: Fri Jan 07, 2005 8:15 pm    Post subject: Blocksies Game for Summative  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				Hey this is my code for my blocksies game. I need an expert to help me figure out what's wrong with it.    I can't figure out what's wrong with it. So any help is appreciated! Thanks! 
 
 
 
	  | code: | 	 		  
 
%%%%%%%%%%%%%%%%%
 
%%  BLOCKSIES  %%
 
%%%%%%%%%%%%%%%%%
 
 
setscreen ("noecho, nocursor")
 
 
const BLOCKER:=
 
    chr(220)+chr(220)+chr(220)+chr(220)+chr(220)
 
const WAIT:= 125
 
const NUMBER_OF_ASTERISKS:=10
 
const LEFT_ARROW:= chr(203)
 
const RIGHT_ARROW:= chr(205)
 
const HOME:= chr(199)
 
const END:= chr(207)
 
const BLOCKER_ROW:= 24
 
const BLANK_BLOCKER:= "     "
 
 
var Key: string (1)
 
var Asterisk_Column, Start, Finish: int
 
var Blocker_Column:= 38
 
var Asterisk_Row:= 2
 
 
procedure Move_Blocker
 
 
    getch (Key)
 
 
    locate (BLOCKER_ROW, Blocker_Column)
 
    put BLANK_BLOCKER
 
    
 
    if Key= RIGHT_ARROW then
 
        Blocker_Column:= Blocker_Column+2
 
    elsif Key= LEFT_ARROW then
 
        Blocker_Column:= Blocker_Column-2
 
    elsif Key= HOME then
 
        Blocker_Column:= 2
 
    elsif Key= END then
 
        Blocker_Column:= 75
 
    end if
 
    
 
    if Blocker_Column> 75 then
 
        Blocker_Column:= 75
 
    elsif Blocker_Column< 2 then
 
        Blocker_Column:= 2
 
    end if
 
    locate (BLOCKER_ROW, Blocker_Column)
 
    put BLOCKER
 
    
 
end Move_Blocker   
 
 
randomize
 
 
clock(Start)
 
 
for Asterisk: 1..NUMBER_OF_ASTERISKS
 
 
locate(1,1)
 
put "Asterisk #", Asterisk
 
 
randint (Asterisk_Column,2,79)
 
 
loop
 
    locate (Asterisk_Row, Asterisk_Column)
 
    put "*"..
 
    delay (WAIT)
 
    
 
    if hasch then
 
        Move_Blocker
 
    end if
 
 
    locate (Asterisk_Row, Asterisk_Column)
 
    put " "
 
 
    Asterisk_Row:= Asterisk+1
 
 
    if Asterisk_Row>24 then
 
        Asterisk_Row:=2
 
    end if
 
    
 
    if Asterisk_Column >= Blocker_Column and 
 
        Asterisk_Column <= Blocker_Column+4 and
 
        Asterisk_Row= 24 then
 
        sound (1000,100)
 
        exit
 
    elsif Asterisk_Row= 24 and
 
        (Asterisk_Column< Blocker_Column or
 
        Asterisk_Column > Blocker_Column+4) then
 
   end if
 
   end loop
 
end for
 
 
clock (Finish)
 
 
cls
 
put "TIME: ", (Finish-Start)/1000, " Seconds"
 
  | 	 
  | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
		 
		Sponsor Sponsor 
		 
  
		 | 
		
 | 
	 
	 
		  | 
	 
				 
		cool dude
 
  
 
    
		 | 
		
		
			
				  Posted: Fri Jan 07, 2005 8:55 pm    Post subject: (No subject)  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| wat r u trying to do with this. be more specific on wat u need help with becuase we don't know wat u r trying to make and have trouble with | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		Cervantes
 
  
 
    
		 | 
		
		
			
				  Posted: Sat Jan 08, 2005 10:18 am    Post subject: (No subject)  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				I don't understand what you are trying to do with your program.  Are the asterisks supposed to "fall" towards the bottom of the screen and the player has to block them?  
 
In any case, I would recommend using Input.KeyDown for movement, instead of getch. | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		benQ
 
 
 
    
		 | 
		
		
			
				  Posted: Sat Jan 08, 2005 3:08 pm    Post subject: Blocksies  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| Ya. I need to make the asterisk fall to the bottom of the screen and the Blocker has to move to block it. It also needs to bounce off the blocker. | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		Cervantes
 
  
 
    
		 | 
		
		
			
				  Posted: Sat Jan 08, 2005 6:33 pm    Post subject: (No subject)  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				Okay.  Well, I don't see any errors with your program.  I don't see any bugs. I just see an unfinished program.  Keep working on it    If you have a specific question, feel free to ask! | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		benQ
 
 
 
    
		 | 
		
		
			
				  Posted: Thu Jan 13, 2005 9:28 am    Post subject: Alright  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				Alright, here's my finished program. I'm such a newbie and I have no clue how to make the walls and the blocker be bouncy so that the asterisk can bounce around. The only way to get a new asterisk would be if the asterisk passes the blocker and goes past the bottom of the screen. Do you know how to make the asterisk bounce off the 3 walls and the blocker? Help is greatly appreciated.
 
 
	  | code: | 	 		  
 
%%%%%%%%%%%%%%%%%%%%%%%%%
 
%%%%%%%%%%%%%%%%%%%%%%%%%
 
%% BLOCKSIES SUMMATIVE %%   
 
%%%%%%%%%%%%%%%%%%%%%%%%%
 
%%%%%%%%%%%%%%%%%%%%%%%%%
 
 
% This plays music. %
 
process playstuff
 
    loop
 
        play ("decdbcabebbdeacgabcefgabcgdbegdbcgabdgcbegdec")
 
        delay (500)
 
        play ("cdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabc")
 
        delay (500)
 
    end loop
 
end playstuff
 
 
fork playstuff %fork it to play music%
 
 
% This is a program that lets you use the arrow keys to control the blocker.%
 
% The object is to block ten asterisks.%
 
 
const BLOCKER :=
 
    chr(220)+chr(220)+chr(220)+chr(220)+chr(220)
 
const WAIT := 125
 
const NUMBER_OF_ASTERISKS := 10
 
const LEFT_ARROW := chr(203)
 
const RIGHT_ARROW := chr(205)
 
const HOME := chr(199)
 
const END := chr(207)
 
const BLOCKER_ROW := 24
 
const BLANK_BLOCKER := "     "
 
 
var Key : string (1)
 
var Asterisk_Column, Start, Finish : int
 
var Blocker_Column := 38
 
var Asterisk_Row := 2
 
 
setscreen ("noecho,nocursor")
 
 
 
procedure Move_Blocker
 
    %We wait for the user to press a key.%
 
    getch (Key)
 
 
    %We erase a previously positioned blocker.%
 
    locate (BLOCKER_ROW, Blocker_Column)
 
    put BLANK_BLOCKER
 
 
    %We adjust the position of the blocker%
 
    %according to the direction specified%
 
    %by the user.%
 
    if Key = RIGHT_ARROW then
 
        Blocker_Column := Blocker_Column + 2
 
    elsif Key = LEFT_ARROW then
 
        Blocker_Column := Blocker_Column - 2
 
    elsif Key = HOME then
 
        Blocker_Column := 2
 
    elsif Key = END then
 
        Blocker_Column := 75
 
    end if
 
 
    %We do not allow the blocker to be moved%
 
    %Beyond the borders of the screen%
 
 
    if Blocker_Column > 75 then
 
        Blocker_Column := 75
 
    elsif Blocker_Column < 2 then
 
        Blocker_Column := 2
 
    end if
 
 
    %The blocker is displayed on the screen.%
 
 
    locate (BLOCKER_ROW, Blocker_Column)
 
    put BLOCKER
 
 
end Move_Blocker
 
 
locate (BLOCKER_ROW, Blocker_Column)
 
put BLOCKER
 
 
randomize
 
 
clock (Start)
 
 
for Asterisk : 1 .. NUMBER_OF_ASTERISKS
 
    locate (1, 1)
 
    put "Asterisk #", Asterisk
 
    randint (Asterisk_Column,2,79)
 
 
    loop
 
        locate (Asterisk_Row, Asterisk_Column)
 
        put "*"
 
        delay (100)
 
 
        if hasch then
 
            Move_Blocker
 
        end if
 
 
        locate (Asterisk_Row, Asterisk_Column)
 
        put " "
 
 
        Asterisk_Row := Asterisk_Row + 1
 
 
        if Asterisk_Row > 24 then
 
            Asterisk_Row := 2
 
        end if
 
 
        if Asterisk_Column >= Blocker_Column and
 
                Asterisk_Column <= Blocker_Column + 4 and
 
                Asterisk_Row = 24 then
 
            sound (100, 100)
 
            exit
 
        elsif Asterisk_Row=24 and
 
            (Asterisk_Column<Blocker_Column or
 
            Asterisk_Column>Blocker_Column+4) then
 
            sound (100,100)
 
        end if
 
    end loop
 
end for
 
 
% After this for loop, the clock stops and the time is displayed.% 
 
 
clock (Finish)
 
 
cls
 
put "Time: ", (Finish - Start) / 1000, " Seconds."
 
 
  | 	 
  | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		 | 
	 
 
	
	
	 
	
	 |