Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (404)
games submitted by our members
Games in WIP (289)
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  
  Boards within GameBoard  (Read 969 times)
0 Members and 1 Guest are viewing this topic.
Offline joelt

Junior Newbie





« Posted 2010-12-21 00:08:28 »

I have a game that has two portions which should logically use the same rendering logic, except the data is different for each and the location (translation) and perspective (mirror image) are different.

Should I use a image to render these to, and then blit to the main backscreen, using a transformation, or is there something more logical I should do to get them to draw directly to the backscreen?

J
Offline Captain Awesome

Junior Member


Medals: 2


Hi


« Reply #1 - Posted 2010-12-21 01:06:07 »

No, rendering it to an image before rendering it to the main screen will probably be slow.
Instead, either set a translation on your graphics object, or create a copy of the graphics object and translate that one.
You can create a copy of the graphics object by using one of the following methods:
create()
create(int x, int y, int width, int height)

With the first one you have to manually set the translation, with the second one the translation and clipping area is set in the constructor.
Offline joelt

Junior Newbie





« Reply #2 - Posted 2010-12-21 02:04:03 »

The problem is I don't see how to make that transformation. For instance if I want to draw component "as is" in the top half of screen, that's fine but what's the transformation so that drawing will be mirrored in the bottom half of screen? It seems like it mirror on the dimensions of the screen, not just the bottom half of the screen.
Games published by our own members! Check 'em out!
Try the Free Demo of Titan Attacks
Offline Nate

JGO Wizard


Medals: 81
Projects: 3


Esoteric Software


« Reply #3 - Posted 2010-12-21 02:07:55 »

Draw it twice, using the same rendering logic with different data.

Offline joelt

Junior Newbie





« Reply #4 - Posted 2010-12-21 02:09:02 »

I think you indicate how with the width and height being specified so it should just rotate that area not against the whole screen. Ill give that a try anyway.
Offline joelt

Junior Newbie





« Reply #5 - Posted 2010-12-21 23:08:00 »

This is generally working, but I'm having trouble using Graphics properly it appears.

I create a top-level graphics object thusly:
Graphics t1 = g.create(3,25);

and then in a method later...
Graphics t2 = t1.create(0,0,800,600)

I think the problem comes when I create an AffineTransform with another translation and set that on the graphics object:
t2.setTranform(affineTransform);

This works except for the detail of forgetting the first translation it appears, how do I preserve the first, w/o knowing the values? I know I could pass them around, but seems like I'm missing something in the API.

J
Offline joelt

Junior Newbie





« Reply #6 - Posted 2010-12-21 23:17:22 »

NM. Just found it, have to set translations on graphics object, not on a transform as setTransform() wipes any other transformations.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Browse for soundtracks for your game!

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (32 views)
2013-05-17 21:29:12

alaslipknot (40 views)
2013-05-16 21:24:48

gouessej (70 views)
2013-05-16 00:53:38

gouessej (69 views)
2013-05-16 00:17:58

theagentd (78 views)
2013-05-15 15:01:13

theagentd (73 views)
2013-05-15 15:00:54

StreetDoggy (113 views)
2013-05-14 15:56:26

kutucuk (137 views)
2013-05-12 17:10:36

kutucuk (137 views)
2013-05-12 15:36:09

UnluckyDevil (145 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.096 seconds with 21 queries.