home *** CD-ROM | disk | FTP | other *** search
- on findDistance pointA, pointB
- hDistance = pointA[1] - pointB[1]
- vDistance = pointA[2] - pointB[2]
- finalDistance = sqrt((hDistance * hDistance) + (vDistance * vDistance))
- return finalDistance
- end
-
- on findAngle pointA, pointB
- global watchThisAngle
- xDist = pointB[1] - pointA[1]
- yDist = pointB[2] - pointA[2]
- if xDist <> 0 then
- watchThisAngle = atan(1.0 * yDist / xDist) * 180 / PI
- theAngle = atan(1.0 * yDist / xDist) * 180 / PI
- if xDist > 0 then
- theAngle = theAngle + 90
- else
- if xDist < 0 then
- theAngle = theAngle - 90
- else
- if yDist < 0 then
- theAngle = 0
- else
- if yDist > 0 then
- theAngle = 180
- end if
- end if
- end if
- end if
- else
- if yDist < 0 then
- theAngle = 0
- else
- if yDist > 0 then
- theAngle = 180
- end if
- end if
- end if
- return theAngle
- end
-
- on translateVector spriteLoc, spriteDepth
- global fieldRotation, fieldOffset
- swivelAim1 = fieldRotation + 90
- if swivelAim1 > 360 then
- swivelAim1 = swivelAim1 - 360
- end if
- swivelAim2 = fieldRotation
- locY = cos(fieldRotation * PI / 180) * 1.5
- locX = sin(fieldRotation * PI / 180) * -1.5
- BGLocX = spriteLoc[1] + locX
- BGLocY = spriteLoc[2] + locY
- locY1 = cos(swivelAim1 * PI / 180) * -BGLocX
- locX1 = sin(swivelAim1 * PI / 180) * BGLocX
- locY2 = cos(swivelAim2 * PI / 180) * -BGLocY
- locX2 = sin(swivelAim2 * PI / 180) * BGLocY
- maxLoc = point(locX1, locY1) + point(locX2, locY2)
- minLoc = maxLoc / 10
- vectorDistance = findDistance(maxLoc, minLoc)
- vectorAngle = findAngle(maxLoc, minLoc)
- extrapolatedDist = vectorDistance * 100 / spriteDepth
- finalY = cos(vectorAngle * PI / 180) * -extrapolatedDist
- finalX = sin(vectorAngle * PI / 180) * extrapolatedDist
- return point(finalX, finalY)
- end
-
- on initializeStarField
- global starfieldData, starReset, fieldRotation, SF_maxStars, SF_SO
- starfieldData = []
- starReset = 0
- repeat with whichStar = 1 to SF_maxStars
- whichSprite = SF_SO + whichStar - 1
- starlength = random(20)
- set the height of sprite whichSprite to starlength * starlength
- set the width of sprite whichSprite to 5
- sprite(whichSprite).rotation = random(360)
- sprite(whichSprite).locZ = 10
- set the locH of sprite whichSprite to 1000
- set the foreColor of sprite whichSprite to random(255)
- add(starfieldData, [0, 50 + random(50), 5, point(0, 0)])
- end repeat
- end
-
- on moveStarField
- global starfieldData, starReset, fieldRotation, SF_maxStars, SF_SO, SF_starSpeed, SF_fieldRotation, SF_starSpread, starPaceLevel
- starPaceLevel = starPaceLevel + SF_starSpread
- if starPaceLevel > 100 then
- starPaceLevel = starPaceLevel mod 100
- starReset = starReset + 1
- end if
- if starReset > SF_maxStars then
- starReset = 1
- end if
- repeat with wStar = 1 to SF_maxStars
- wSprite = wStar + SF_SO - 1
- if wStar = starReset then
- starfieldData[wStar][3] = 5
- end if
- starfieldData[wStar][3] = starfieldData[wStar][3] - SF_starSpeed
- if starfieldData[wStar][3] < 5 then
- starfieldData[wStar][3] = 5
- end if
- if starfieldData[wStar][3] >= 10 then
- locY = cos(starfieldData[wStar][1] * PI / 180) * -starfieldData[wStar][2]
- locX = sin(starfieldData[wStar][1] * PI / 180) * starfieldData[wStar][2]
- oldDrawPoint = starfieldData[wStar][4]
- newDrawPoint = translateVector(point(locX, locY), starfieldData[wStar][3])
- starfieldData[wStar][4] = newDrawPoint
- streakLength = findDistance(oldDrawPoint, newDrawPoint)
- streakAim = findAngle(oldDrawPoint, newDrawPoint)
- visState = 1
- else
- starfieldData[wStar] = [random(360), random(150) + 250, 400, point(290, 220)]
- locY = cos(starfieldData[wStar][1] * PI / 180) * -starfieldData[wStar][2]
- locX = sin(starfieldData[wStar][1] * PI / 180) * starfieldData[wStar][2]
- oldDrawPoint = point(-600, -600)
- newDrawPoint = point(-600, -600)
- streakLength = 1
- streakAim = 1
- visState = 1
- end if
- if streakLength > 100 then
- streakLength = 100
- end if
- set the height of sprite wSprite to streakLength
- if the timer > 10 then
- set the blend of sprite wSprite to streakLength + 10
- else
- set the blend of sprite wSprite to 0
- end if
- set the width of sprite wSprite to streakLength - 20
- sprite(wSprite).rotation = streakAim + 1
- set the loc of sprite wSprite to oldDrawPoint + point(290, 220)
- sprite(wSprite).visible = visState
- end repeat
- end
-