Slick Forums

Discuss the Slick 2D Library
It is currently Thu May 23, 2013 5:55 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Sat Sep 01, 2012 11:29 am 
Offline

Joined: Thu Mar 15, 2012 12:10 pm
Posts: 3
Hello,

I'm just writing a vector-based platformer, using Slick2D (you guessed that, right? ;) ).
All my render operations would be much easier (and independent of screen resolution) if I could make slick consider the lower left corner of the screen as origin (could Graphics.translate(...) to achieve that) and paint positive y-direction upwards (can't do that...).

Is it possible to do that?


Top
 Profile  
 
PostPosted: Sun Sep 02, 2012 3:39 pm 
Offline

Joined: Fri Aug 31, 2012 6:54 pm
Posts: 8
My programming sense is tingling and telling me that solving this problem is just patching a earlier poor decision. BUT I think it should be easy to solve anyway...

Given a resolution of X by Y, our screen looks like -

[00][X0]
[0Y][XY] and needs to be converted to

[0Y][XY]
[00][X0]

to do this we need to take each set of coords X by Y and resolve them as (X, |Y-Y|).

No, translation needed.

Example -
Code:
//Getting screen Y size.
int maxY = gameContainer.getScreenHeight();
//Creating vector to describe image location
Vector2f imageLocation = new Vector2f(100, 250);
Image image = new Image("your/location.png");

//Draw to converted coords
image.draw(imageLocation.getX(), Math.abs(imageLocation.getY()-maxY));


If you are doing this for every Y... you probably want to create a convertY method to quickly change an array of images, etc to the translated Y coords.

But like I said- this is a bad idea. :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group