Clock Transition?

Started by
1 comment, last by Cornutopia 19 years, 3 months ago
How would I make a clock transition in a game from one map to another that would wipe the screen clockwise to a new map? All I need is the math parts of this.
True God of the TribunalKelchargeMy SiteMy Ugly Forums
Advertisement
Do you mean such that the new map appears on top of the old one, first showing a little sliver between "12 o'clock" and a bit clockwise, and then gradually expanding the wedge all the way around?

Imagine a single 'hand' which extends from the centre of the screen straight up, and travels clockwise one full rotation over the duration of the visual effect. In each delta-time, you need to advance the hand angle by a few degrees, then draw the portion of the new map that lies between old and new hand positions. That "portion" will be a triangle between:

- the centre of the map
- the intersection of the old hand with the edge of the map
- the intersection of the new hand with the edge of the map.

You can get the slope of the line via atan2() in <cmath> (<math.h> in plain C), and thus find the equation for the current 'hand line' in y=mx+b form (although you will have to handle vertical lines separately I suppose). Then intersect the line with the edges of the map (standard line/line intersection; since the map edges will be vertical or horizontal, you can just plug in an x or y value into the line equation) to find those vertices. One problem will be when you pass by the corners of the map, which you will probably want to handle as a special case (or just make sure that for some valid delta-time value, the hand points exactly at the corner).
If you mean tile map to tile map, a simple way would be to use the Bresenham line drawing algorithm to draw consecutive lines from the middle of the screen to each bordering tile in turn.

Mark
Bytten Independent Games Magazine
http://www.bytten.com

This topic is closed to new replies.

Advertisement