Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (472)
Games in Android Showcase (105)
games submitted by our members
Games in WIP (524)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Newbie & Debugging Questions / Re: Where to start learning game programming on: 2012-05-27 02:24:38
 try the book Developing Games in Java by david brackeen, Im in chapter 3 now and it seems to be working well for me. it was originally written for java 1.4 but the web site has some updates and any other problems can probably be solved by posting here. it starts with enabling graphics mode, excluding a excerpt about threads that are used throughout the book, and according to the table of contents goes up through complicated topics like bsp trees and A*. I have found the explanations quite clear. in addition all of the source code is available at www.brackeen.com/javagamebook
2  Game Development / Newbie & Debugging Questions / Re: error type mismatch on: 2012-05-27 02:16:54
thanks so much, when I copied the code over to solve my original problem I forgot to change the location of my Images in my code <<facepalm>>
3  Game Development / Newbie & Debugging Questions / Re: error type mismatch on: 2012-05-27 01:51:13
yes here they are :

Exception in thread "main" java.lang.IllegalArgumentException: Width (-1) and height (-1) cannot be <= 0
   at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:999)
   at java.awt.image.BufferedImage.<init>(BufferedImage.java:324)
   at apple.awt.CGraphicsConfig.createCompatibleImage(CGraphicsConfig.java:133)
   at com.brackeen.javagamebook.graphics.ScreenManager.createCompatibleImage(ScreenManager.java:251)
   at MenuTest.createButton(MenuTest.java:139)
   at MenuTest.init(MenuTest.java:38)
   at com.brackeen.javagamebook.test.GameCore.run(GameCore.java:34)
   at MenuTest.main(MenuTest.java:18)

I Hope this helps
4  Game Development / Newbie & Debugging Questions / Re: error type mismatch on: 2012-05-27 01:40:36
thats probable because now when I run the program it opens and then closed immediately and I'm not sure where to begin looking for the problem. maybe this other mystery can help you point me in the right direction?
5  Game Development / Newbie & Debugging Questions / Re: error type mismatch on: 2012-05-27 01:26:15
thanks that clears things up, but why did the assignment work in the original code?
6  Game Development / Newbie & Debugging Questions / <solved>error type mismatch on: 2012-05-27 01:00:27
I have been working through a book on java game programing, originally written in java 1.4, but Im working in 1.6. in the original source files I downloaded the code works fine but when I moved it to 1.6 this error popped up "Type mismatch: cannot convert from Window to JFrame" what should I change to update the code? The error pops up in 2 places shown below.

1  
2  
JFrame frame = super.screen.getFullScreenWindow();
        Container contentPane = frame.getContentPane();


and

1  
2  
3  
    public void draw(Graphics2D g) {
        super.draw(g);
        JFrame frame = super.screen.getFullScreenWindow();

Any help on updating the code would be greatly appreciated.

7  Game Development / Newbie & Debugging Questions / Re: help- loading and displaying 2D images on: 2012-05-13 02:00:51
I have moved the images into the source folder and replaced the code

1  
2  
private Image loadImage(String fileName) {
      return new ImageIcon(fileName).getImage();


with
1  
2  
3  
4  
5  
6  
7  
8  
   private Image loadImage(String name) {
         try {
            return ImageIO.read(getClass().getResource(name));
         } catch (IOException e) {
            e.printStackTrace();
         }
         return null;
      }

now all it does is display the blue screen with a loading images message, wait a second, refresh and remove the waiting message, then close without displaying the desired image. maybe this will clear things up a little, the program is supposed to display a loading images message, and once the images are loaded then refresh the screen and display the images.
8  Game Development / Newbie & Debugging Questions / Re: help- loading and displaying 2D images on: 2012-05-13 01:02:55
where should I put the new code? if I remove the line you were talking about it gives me an error unless I put the new code in directly below it, but that doesn't seem to solve the problem. I am new to any form of graphics environment so it would be great if you could simplify your explanation as much as possible. also should I change the section of the code below to work with the new code?



1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
if (imagesLoaded = true) {
         g.drawImage(bgImage,0,0,null);
         drawImage (g,opaqueImage,320,0, "opaque");
         
      }
      else {
         g.drawString("Loading Images...", 5, FONT_SIZE);  
      }
   }

      public void drawImage (Graphics g ,Image image , int x, int y, String caption) {
         g.drawImage(image,x,y,null);
         g.drawString(caption , x +5, y + FONT_SIZE+ image.getHeight(null));
     
9  Game Development / Newbie & Debugging Questions / Re: help- loading and displaying 2D images on: 2012-05-12 23:31:23
The files are located on my hard drive, I wasn't sure if I needed the file location when I called them I'm the code or just the file name. Fyi I'm on a mac if that changes  how I should refer to them
10  Game Development / Newbie & Debugging Questions / help- loading and displaying 2D images on: 2012-05-12 22:24:29
I have been Having difficulty getting an image file to load and be displayed properly. The code below gives me no errors when I try to run it but all I get is the word opaque printed on a blue background. I am trying to use an example in a Java game programing book but it is outdated. The book is written for java 1.4 if that helps anybody. Keep in mind I defined the class SimpleScreenManger, should have been SimpleScreenManager, and have used it for other code in the same project so its not the problem. Any tips or advise are welcome.


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
import java.awt.*;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
public class ImageTest extends JFrame {
   
   public static void main(String[] args) {
      DisplayMode displayMode;
     
      if (args.length == 3) {
         displayMode = new DisplayMode(
               Integer.parseInt(args[0]),
               Integer.parseInt(args[1]),
               Integer.parseInt(args[2]),
               DisplayMode.REFRESH_RATE_UNKNOWN);
      }
      else {
            displayMode = new DisplayMode(1440,900,16,
                  DisplayMode.REFRESH_RATE_UNKNOWN);
      }
      ImageTest test = new ImageTest() ;
      test.run(displayMode);
     
   }
   
   private static final int FONT_SIZE = 24;
   private static final long DEMO_TIME = 5000;
   
   private SimpleScreenManger screen;
   private Image bgImage;
   private Image opaqueImage;
   private boolean imagesLoaded;
   
   public void run(DisplayMode displayMode) {
      setBackground(Color.blue);
      setForeground(Color.white);
      setFont (new Font("Dialog", Font.PLAIN, FONT_SIZE)) ;
      imagesLoaded = false;
     
      screen = new SimpleScreenManger();
      try {
         screen.setFullScreen(displayMode, this);
         loadImages();
         try {
            Thread.sleep(DEMO_TIME);
         }
         catch (InterruptedException ex) {}
      }
      finally {
         screen.restoreScreen();}
           
   }
   public void loadImages () {
      bgImage = loadImage("Background.jpg");
      opaqueImage = loadImage("opaquecircle.png");
      imagesLoaded = true;
      repaint();  
   
   }
   
   private Image loadImage(String fileName) {
      return new ImageIcon(fileName).getImage();
   }
   
   public void paint (Graphics g) {
      if (g instanceof Graphics2D) {
         Graphics2D g2 = (Graphics2D) g;
         g2.setRenderingHint(
               RenderingHints.KEY_TEXT_ANTIALIASING,
               RenderingHints.VALUE_TEXT_ANTIALIAS_ON );
      }
     
      if (imagesLoaded = true) {
         g.drawImage(bgImage,0,0,null);
         drawImage (g,opaqueImage,320,0, "opaque");
         
      }
      else {
         g.drawString("Loading Images...", 5, FONT_SIZE);  
      }
   }

      public void drawImage (Graphics g ,Image image , int x, int y, String caption) {
         g.drawImage(image,x,y,null);
         g.drawString(caption , x +5, y + FONT_SIZE+ image.getHeight(null));
     
   }

}

Pages: [1]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Riven (20 views)
2014-07-10 20:20:18

CopyableCougar4 (21 views)
2014-07-10 02:26:14

CopyableCougar4 (28 views)
2014-07-09 02:55:38

Code Mage (28 views)
2014-07-08 23:57:00

Code Mage (15 views)
2014-07-08 23:49:08

AppleSauce (24 views)
2014-07-08 19:25:32

CopyableCougar4 (24 views)
2014-07-06 01:51:26

ipe369 (29 views)
2014-07-05 14:18:25

vastrolorde (40 views)
2014-07-04 18:45:44

theagentd (58 views)
2014-07-02 22:19:37
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!