Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (775)
Games in Android Showcase (230)
games submitted by our members
Games in WIP (856)
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 2591 times)
0 Members and 1 Guest are viewing this topic.
Offline Ging3rtoby
« Posted 2013-08-23 09: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
Offline Ging3rtoby
« Reply #1 - Posted 2013-08-23 10: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 10: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 10: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....
bufferedimage.getGraphics(); etc.
Offline Ging3rtoby
« Reply #4 - Posted 2013-08-23 11: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 11: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 12: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 12: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 and,  similiar to your Core_Main and Core_Window
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
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.


"Experience is what you get when you did not get what you wanted"
Offline Ging3rtoby
« Reply #8 - Posted 2013-08-23 14: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 19: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  

hadezbladez (45 views)
2018-11-16 13:46:03

hadezbladez (50 views)
2018-11-16 13:41:33

hadezbladez (29 views)
2018-11-16 13:35:35

hadezbladez (20 views)
2018-11-16 13:32:03

EgonOlsen (1900 views)
2018-06-10 19:43:48

EgonOlsen (1936 views)
2018-06-10 19:43:44

EgonOlsen (1286 views)
2018-06-10 19:43:20

DesertCoockie (1718 views)
2018-05-13 18:23:11

nelsongames (1412 views)
2018-04-24 18:15:36

nelsongames (2043 views)
2018-04-24 18:14:32
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46 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‑
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!