Results 1 to 5 of 5
  1. #1
    benjamin is offline Member
    Join Date
    Jun 2010
    Posts
    3
    Rep Power
    0

    Default moving a pic, another pic disappears

    hi guys, i'm really new to java, and i had to make a driving sim for school.

    Java Code:
    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    
    
    
    public class RijSimAls extends Applet implements Runnable {
    		Image plaatje;
    		Image Weg;
    		Image strepen;
    		int x_pos = 0;
    		int y_pos = 400;
    		
      
      public void init () {
    	   }
      
      public void start ()
    	{
    		
    		Thread th = new Thread (this);
    		th.start ();
    	}
    
    	public void stop()
    	{
    
    	}
    
    	public void destroy()
    	{
    
    	}
    
    	public void run ()
    	{
    		
    		Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
    
    		
    		while (true)
    		{
    			
    			y_pos ++;
    
    			
    			repaint();
    
    			try
    			{
    				
    				Thread.sleep (20);
    			}
    			catch (InterruptedException ex)
    			{
    				
    			}
    
    			
    			Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
    		}
    	}
      
      public void paint( Graphics g ) {
    	  //grass
    	  g.setColor( Color.green);
    	  g.fillRect(0, 0, 1280, 800);
    	  //sky
    	  g.setColor( Color.blue);
    	  g.fillRect(0, 0, 1280, 400);
    	  //road
    	  Weg = getImage(getCodeBase(), "weg.gif" );
    	  g.drawImage( Weg, 0, 400, 1280, 400, this);
    	  //moving stripes
    	  strepen = getImage(getCodeBase(), "strepen.gif" );
    	  g.drawImage( strepen, x_pos, y_pos, 1280, 400, this);
    	  //car
    	  plaatje = getImage(getCodeBase(), "blub.gif" );
    	  g.drawImage(plaatje, 0, 0, 1280, 800, this);
    	 	
      }
      
    }
    RijSimAls means driving sim in dutch
    thanks in advance :)
    Last edited by benjamin; 06-16-2010 at 07:56 PM. Reason: not solved

  2. #2
    dinosoep is offline Senior Member
    Join Date
    Nov 2009
    Posts
    150
    Rep Power
    6

    Default

    wat is je probleem, welke pic verdwijnt, welke wordt wel getekend,...

  3. #3
    benjamin is offline Member
    Join Date
    Jun 2010
    Posts
    3
    Rep Power
    0

    Default

    ok de auto verdwijnt en de weg flikkert.

  4. #4
    dinosoep is offline Senior Member
    Join Date
    Nov 2009
    Posts
    150
    Rep Power
    6

    Default

    //car
    plaatje = getImage(getCodeBase(), "blub.gif" );
    g.drawImage(plaatje, 0, 0, 1280, 800, this);
    snap ik niet.
    je tekent dus blub over heel uw panel heen?
    en dat flikkeren weet ik wel hoe het komt.
    zoek eens wat op over double buffered painting

  5. #5
    benjamin is offline Member
    Join Date
    Jun 2010
    Posts
    3
    Rep Power
    0

    Default

    blub is de auto van binnen, wat je dus ziet is zeg maar het stuur, alsof je in een auto zit. en bedankt, ik ben echt heel erg een noob met dit :P

Similar Threads

  1. JLabel icon disappears
    By grease_monkey1986 in forum AWT / Swing
    Replies: 3
    Last Post: 05-09-2010, 01:43 PM
  2. moving a file
    By swati.jyoti in forum New To Java
    Replies: 8
    Last Post: 11-23-2009, 09:44 AM
  3. Replies: 11
    Last Post: 10-27-2009, 08:55 AM
  4. Moving Box
    By anilanar in forum New To Java
    Replies: 2
    Last Post: 08-30-2009, 01:29 PM
  5. text box disappears
    By okabeer in forum NetBeans
    Replies: 2
    Last Post: 07-13-2009, 07:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •