| BLOCKSIES GAME!!! please check it out!!! 
 
	 
	
		| Author | Message |   
		| Amreen 
 
 
 
 
 | 
			
				|  Posted: Wed Jan 12, 2005 9:10 am    Post subject: BLOCKSIES GAME!!! please check it out!!! |  |   
				| 
 |  
				| Hey Everyone!! listen, im creating a blocksies game and all it is, is the replica of PONG...the object of this game is to move the blocker at the bottom of the screen and make sure it catches the asterisks as they fall from random places on the screen. I want to make the asterisks bounce off the blocker at the bottom of the screen. Please help me out and post ur comments, advice and insturctions on how i can make my program work right. I really do appreciate it and hope that this program is a success. THANX for all who do post!!!!   
 
 
 	  | code: |  	  | 
%This program is what the BLOCKSIES game is going to look like
 %as this is the structure of the game.
 
 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:= "     " % 5 blank spaces
 
 var Key:string (1)
 var Asterisks_Column, Start, Finish:int
 var Blocker_Column:= 38
 var Asterisks_Row:=2
 
 setscreen ("noecho, nocursor")
 % We set the screen because we want to make sure that the user's
 % keystrokes and not displayed and also to hide the cursor
 % while the game is being played. Also, we set up the global vaiables
 % and constants that will be needed in this program.
 
 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
 
 %This will randomly determine the column that each
 %asterisk is going to fall from.
 randomize
 
 %Clock keeps track of the time (in milliseconds) that
 %Turing has been in use.
 clock(Start)
 
 for Asterisk:1..NUMBER_OF_ASTERISKS
 
 locate (1,1)
 put "Asterisk #",Asterisk
 
 
 randint (Asterisks_Column, 2, 79)
 
 loop
 locate (Asterisks_Row, Asterisks_Column)
 put "*"..
 delay (WAIT)
 
 if hasch then
 Move_Blocker
 end if
 
 locate (Asterisks_Row, Asterisks_Column)
 put " "
 
 Asterisks_Row:=Asterisks_Row + 1
 
 if Asterisks_Row > 24 then
 Asterisks_Row:= 2
 end if
 
 if Asterisks_Column >= Blocker_Column and
 Asterisks_Column <= Blocker_Column + 4 and
 Asterisks_Row = 24 then
 sound (100, 100)
 exit
 elsif Asterisks_Row = 24 and
 (Asterisks_Column < Blocker_Column or
 Asterisks_Column > Blocker_Column + 4) then
 sound (100,100)
 end if
 
 end loop
 end for
 
 clock (Finish)
 
 cls
 put "TIME: ", (Finish - Start) / 1000, " Seconds."
 | 
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Sponsor Sponsor
 
  
   |  |   
		|  |   
		| Delos 
 
  
 
 
 | 
			
				|  Posted: Wed Jan 12, 2005 1:17 pm    Post subject: (No subject) |  |   
				| 
 |  
				| 1) 
 is a valid identifier.
 Check out the help file for more details on such terms.
 
 2)
 You're code seems reasonable enough to be upraded a tad...instead of using getch() for your movement, check out what Input.KeyDown() can do for you.
 
 3)
 As for the bounces...
 I suggest that you create a variable that controls the way your change rows...for example, if the * is falling, then its value would be -1, -2, etc...that means that each loop you go through, the row has (-1) or (-2) added to it.  Simple algebra, the resultant number is less than that before it.
 
 	  | code: |  	  | 
var delta : int := -2
 var counter : int := 20
 
 for i : 1..5
 put "The current value is ", counter
 counter += delta
 % Hopefully you're familiar with the '+=' form of writing this.
 % Check http://www.compsci.ca/v2/viewtopic.php?t=4588 if you need some brushing up.
 end for
 
 | 
 
 See what I mean?  Now, once it reaches the bottom of the screen, you can simply change the value of your 'delta' variable to a positive number, so now it will intepret the values as increasing...
 
 It all comes down to thinking of the movement in terms of vectors.
 BTW, here's that link from the code in case you're too lazy to cut and paste (like most of us here
  ) |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| benQ 
 
 
 
 
 | 
			
				|  Posted: Thu Jan 13, 2005 8:53 am    Post subject: Actually.. |  |   
				| 
 |  
				| I tried that because i'm doing the same thing. And it doesn't bounce. Why are you using a counter? |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Delos 
 
  
 
 
 | 
			
				|  Posted: Thu Jan 13, 2005 9:04 am    Post subject: (No subject) |  |   
				| 
 |  
				| The counter in this case would be used in conjunction with the locate()s.  It would basically store which row the * is currently on. |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| benQ 
 
 
 
 
 | 
			
				|  Posted: Thu Jan 13, 2005 4:05 pm    Post subject: Oh |  |   
				| 
 |  
				| But why doesn't the asterisk bounce? Where should I be putting your code in my program? |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Cervantes 
 
  
 
 
 | 
			
				|  Posted: Fri Jan 14, 2005 5:34 pm    Post subject: Re: Oh |  |   
				| 
 |  
				| benQ wrote: Where should I be putting your code in my program? You don't.  That's called plagerism.  Instead, study his code and the things he said that went with it, then rearrange and warp the code to suit your specific code and your specific problem.
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Amreen 
 
 
 
 
 | 
			
				|  Posted: Tue Jan 18, 2005 9:08 am    Post subject: (No subject) |  |   
				| 
 |  
				| ITS NOT PLAGERISM....ITS CALLED I NEED HELP!!!!! |  
				|  |  |   
		|  |  |  
	  
		|  |   
		|  |  
 |