Moving object problem 
	 
	
		| Author | 
		Message | 
	 
		 
		uknowhoiam
 
 
 
    
		 | 
		
		
			
				  Posted: Thu Feb 19, 2009 9:12 pm    Post subject: Moving object problem  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				k i really need help with this problem....
 
 
So i ask the user for the location of the two objects, and then i put that in the drawfilloval command, but my problem is that the objects start from 0, 0 (both of my objects) and they go off the screen and come back to point 0,0 ,  they just bounce off the corners... heres my code
 
 
	  | Turing: | 	 		  
var x, y, x2, y2  : int
var xpos, ypos, xpos2, ypos2  : int := 1
setscreen ("graphics")
%  if the user does not enter the right value, then this will start again
loop
    put "Please enter starting coordinates x for the FIRST object: " ..
     get x
     if x <  10 then
        put "Your number is too low"
    elsif x >  maxx -  10 then
        put "Your number is too high"
    else
        exit
    end if
end loop
%  if the user does not enter the right value, then this will start again
loop
    put "Please enter starting coordinates y for the FIRST object: " ..
     get y
     if y <  10 then
        put "Your number is too low"
    elsif y >  maxy -  10 then
        put "Your number is too high"
    else
        exit
    end if
end loop
%  if the user does not enter the right value, then this will start again
loop
    put "Please enter starting coordinates x for the SECOND object: " ..
     get x2
     if x2 <  20 then
        put "Your number is too low"
    elsif x2 >  maxx -  20 then
        put "Your number is too high"
    else
        exit
    end if
end loop
%  if the user does not enter the right value, then this will start again
loop
    put "Please enter starting coordinates y for the SECOND object: " ..
     get y2
     if y2 <  20 then
        put "Your number is too low"
    elsif y2 >  maxy -  20 then
        put "Your number is too high"
    else
        exit
    end if
end loop
colourback (20)
cls
loop
    %if the ball is too close to the top or bottom, this will change direction
    if x <  5 or x >=  maxx -  5 then
        xpos  := -xpos
     end if
    if y <  5 or y >=  maxy -  5 then
        ypos  := -ypos
     end if
    %if the star is too close to the top or bottom, this will change direction
    if x2 <  10 or x2 >=  maxx -  10 then
        xpos2  := -xpos2
     end if
    if y2 <  10 or y2 >=  maxy -  10 then
        ypos2  := -ypos2
     end if
    % the star
    drawfillstar (x2, y2,  20,  20,  purple)
    delay (5)
    %drawing over the star
    drawfillstar (x2, y2,  20,  20,  20)
    %the movement of the star
    x2  := x + xpos2
 
    y2  := y + ypos2
     %the ball
    drawfilloval (x, y,  10,  10,  112)
    delay (5)
    %drawing over the ball
    drawfilloval (x, y,  10,  10,  20)
    %the movement of the ball
    x  := x + xpos
 
    y  := x + ypos
 end loop  | 	  
 
 
MOD EDIT: Remember your syntax tags!
 
	  | code: | 	 		  [syntax="Turing"]your code here[/syntax]  | 	 
  | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
		 
		Sponsor Sponsor 
		 
  
		 | 
		
 | 
	 
	 
		  | 
	 
				 
		A.J
 
  
 
    
		 | 
		
		
			
				  Posted: Thu Feb 19, 2009 10:06 pm    Post subject: Re: Moving object problem  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| well, they moved off the screen because you moved them...look at your code | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		 | 
	 
 
	
	
	 
	
	 |