Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
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  
  BufferedStrategy need info  (Read 858 times)
0 Members and 1 Guest are viewing this topic.
Offline brollysan

Junior Member


Medals: 1



« Posted 2013-03-19 21:28:03 »

I have some general questions about the bufferedstrategy class and how I can use them and hope you can help.

a) Since I use the graphicscontext (graphics2d g) to draw, do I have to clear the screen for every iteration of my gameloop to avoid duplicates? If I have a map with a box, if I don't clear it and the box moves during one iteration, will I draw two boxes or is the image automatically cleared for me?

b) Depending on the above, if the image is automatically cleared, do I have to redraw EVERYTHING in every iteration of the gameloop? This seems a bit inefficient (imagine the player going afk for 30 minutes, I am still rendering at full speed, the same static objects).

c) I am currently attaching a bufferedstrategy to a canvas, this canvas can have a gazillion subcomponents. Do I have to render each and every component (how?) or does the canvas have a paint-method that paints all of its components? How would one actively render a components image?
Offline opiop65

JGO Kernel


Medals: 153
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #1 - Posted 2013-03-19 21:40:43 »

1. Yes, or else yes, you will be drawing multiple boxes(I believe). Basically, in any sort of graphical program, you need to clear the screen constantly. You will also want to limit rendering so that even on slower machines, objects won't render faster and thus appear to be faster.
2. You only need to draw anything that is currently on the screen and is visible. I believe you also can optimize your game a little by only re-drawing objects that have actually moved on screen. But that may not work, and it may not apply to you. Just something to look into!
3. I don't honestly understand what you're asking here, could you elaborate or provide an example?

Offline brollysan

Junior Member


Medals: 1



« Reply #2 - Posted 2013-03-19 22:01:23 »

Thank you for the quick answer.

On your answer to the second question, thank you, for now I think I will simply empty(clear) the screen and redraw. As to avoiding redrawing things that haven't changed, how would that be possible if I clear? Do I have to selectively clear? (Eg if only a box has moved, just clear area big enough to draw something on where box was and where box will be and draw to this area on next iteration) Is this feasible?

On the third question. I was wondering how I actively render things that are attached to the canvas, like a JButton or a Menulayout, do I have to call their paint? (which seems passive).
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.

ctomni231 (34 views)
2014-07-18 06:55:21

Zero Volt (30 views)
2014-07-17 23:47:54

danieldean (25 views)
2014-07-17 23:41:23

MustardPeter (27 views)
2014-07-16 23:30:00

Cero (42 views)
2014-07-16 00:42:17

Riven (44 views)
2014-07-14 18:02:53

OpenGLShaders (32 views)
2014-07-14 16:23:47

Riven (33 views)
2014-07-14 11:51:35

quew8 (30 views)
2014-07-13 13:57:52

SHC (66 views)
2014-07-12 17:50:04
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!