Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Please need help with this code, please!!

  1. #1
    Junior Member
    Join Date
    Jul 2011
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Please need help with this code, please!!

    import javax.swing.*; 
    import javax.swing.event.*; 
    import java.awt.*; 
    import java.awt.event.*;
     
    public class Game1 extends JFrame {
     
    	final int WITHD = 900, HEIGHT = 650;
     
    	Rectangle left = new Rectangle(0,0,WIDTH/9,HEIGHT);
    	Rectangle right = new Rectangle((WIDTH/9)*9,0,WIDTH/9,HEIGHT);
    	Rectangle top = new Rectangle(0,0,WiDTH, HEIGHT/9);
    	Rectangle bottom = new Rectangle(0, (HEIGHT/9)*9,WIDTH,HEIGHT/9);
    	Rectangle center = new 
    		Rectangle((int) ((WIDTH/9)*2.5), (int)
    				((HEIGHT/9)*2.5), (int) ((WIDTH/9)*5), (HEIGHT/9)*4;
    	Rectangle obstacle = new
    		Rectangle(WIDTH/2,(int)((HEIGHT/9)*7),WIDTH/10,HEIGHT/9);
    	Rectangle obstacle2 = new
    		Rectangle(WIDTH/3,(int)((HEIGHT/9)*5),WIDTH/10,HEIGHT/4);
    	Rectangle obstacle3 = new
    		Rectangle(2*(WIDTH/3),(int)((HEIGHT/9)*5),WIDTH/10,HEIGHT/4);
    	Rectangle obstacle4 = new Rectangle(WIDTH/3,HEIGHT/9,WIDTH/30,HEIGHT/9); 
    	Rectangle obstacle5 = new 
    		Rectangle(WIDTH/2,(int)((HEIGHT/9)*1.5),WIDTH/30,HEIGHT/4);
     
    	Rectangle finish = new 
    		Rectangle(WIDTH/9,(HEIGHT/2)−HEIGHT/9, (int)((WIDTH/9)*1.5),
    			HEIGHT/70);
    	Rectangle lineO = new
    		Rectangle(WIDTH/9,HEIGHT/2,(int)((WIDTH/9)*1.5)/2,HEIGHT/140);
    	Rectangle lineI = new 
    		Rectangle(((WIDTH/9)+((int)((WIDTH/9)*1.5)/2)),
    			(HEIGHT/2)+(HEIGHT/10), (int)((WIDTH/9)*1.5)/2, HEIGHT/140);
     
    	public Game1() {
     
    		super("Radical Racing");
    		SetSize(WIDTH,HEIGHT);
    		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		setVisible(true);
    }
     
    	public void paint(Graphics g) {
     
    		super.paint(g);
    		g.setColor(Color.DARK_GRAY);
    		g.fillRect(0,0,WIDTH,HEIGHT);
     
    		g.setColor(Color.GREEN);
    		g.fillRect(left.x,left.y,left.width,left.height);
    		g.fillRect(right.x,right.y,right.width,right.height);
    		g.fillRect(top.x,top.y,top.width,top.height); 
    		g.fillRect(bottom.x,bottom.y,bottom.width,bottom.height); 
    		g.fillRect(center.x,center.y,center.width,center.height); 
    		g.fillRect(obstacle.x,obstacle.y,obstacle.width,obstacle.height); 
    		g.fillRect(obstacle2.x,obstacle2.y,obstacle2.width,obstacle2.height); 
    		g.fillRect(obstacle3.x,obstacle3.y,obstacle3.width,obstacle3.height); 
    		g.fillRect(obstacle4.x,obstacle4.y,obstacle3.width,obstacle4.height);
    		g.fillRect(obstacle5.x,obstacle5.y,obstacle5.width,obstacle5.height);
     
    		g.setColor(Color.WHITE);
    		g.fillRect(lineO.x,lineO.y,lineO.width,lineO.height); 
    		g.fillRect(lineI.x,lineI.y,lineI.width,lineI.height);
     
    		g.setColor(Color.YELLOW);
    		g.fillRect(finish.x,finish.y,finish.width,finish.height);
     
    		}
    	public static void main(String args[]) {
    		new Game1();
    	}
    }


  2. #2
    Junior Member
    Join Date
    Jul 2011
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Please need help with this code, please!!

    other than the WITHD, i fixed it still doesnt work

  3. #3
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 168 Times in 159 Posts

    Default Re: Please need help with this code, please!!

    Quote Originally Posted by joelmeler View Post
    it still doesnt work
    Do you honestly think that provides us with enough information?
    Improving the world one idiot at a time!

  4. #4
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: Please need help with this code, please!!

    Is there a question associated with this? What is the code meant to do? What are the errors? Any Exceptions?
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers