angellove40 0 Newbie Poster

I m in SE Comp Engg need help in SCR
As I've Drawn ,I want that when my sun goes outside the screen ,the background behind mountains should turn black with stars .
Also while sun moves up,man should also move in x-direction and go outside applet.

import java.awt.*;
import java.applet.*;
public class village extends Applet implements Runnable
{
int x_pos=270;
int y_pos=85;
int radius=22;
private Image nimage;
private Graphics ngraph;
Color c1=new Color(200,100,30);
public void init()
{
}
public void start()
{
Thread t=new Thread(this);
t.start();
}

public void run()
{
while (y_pos>-50)
{
	y_pos-=2;
	x_pos++;
	repaint();
	try
	{
		Thread.sleep (300);
	}
	catch (InterruptedException ex)
	{}
}
}
public void update(Graphics g)
{
if(nimage==null)
{
nimage=createImage(this.getSize().width,this.getSize().height);
ngraph=nimage.getGraphics();
}
ngraph.setColor(getBackground());
ngraph.fillRect(0, 0, this.getSize().width, this.getSize().height);
ngraph.setColor (getForeground()); 
	paint (ngraph); 
g.drawImage (nimage, 0, 0, this);
}
public void paint(Graphics g)
{
int x1[]={0,150,300,0};
int y1[]={160,10,160,160};
int n1=4;
int x2[]={285,435,640,299};
int y2[]={144,10,160,160};
int n2=4;
int x3[]={620,820,1000,638};				
int y3[]={144,10,160,160};
int n3=4;
int x4[]={700,746,795,700};			// House Triangle	
int y4[]={400,300,400,400};
int n4=4;
int x5[]={746,865,907,795};			//House upper polygon
int y5[]={300,300,400,400};
int n5=4;
int l1=759;int l2=300;int l3=806;int l4=400;		//Line Draw Over house
//Mountains
g.setColor(c1);
g.fillPolygon(x1,y1,n1) ;//First Mountain
g.fillPolygon(x2,y2,n2) ;//2nd Mountain
g.fillPolygon(x3,y3,n3) ;//3rd Mountain
g.setColor(Color.yellow);
g.fillOval(x_pos,y_pos,2 * radius, 2 * radius);
g.setColor(Color.orange);
g.drawOval(x_pos,y_pos,2 * radius, 2 * radius);// SUN

//House
g.drawRect(700,400,95,85);
g.drawPolygon(x4,y4,n4);
g.drawPolygon(x5,y5,n5);
g.setColor(Color.black);
g.drawLine(795,485,907,485);
g.drawLine(907,400,907,485);
g.drawOval(730,350,25,25);
for(int i=0;i<8;i++)
{
g.drawLine(l1,l2,l3,l4);
l1+=13; l3+=13; 
}
g.drawRect(810,420,22,22); 				//1st Window
g.drawRect(872,420,22,22);				// 2nd Window
g.drawRect(735,440,18,45);				// Door of House

//Man
g.drawOval(600,410,52,52);				//head
g.drawOval(608,421,8,8);				//1st Eye
g.drawOval(628,421,8,8);				//2nd Eye
g.drawOval(620,435,6,6);				//Nose
g.drawOval(613,446,22,8);				//Mouth
g.drawLine(628,462,631,525);				//Body
g.drawLine(592,565,631,525);				// L Leg
g.drawLine(656,565,631,525);				// R Leg
g.drawLine(600,510,631,490);				// L Hand
g.drawLine(660,510,631,490);				// R Hand		
}
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.