Thanks blink0k, the lights seem to work pretty cool in AGKS.
Having control of the skybox and horizon made it easy to clean up the edges too.
And I noticed some messy code I didn't like so I cleaned it up a bit. Still looks the same when run though.
Original download updated.
// Project: lightning test by ando
// Created: 20-03-12
// WARNING - CONTAINS SPAGHETTI - wear eye protection
// show all errors
SetErrorMode(2)
SetVSync(1)
// make fullscreen
width# = GetDeviceWidth() // I had to use # to stabilise mouselook
height# = GetDeviceHeight()
SetWindowSize(width#,height#,1)
SetVirtualResolution(width#,height#) // doesn't have to match the window
SetSyncRate(60,0) // 60fps
SetScissor(0,0,0,0) // use the maximum available screen space
UseNewDefaultFonts(1)
Create3DPhysicsWorld()
Set3DPhysicsGravity(0,-0.15,0)
SetGenerateMipmaps(1)
// xxxxxxxxxxxxxxxx set all item ID's to names
// CAMERA
cam1=1
// IMAGES
terraintex=1
skytex=2
// OBJECTS
bolt1=1
bolt2=2
bolt3=3
bolt4=4
bolt5=5
bolt6=6
terrain=7
man1=8
sky=9
// SOUNDS
thunder1=1
thunder2=2
thunder3=3
thunder4=4
thunder5=5
thunder6=6
thunder7=7
thunder8=8
thunder9=9
wind=10
// LIGHTS
light1=1
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx FOG and LIGHT
SetSunActive(0)
SetAmbientColor(50,50,50)
SetFogMode(1)
SetFogColor(30,30,30)
SetFogRange(8000,9000)
SetSkyboxVisible(1)
SetSkyBoxHorizonColor(30,30,30)
SetSkyBoxSkyColor(30,30,30)
CreatePointLight(light1,0,50,0,3000,255,255,255)
SetPointLightRadius(light1,0)
SetPointLightColor(light1,255,255,255)
SetPointLightMode(light1,1)
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx WIND SOUND
LoadSoundOGG(wind,"wind1.ogg")
PlaySound(wind,4,1)
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx THUNDER SOUNDS
LoadSoundOGG(thunder1,"thunder1.ogg")
LoadSoundOGG(thunder2,"thunder2.ogg")
LoadSoundOGG(thunder3,"thunder3.ogg")
LoadSoundOGG(thunder4,"thunder4.ogg")
LoadSoundOGG(thunder5,"thunder5.ogg")
LoadSoundOGG(thunder6,"thunder6.ogg")
LoadSoundOGG(thunder7,"thunder7.ogg")
LoadSoundOGG(thunder8,"thunder8.ogg")
LoadSoundOGG(thunder9,"thunder9.ogg")
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx LIGHTNING BOLTS
LoadObject(bolt1,"bolt1.obj")
LoadObject(bolt2,"bolt2.obj")
LoadObject(bolt3,"bolt3.obj")
LoadObject(bolt4,"bolt4.obj")
LoadObject(bolt5,"bolt5.obj")
LoadObject(bolt6,"bolt6.obj")
SetObjectScale(bolt1,5,5,5)
SetObjectScale(bolt2,5,5,5)
SetObjectScale(bolt3,5,5,5)
SetObjectScale(bolt4,5,5,5)
SetObjectScale(bolt5,5,5,5)
SetObjectScale(bolt6,5,5,5)
SetObjectColor(bolt1,255,255,255,0)
SetObjectColor(bolt2,255,255,255,0)
SetObjectColor(bolt3,255,255,255,0)
SetObjectColor(bolt4,255,255,255,0)
SetObjectColor(bolt5,255,255,255,0)
SetObjectColor(bolt6,255,255,255,0)
SetObjectColorEmissive(bolt1,255,255,255)
SetObjectColorEmissive(bolt2,255,255,255)
SetObjectColorEmissive(bolt3,255,255,255)
SetObjectColorEmissive(bolt4,255,255,255)
SetObjectColorEmissive(bolt5,255,255,255)
SetObjectColorEmissive(bolt6,255,255,255)
SetObjectVisible(bolt1,0)
SetObjectVisible(bolt2,0)
SetObjectVisible(bolt3,0)
SetObjectVisible(bolt4,0)
SetObjectVisible(bolt5,0)
SetObjectVisible(bolt6,0)
lightningDist=0
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx TERRAIN
CreateObjectFromHeightMap(terrain,"terrainHM.png",1000,50,1000,1,1)
LoadImage(terraintex,"dirt5.png")
SetObjectImage(terrain,terraintex,0)
SetObjectUVScale(terrain,0,300,300)
SetImageWrapU(terraintex,1)
SetImageWrapV(terraintex,1)
Create3DPhysicsStaticBody(terrain)
//SetObject3DPhysicsFriction(terrain,10000)
//SetObject3DPhysicsRollingFriction(terrain,255)
SetObjectCollisionMode(terrain,1)
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx CLOUD LAYER
CreateObjectPlane(sky,10000,10000)
LoadImage(skytex,"cloud2.png")
SetObjectImage(sky,skytex,0)
SetObjectRotation(sky,-90,0,0)
SetObjectPosition(sky,0,100,0)
// xxxxxxxxxxxxxxxxxxxx CAMERA and PLAYER COLLISION SPHERE
SetCameraRange(cam1, 0.1, 50000 )
SetCameraposition(cam1,200,30,200)
CreateObjectsphere(man1,2,6,12)
SetObjectposition(man1,200,30,200)
setobjectvisible(man1,0)
Create3DPhysicsDynamicBody(man1)
ovec = CreateVector3(0,0,0) // offset
rvec = CreateVector3(0,0,0) // rotation
Create3DPhysicsCharacterController(man1,1,ovec,rvec,0.5)
Set3DPhysicsCharacterControllerJumpSpeed(man1,1.5)
Set3DPhysicsCharacterControllerFallSpeed(man1,1.5)
Set3DPhysicsCharacterControllerGravity(man1,3)
//SetObject3DPhysicsFriction(man1,1000)
//SetObject3DPhysicsAnisotropicFriction(man1,1)
//SetObject3DPhysicsRollingFriction(man1,255)
Set3DPhysicsCharacterControllerMaxSlope(man1,20)
SetObjectCollisionMode(man1,1)
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
setrawmousevisible(0)
SetRawMousePosition(width#/2,height#/2)
do
Print( ScreenFPS())
Print( "lightningDist= " + str(lightningDist))
// mouse and keys xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
mouseX# = (GetRawMouseX()-width#/2)*0.2
mouseY# = (GetRawMouseY()-height#/2)*0.2
RotateCameraLocalX(cam1,mouseY#)
SetCameraRotation(cam1,GetCameraAngleX(cam1),GetObjectAngleY(man1),0)
If GetCameraAngleX(cam1)>80 Then SetCameraRotation(cam1,80,GetCameraAngleY(cam1),0)
If GetCameraAngleX(cam1)<-80 Then SetCameraRotation(cam1,-80,GetCameraAngleY(cam1),0)
strafe# = (GetRawKeyState(68) - GetRawKeyState(65))
move# = (GetRawKeyState(87) - GetRawKeyState(83))
Move3DPhysicsCharacterController(man1,strafe#,move#,10)
Rotate3DPhysicsCharacterController(man1,GetCameraAngleY(cam1)+mouseX#)
if GetRawKeyPressed(32)
Jump3DPhysicsCharacterController(man1)
endif
Step3DPhysicsWorld()
SetCameraPosition(cam1,GetObjectX(man1),GetObjectY(man1)+1,GetObjectZ(man1))
// xxxxxxxxxxxxxxxxxxxxxxxxxxxx THUNDER and LIGHTNING
if lightning=0
lightning=1
lightningtime=Random(25,400)
lightningX=Random(1,1000)
lightningZ=Random(1,1000)
thunderpick=Random(1,9)
boltpick=Random(1,6)
duration=random(5,40)
Yrot=random(1,360)
EndIf
lightningclock=lightningclock+1
If lightningclock>lightningtime
flashtime=flashtime+1
SetPointLightPosition(light1,lightningX,50,lightningZ)
If boltpick=1
playBolt=bolt1
ElseIf boltpick=2
playBolt=bolt2
ElseIf boltpick=3
playBolt=bolt3
ElseIf boltpick=4
playBolt=bolt4
ElseIf boltpick=5
playBolt=bolt5
ElseIf boltpick=6
playBolt=bolt6
EndIf
SetObjectPosition(playBolt,lightningX,100,lightningZ)
lightningDist=Abs(GetObjectX(man1)-GetObjectX(playBolt))+Abs(GetObjectZ(man1)-GetObjectZ(playBolt))
if angleChoice=0
angleChoice=1
SetObjectRotation(playBolt,0,random(1,360),0)
endif
boltFlash=Random(1,2)
If boltFlash=1
SetObjectVisible(playBolt,1)
SetPointLightRadius(light1,5000)
ElseIf boltFlash=2
SetObjectVisible(playBolt,0)
SetPointLightRadius(light1,0)
EndIf
thunderVol = 25000 / lightningDist
If thunderVol<10 then thunderVol=10
If thunderVol>100 then thunderVol=100
If thunderpick=1 Then PlaySound(thunder1,thunderVol)
If thunderpick=2 Then PlaySound(thunder2,thunderVol)
If thunderpick=3 Then PlaySound(thunder3,thunderVol)
If thunderpick=4 Then PlaySound(thunder4,thunderVol)
If thunderpick=5 Then PlaySound(thunder5,thunderVol)
If thunderpick=6 Then PlaySound(thunder6,thunderVol)
If thunderpick=7 Then PlaySound(thunder7,thunderVol)
If thunderpick=8 Then PlaySound(thunder8,thunderVol)
If thunderpick=9 Then PlaySound(thunder9,thunderVol)
thunderpick=0
If flashtime > duration
if playBolt then SetObjectVisible(playBolt,0)
SetPointLightRadius(light1,0)
playBolt=0
boltFlash=0
flashtime=0
lightning=0
lightningclock=0
angleChoice=0
EndIf
EndIf
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
SetRawMousePosition(width#/2,height#/2)
Sync()
if GetrawKeyPressed(27) then end
loop
Never play leap frog with a unicorn.
