Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (536)
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 1203 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!
Legends of Yore - The Casual Retro Roguelike
Offline Nate

JGO Kernel


Medals: 145
Projects: 4
Exp: 14 years


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.

 

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

The first screenshot will be displayed as a thumbnail.

Riven (20 views)
2014-07-29 18:09:19

Riven (13 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (31 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (42 views)
2014-07-24 01:59:36

Riven (42 views)
2014-07-23 21:16:32

Riven (28 views)
2014-07-23 21:07:15

Riven (29 views)
2014-07-23 20:56:16

ctomni231 (60 views)
2014-07-18 06:55:21
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!