Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (710)
Games in Android Showcase (212)
games submitted by our members
Games in WIP (784)
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 1544 times)
0 Members and 1 Guest are viewing this topic.
Offline brollysan

Junior Devvie

Medals: 1

« Posted 2013-03-19 20: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 Opiop
« Reply #1 - Posted 2013-03-19 20: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 Devvie

Medals: 1

« Reply #2 - Posted 2013-03-19 21: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.

theagentd (105 views)
2017-02-18 13:42:33

theagentd (109 views)
2017-02-18 13:35:16

h.pernpeintner (1274 views)
2017-01-24 22:39:11

h.pernpeintner (1262 views)
2017-01-24 22:38:32

Galdo (1821 views)
2017-01-12 13:44:09

Archive (1926 views)
2017-01-02 05:31:41

0AndrewShepherd0 (2464 views)
2016-12-16 03:58:39

0AndrewShepherd0 (2301 views)
2016-12-15 21:50:57

Lunch (2380 views)
2016-12-06 16:01:40

ral0r2 (2156 views)
2016-11-23 16:08:26
List of Learning Resources
by elect
2016-09-09 09:47:55

List of Learning Resources
by elect
2016-09-08 09:47:20

List of Learning Resources
by elect
2016-09-08 09:46:51

List of Learning Resources
by elect
2016-09-08 09:46:27

List of Learning Resources
by elect
2016-09-08 09:45:41

List of Learning Resources
by elect
2016-09-08 08:39:20

List of Learning Resources
by elect
2016-09-08 08:38:19

Rendering resources
by Roquen
2016-08-08 05:55:21 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!