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

Junior Newbie

« Posted 2010-12-20 23: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?

Offline Captain Awesome

Junior Devvie

Medals: 2


« Reply #1 - Posted 2010-12-21 00: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(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 01: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 Bitwise Duke »

Medals: 167
Projects: 4
Exp: 14 years

Esoteric Software

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

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

Offline joelt

Junior Newbie

« Reply #4 - Posted 2010-12-21 01: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 22: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:

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.

Offline joelt

Junior Newbie

« Reply #6 - Posted 2010-12-21 22: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  

hadezbladez (2192 views)
2018-11-16 13:46:03

hadezbladez (825 views)
2018-11-16 13:41:33

hadezbladez (2150 views)
2018-11-16 13:35:35

hadezbladez (425 views)
2018-11-16 13:32:03

EgonOlsen (3464 views)
2018-06-10 19:43:48

EgonOlsen (3697 views)
2018-06-10 19:43:44

EgonOlsen (2280 views)
2018-06-10 19:43:20

DesertCoockie (3016 views)
2018-05-13 18:23:11

nelsongames (3089 views)
2018-04-24 18:15:36

nelsongames (3908 views)
2018-04-24 18:14:32
Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20 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!