Drawing Program 
	 
	
		| Author | 
		Message | 
	 
		 
		mynameisbob
 
  
 
    
		 | 
		
		
			
				  Posted: Tue May 18, 2004 5:51 pm    Post subject: Drawing Program  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				How do i make it so that the pen does not erase the lines that you already draw?
 
 
	  | code: | 	 		  setscreen ("graphics:640;480")
 
 
var drawx : int := 320
 
var drawy : int := 150
 
var draw : int := 0
 
 
%pictures
 
var penOut : int := Pic.FileNew ("penOut.bmp")
 
var penIn : int := Pic.FileNew ("penIn.bmp")
 
var blank : int := Pic.FileNew ("blank.bmp")
 
 
% The array used to check the keys
 
var keys : array char of boolean
 
 
proc control
 
    if keys (KEY_LEFT_ARROW) then
 
        drawx -= 1
 
    end if
 
    if keys (KEY_UP_ARROW) then
 
        drawy += 1
 
    end if
 
    if keys (KEY_RIGHT_ARROW) then
 
        drawx += 1
 
    end if
 
    if keys (KEY_DOWN_ARROW) then
 
        drawy -= 1
 
    end if
 
    if keys (KEY_CTRL) then
 
        draw := 1
 
    end if
 
    if keys (KEY_ALT) then
 
        draw := 0
 
    end if
 
end control
 
 
 
%-------------------------------------------------------------------------------------------
 
 
setscreen ("offscreenonly")
 
loop
 
    Input.KeyDown (keys)
 
    locatexy (550, 470)
 
    put "x:", drawx, " y:", drawy ..
 
    control
 
    if draw = 0 then
 
        Pic.Draw (penIn, drawx, drawy, picMerge)
 
    elsif draw = 1 then
 
        Pic.Draw (penOut, drawx, drawy, picMerge)
 
        drawdot (drawx-1, drawy-1,black)
 
    end if
 
    delay (3)
 
    View.Update
 
end loop  | 	  
		
	
  
          
					 
	
	
		
	 
	
		|  Description: | 
		
			
		 | 
	 
	
		|  Filesize: | 
		 24.65 KB | 
	 
	
		|  Viewed: | 
		 3163 Time(s) | 
	 
	
		
  
 
  | 
	 
	 
	 
		 
	
	
		
	 
	
		|  Description: | 
		
			
		 | 
	 
	
		|  Filesize: | 
		 24.65 KB | 
	 
	
		|  Viewed: | 
		 3163 Time(s) | 
	 
	
		
  
 
  | 
	 
	 
	 
				
 | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
		 
		Sponsor Sponsor 
		 
  
		 | 
		
 | 
	 
	 
		  | 
	 
				 
		mynameisbob
 
  
 
    
		 | 
		
		
			
				  Posted: Tue May 18, 2004 5:52 pm    Post subject: (No subject)  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| i forgot to add, press CTRL to start drawing
		
 | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		Dan
 
  
 
    
		 | 
		
		
			
				  Posted: Wed May 19, 2004 1:06 pm    Post subject: (No subject)  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				this is not as easy as it used to be to do since sprites where taken away, but since i have been working on remaking i have lreaned a few tricks to get past this.
 
 
what you got to do is save the drawing made by the pen but not the pen b/c it will draw over the drawing.
 
 
I tryed this trick in your code and it worked:
 
 
	  | code: | 	 		  
 
setscreen ("graphics:640;480")
 
 
var drawx : int := 320
 
var drawy : int := 150
 
var draw : int := 0
 
 
%pictures
 
var penOut : int := Pic.FileNew ("penOut.bmp")
 
var penIn : int := Pic.FileNew ("penIn.bmp")
 
var blank : int := Pic.FileNew ("blank.bmp")
 
 
% The array used to check the keys
 
var keys : array char of boolean
 
 
proc control
 
    if keys (KEY_LEFT_ARROW) then
 
        drawx -= 1
 
    end if
 
    if keys (KEY_UP_ARROW) then
 
        drawy += 1
 
    end if
 
    if keys (KEY_RIGHT_ARROW) then
 
        drawx += 1
 
    end if
 
    if keys (KEY_DOWN_ARROW) then
 
        drawy -= 1
 
    end if
 
    if keys (KEY_CTRL) then
 
        draw := 1
 
    end if
 
    if keys (KEY_ALT) then
 
        draw := 0
 
    end if
 
end control
 
 
 
%-------------------------------------------------------------------------------------------
 
 
setscreen ("offscreenonly")
 
var back:int:=Pic.New (0, 0, maxx, maxy)
 
 
loop
 
    Input.KeyDown (keys)
 
    locatexy (550, 470)
 
    put "x:", drawx, " y:", drawy ..
 
    control
 
    
 
    Pic.Draw(back,0,0,picCopy)
 
    if draw = 1 then
 
        drawdot (drawx-1, drawy-1,black)
 
    end if
 
    Pic.Free(back)
 
    back := Pic.New(0,0,maxx,maxy)
 
    
 
    if draw = 0 then
 
        Pic.Draw (penIn, drawx, drawy, picMerge)
 
    elsif draw = 1 then
 
        Pic.Draw (penOut, drawx, drawy, picMerge)
 
        
 
    end if
 
    
 
    delay (3)
 
    View.Update
 
end loop
 
  | 	  
 
 
cool eh? and that is also the basick idea behind sprites.
		
 | 
			 
			
				| Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!  | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		 | 
	 
 
	
	
	 
	
	 |