# Clock Transition?

This topic is 5058 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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.

##### Share on other sites
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).

##### Share on other sites
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

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633303
• Total Posts
3011280
• ### Who's Online (See full list)

There are no registered users currently online

×