Jump to content

  • Log In with Google      Sign In   
  • Create Account


Painting Graphics Within A Game Loop?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Incompletion   Members   -  Reputation: 129

Like
0Likes
Like

Posted 02 December 2012 - 06:37 PM

I am wondering how to call my method which is using the (Graphics Gr) object in a seperate class, for instance I have my game loop class "MainGameLoop.java" how can I call the (Graphics Gr) method into the game loop from the class "MainRenderHandler.java" and also how do I use a different method instead of paintComponent is there a way to create a custom one such as Draw(Graphics Gr) instead?

EDIT: Here's my game classes;

MainClassHandler: "http://pastebin.com/whBSrfii"
MainGameLoop: "http://pastebin.com/kvhRfWqW"
MainJFrameConfig: "http://pastebin.com/ZEYX8UXc"
MainRenderHandler: "http://pastebin.com/f3iQJ3BK"

Edited by Incompletion, 02 December 2012 - 07:08 PM.


Sponsor:

#2 Incompletion   Members   -  Reputation: 129

Like
0Likes
Like

Posted 03 December 2012 - 09:41 PM

Anyone? Posted Image

Edited by Incompletion, 03 December 2012 - 09:41 PM.


#3 Incompletion   Members   -  Reputation: 129

Like
0Likes
Like

Posted 04 December 2012 - 12:01 PM

Sigh..

#4 BCullis   Crossbones+   -  Reputation: 1813

Like
1Likes
Like

Posted 04 December 2012 - 01:07 PM

I'm not familiar with game programming in Java (at least with graphics2D, I have used a JOGL-based framework before) but I'm pretty sure you don't want to be new()ing a fresh RenderHandler class every frame. Your code seems a little confused in terms of class responsibilities, but if you want access to the Graphics object, it has to exist outside the paintComponent call. You might want to google around for java game programming with Graphics2D, and see what other frameworks people have created to address that issue.
Hazard Pay :: FPS/RTS in SharpDX
DeviantArt :: Because right-brain needs love too

#5 BaneTrapper   Members   -  Reputation: 1149

Like
1Likes
Like

Posted 04 December 2012 - 03:17 PM

I have low knowledge about java so i cant help.
But if you want help, start from adding code intro the post it self.
//REMOVE ALL THE quotation marks -> " <- this
["CODE] my code is pasted here ["/"CODE] or click a "< >" icon on "toolbar" its directly bellow Posted Image this icon

how to call my method which is using the (Graphics Gr) object in a seperate class

Did you read a book on java, or finished tutorial series on java? it would teach you how to handle this.

Finding out problem on your own gives great experience and morale boost. On the other hand if your stuck, don't hesitate to confront anyone with it.

Edited by BaneTrapper, 04 December 2012 - 03:40 PM.

Current projects:
The Wanderer, 2d turn based rpg style game

www.gamedev.net/topic/641117-check-up-the-wanderer/


#6 Incompletion   Members   -  Reputation: 129

Like
0Likes
Like

Posted 04 December 2012 - 06:43 PM

Thanks BCullis, I've been trying to find information but to no avail so far Posted Image, also I had a render-handler class so my game could handle both 2D and 3D rendering capabilities.

Thanks Bane, I'll try to clean up the links a bit next time and I yes I do have a book on Java but it didn't explain how to use Graphics in the way I was hoping. I know fixing a problem myself is very helpful so, I will continue to try. If I am still stuck I'll try look around some more Posted Image.

Edited by Incompletion, 07 December 2012 - 03:57 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS