Jump to content

  • Log In with Google      Sign In   
  • Create Account

The Code Zone Bargain Basement Blog



A couple of minor changes

  Posted by , 17 August 2010 - - - - - - · 175 views
import_rss
First off, the Google Checkout issue is fixed. The site should be in the pink again.



Second, I made a couple of changes to the look. The old Flash-based menu has been replaced with a shiny new standards-compliant HTML menu. The old one worked, but it gave the HTML purists fits.



Note that HTML menus tend to give some browsers fits (much like the Flash menu gave iPods and iPads fits). If you see something other than a classy gray menu-bar, please email support@thecodezone.com and let me know.https://blogger.googleusercontent.com/tracker/5927544581291786949-6650317037396314417?l=thecodezone.blogspot.com

Source


Google checkout issues

  Posted by , 09 August 2010 - - - - - - · 176 views
import_rss
Looks like my shared SSL certificate is expired. Fortunately for me, all that affects is Google Checkout. As it stands, I'll be fulfilling any google checkout orders by hand until that issue is resolved. My service provider is aware of the issue and is working to fix it.



Thanks for your patience.https://blogger.googleusercontent.com/tracker/5927544581291786949-3690158241823205172?l=thecodezone.blogspot.com

Source


Handy piece of code

  Posted by , 04 August 2010 - - - - - - · 153 views
import_rss
Here's a quick-n-simple piece of AS3 (or Javascript) that calculates the point on a line closest to a given point. It took me a couple of tries to get it right, so I figured I would share it.



var nearestPtToLine = function(segA:Point, segB:Point, p:Point, infinite:Boolean = true):Point

{

var dx:Number = segB.x - segA.x

var dy:Number = segB.y - segA.y

var u:Number = ((p.x - segA.x) * dx + (p.y - segA.y) * dy) / (dx * dx + dy * dy)



if (!infinite)

{

if (u > 1)

u = 1

else if (u < 0)

u = 0

}

return new Point(segA.x + u * dx , segA.y + u * dy)

}



seg1 and seg2 define a line segment. p is the point to test. infinite assumes that the line extends beyond seg1 and seg2. If you need the distance from a point to a line, just use the distance function in the flash.geom.Point object.https://blogger.googleusercontent.com/tracker/5927544581291786949-416910369498440079?l=thecodezone.blogspot.com

Source


Handy piece of code

Posted by , 04 August 2010 - - - - - - · 176 views

Here's a quick-n-simple piece of AS3 (or javascript) that calculates the point on a line closest to a given point. It took me a couple of tries to get it right, so I figured I would share it.

var nearestPtToLine = function(segA:Point, segB:Point, p:Point, infinite:Boolean = true):Point
{
var dx:Number = segB.x - segA.x
var dy:Number = segB.y - segA.y
var u:Number = ((p.x - segA.x) * dx + (p.y - segA.y) * dy) / (dx * dx + dy * dy)

if (!infinite)
{
if (u > [[1]])
u = [[1]]
else if (u < [[0]])
u = [[0]]
}
return new Point(segA.x + u * dx , segA.y + u * dy)
}




seg1 and seg2 define a line segment. p is the point to test. infinite assumes that the line extends beyond seg1 and seg2. If you need the distance from a point to a line, just use the distance function in the flash.geom.Point object.


EDIT: I don't know why gamedev's source formatter is putting brackets around the 1's and 0's in the if (!infinite) block. Don't do that. Just regular ones and zeros.







PARTNERS