Jump to content
  • Advertisement
Sign in to follow this  
kelcharge

Clock Transition?

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
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).

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!