Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (108)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Problem in Game Engine  (Read 675 times)
0 Members and 1 Guest are viewing this topic.
Offline Ging3rtoby

Junior Member


Medals: 1
Projects: 1



« Posted 2013-08-23 11:47:03 »

I Have this problem in my game engine where I am trying to create a double buffering image and it keeps saying null. I have tryed to debug but still cant get this to work. I only have today to get it to work so I would love it if you fix it thanks Toby.

Code here https://www.dropbox.com/s/25wm2wcaz77awkg/Eclispe%20Workspace.zip
Offline Ging3rtoby

Junior Member


Medals: 1
Projects: 1



« Reply #1 - Posted 2013-08-23 12:40:19 »

Ha anybody got a idea yet I have been working on this for hours and still cant find the bug. It needs to done by 1
Offline StrideColossus
« Reply #2 - Posted 2013-08-23 12:56:22 »

Can you post the stack trace, would make it a lot easier to diagnose.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Herjan
« Reply #3 - Posted 2013-08-23 12:58:28 »

I know what you mean, an easy solution is to check if the bufferedimage == null in the render method and if that is true, bufferedimage= new buf....
else
bufferedimage.getGraphics(); etc.

Offline Ging3rtoby

Junior Member


Medals: 1
Projects: 1



« Reply #4 - Posted 2013-08-23 13:22:55 »

Thats what I do i check the buferedImage 2 first time create it second time print the err message.
Offline namrog84

JGO Ninja


Medals: 46
Projects: 4


Keep programming!


« Reply #5 - Posted 2013-08-23 13:59:48 »

Why are you using the variable type Image for your "doubleBufferImage"

Why not used BufferedImage for your bufferimage?

"Experience is what you get when you did not get what you wanted"
Offline Onatoko

Senior Newbie





« Reply #6 - Posted 2013-08-23 14:13:23 »

The graphics object you are trying to retrieve from g = this.getGraphics(); is returning null. Although you check it before you render, you get a NPE when you try to dispose of it.
Offline namrog84

JGO Ninja


Medals: 46
Projects: 4


Keep programming!


« Reply #7 - Posted 2013-08-23 14:19:53 »

I think you have done some things backwards with regards to JFrame and JPanel.

Here is some source code, that is pretty much identical to what you are doing, with some refactored/renamed elements
Specifically with GamePanel.java and Main.java,  similiar to your Core_Main and Core_Window
http://www.thejavahub.net/thejavahub/index.php?topic=266.0
It should show you whats gone wrong.
The issue isn't with doubleBufferImage = createImage or the null gameRender() part
It lies in a deeper and broader issue with how you have your entire program setup.

Specifically you are creating a JFrame inside your JPanel, when it should be the other way around.  The public static void main should be in your JFrame, not in your JPanel



http://www.youtube.com/watch?v=zSkHp7xQxEM
You can follow along as they write most of what you have there,  pay special attention to things that are different.
Ignore the areas outside of the JFrame and JPanel class,  specifically with rendering and basic setup

I got it working with the code, however it requires a lot of various small changes in Core_Main and Core_Window that'd just be a pain to most here, but those 2 links should get you going without too much difficulty.

 Stare

"Experience is what you get when you did not get what you wanted"
Offline Ging3rtoby

Junior Member


Medals: 1
Projects: 1



« Reply #8 - Posted 2013-08-23 16:03:00 »

Well it is a game engine for home use and I have looked at the javahub but I would then need to change all my code and add more classes but I dont have time. So I would rather do the small changes as a temporary solutions then come back to the problem.
Offline lcass
« Reply #9 - Posted 2013-08-23 21:44:35 »

I have had this error before it is generally annoying what I would do is check each variable being put into the functions so System.out.println(g); is an example. if any of them are null then you can tell us the issue.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

CogWheelz (17 views)
2014-07-30 21:08:39

Riven (23 views)
2014-07-29 18:09:19

Riven (15 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (33 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (43 views)
2014-07-24 01:59:36

Riven (43 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

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
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!