Visual Harmonics

Game Development in Flash and Java

  • Home
  • About
  • ActionScript Optimisations
  • Development Methodologies

25

Aug

Physics: My reflections

Posted by Nick Wiggill  Published in ActionScript 3, Math, Physics

I’m looking at creating a little mini-golf/putt-putt game at the moment since something of the like has been requested at work.

For getting to grips with 2D vectors, there is little better than ball games, and particularly ones which need not be real time, eg. top-down golf and snooker/pool.

In fact I was in the midst of putting together this golf game when I thought, “why not make a great old mathematical example out of what I’m doing here?” I often see these awesome little Java and Flash applets which assist one in understanding mathematical concepts, for example this one which is a huge help in visualising the dot product of two vectors, as well as having numeric readouts (which I must confess, mine does not have, but does not really need… read on).





The diagram represents the course of a ball hitting an obstacle and rebounding, over the course of a single frame of animation (i.e. there are usually 20-30 of them per second). If you have a ball travelling toward an obstacle and, on it’s next projected update (tick/game-loop cycle) at the current velocity, it will appear inside a wall, then you have a problem. You cannot allow it to appear behind the surface of the solid wall, and you also cannot simply place it touching the wall on the current frame, as this will destroy the illusion of motion at a constant speed, or even constant acceleration (any constant application of force, even if that force is zero) which we have when the ball is travelling, unhindered, through open space.

As seen in this demo, the most logical approach is to reflect it’s motion outside of the surface of the wall by the same depth it would have “penetrated” into the wall, and at an angle which is a reflection the original (you may now excuse the appalling title of this post), on the opposite side of the wall. (In fact, this “mirror effect” is calculated using the surface normal, which you can see as the grey lines which appears when the green and red vectors cross over).

Have a good play. :)

no comment

Search

Recent Posts

  • VCAM for 2D camera views on stage
  • Copying arrays, need speed?
  • Memoisation: Give me space, take your time
  • Managing entities effectively in Flash games
  • Acquisition - an OO principle for the future

Archives

  • December 2008
  • October 2008
  • September 2008
  • August 2008
  • June 2008
  • October 2007

RSS 8bitrocket

  • An error has occurred; the feed is probably down. Try again later.

RSS gotoandplay.it

  • Forums are back online
  • OpenSpace: rapid virtual world development!

RSS gamedev.net

  • Ratcliff Code Suppository releases JobSwarm, a microthreading framework
  • Audio Article #52 at IndustryBroadcast

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org

Recent Post

  • VCAM for 2D camera views on stage
  • Copying arrays, need speed?
  • Memoisation: Give me space, take your time
  • Managing entities effectively in Flash games
  • Acquisition - an OO principle for the future
  • Physics: My reflections
  • Bitwise Gems: Fast Integer Math over at Polygonal…
  • Comparing Online Payments Providers
  • New ActionScript Optimisations Page
  • Refactoring the Polygonal Data Structures

Recent Comments

  • Nick Wiggill in New ActionScript Optimisations Page
  • Bachir El Khoury in New ActionScript Optimisations Page
  • Nick Wiggill in New ActionScript Optimisations Page
  • Jeff Fulton in New ActionScript Optimisations Page
© 2007 Visual Harmonics
Theme by Wired Studios, courtesy of Corvette Garage
Valid XHTML | Valid CSS 3.0
Powered by Wordpress