Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Need help with centering screen

Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.


Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
That is a simple transformation of a rectrangle.
This is my favorite tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic