jQuery in Action, 2nd edition*
The moose likes Game Development and the fly likes Need help with centering screen Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Game Development
Bookmark "Need help with centering screen" Watch "Need help with centering screen" New topic
Author

Need help with centering screen

richard gallagher
Greenhorn

Joined: Mar 15, 2008
Posts: 9
Hello,

The game map consists of tiles that are not all on screen. It is a turn based map, where the centre of screen should be the "focus" (The focus is displayed as a red box, highlighting the tile.
Clicking a tile makes the tile the "focus", and should centre the screen, as well as update on the gui the tile location. Does anyone know good tutorials on this, for a turn based game, or what keywords whould i google for?
My last attempt (now deleted) was based on a normal platformer game - "focus" wouldnt centre, and the mouseclicks always showed data on the tiles that are present on the first screen (top left), even if the screen was elsewhere.

thankyou

rg
Gavin Tranter
Ranch Hand

Joined: Jan 01, 2007
Posts: 333
I think your searchs may just be a bit to related to games.

When you think about it, this probable is inherient in any mapping or graphics applications. (Ignoring the turn based thing).

Have a look at photoshop, you have an image and an image naviagation box right? Which sounds a lot like what you want.

If you are doing 3D graphics, the area/window though which you are viewing the action, is the clipping plane, I dont know what it is called in 2D graphics.

I would think (and as I am not at home cant comfirm this), that Killer Games Programming in Java, should have a chapter on this.

All you are really doing is transforming the centre of the tile to the centre of the "clipping" plane. The centre of the clipping plane will always be constant.
Or perhaps more correctly you are moving the centre of the "clipping" plane to the centre of teh clicked on title.

I would move the clipping plane rather then the "map".

Hope this helps a little.
Gavin
That is a simple transformation of a rectrangle.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need help with centering screen