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 14 of 14

Thread: Game problem

  1. #1
    Junior Member
    Join Date
    Aug 2011
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Game problem

    Hi,

    I wrote this bit of code for my game: (it is meant to be a copy of pong, so that is why the background is named that way)
     
    import java.awt.geom.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
     
    public class Game extends GameFramework
    {
    	public static void main(String[] args)
    {
         Game game = new Game();
    }
     
     
     
        public Game()
        {
     
            super(800,600);
            setBackground("pongintropage.png");
     
     
     
     
     
     
            this.startGame();
        }
     
        public void update(double elapsed)
        {
     
        }
     
        public void processKeys()
        {
     
        }
     
        @Override
        public void draw(Graphics2D g2)
        {
     
        }
    }


    I expected the usual 800x600 pixel screen with the selected background, but instead I got that blank command prompt black screen. Is there something wrong with my code??


    Thanks,
    Yo Cas Cas
    Last edited by Yo Cas Cas; August 25th, 2011 at 07:02 PM.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Game problem

    What is GameFramework? It is not a standard class in the java API

  3. #3
    Junior Member
    Join Date
    Aug 2011
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Game problem

    Quote Originally Posted by copeg View Post
    What is GameFramework? It is not a standard class in the java API
    What should I use instead???

  4. #4
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Game problem

    We have no idea. Where did you get the GameFramework class from? You have several methods in your Game class that all do nothing. What exactly are you expecting to happen?
    Improving the world one idiot at a time!

  5. #5
    Junior Member
    Join Date
    Aug 2011
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Game problem

    I am expecting a window to come up that is 600 by 800 pixels, with my background set.

  6. #6
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Game problem

    Since nothing in your code does that the expectation is the GameFramework should do it. As mentioned above GameFramework is not a standard Java class. We have never heard of it and have no idea what it does. So how are we supposed to help you?
    Improving the world one idiot at a time!

  7. #7
    Junior Member
    Join Date
    Aug 2011
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Game problem

    I just want what i said to happen. You can change whatever you want. Can you give me some kind of code that will help and also explain why?

    You can change it!

  8. #8
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    661
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default Re: Game problem

    I know this might be frowned upon, as It's of no use to anyone...
    but /facepalm
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

  9. #9
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Game problem

    Are you a troll?

    If not you either have to understand the GameFramework and what it does. Once again we cannot help you with that as we do not know what the GameFramework class is. Else you dump GameFramework and read a tutorial on Swing or Applets.
    Improving the world one idiot at a time!

  10. #10
    Junior Member
    Join Date
    Aug 2011
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Game problem

    Please don't post useless info on other's posts....

  11. #11
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    661
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default Re: Game problem

    Please post useful info in your threads.
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

  12. #12
    Junior Member
    Join Date
    Aug 2011
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Game problem

    Quote Originally Posted by Junky View Post
    Are you a troll?

    If not you either have to understand the GameFramework and what it does. Once again we cannot help you with that as we do not know what the GameFramework class is. Else you dump GameFramework and read a tutorial on Swing or Applets.
    What class should i use instead??????

  13. #13
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Game problem

    WOW!

    You read those toturials very quickly. Obviously so quick you didn't remember any of the information in them.
    Improving the world one idiot at a time!

  14. #14
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Game problem

    Try extending JFrame and see what that does.

  15. The Following User Says Thank You to Norm For This Useful Post:

    Yo Cas Cas (August 25th, 2011)

Similar Threads

  1. Java Game Launching Problem
    By PaulMoretti in forum What's Wrong With My Code?
    Replies: 5
    Last Post: August 18th, 2011, 12:41 PM
  2. Card Game Problem.
    By d'fitz in forum What's Wrong With My Code?
    Replies: 2
    Last Post: June 5th, 2011, 07:30 AM
  3. Card Game Problem....Need Help
    By macFs89H in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 28th, 2011, 07:30 AM
  4. simple game with swing and awt problem
    By Pulse_Irl in forum AWT / Java Swing
    Replies: 2
    Last Post: October 12th, 2010, 02:04 PM
  5. [SOLVED] minesweeper game creation problem
    By kaylors in forum What's Wrong With My Code?
    Replies: 5
    Last Post: June 27th, 2009, 04:06 PM