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
|
|
|
|
|
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
|
|
|
|
|
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)); |
|
|
|
|
|
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)); }
} |
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|