Ezrotate Demo of Night and Day by Jonk7th Sep 2005 17:27
|
---|
Summary This simple short demo shows a how to set night and day on an x model terrain using a sun and light source rotating around the terrain model. NB. Uses EZrotate Description Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com REM Project: Terrain x REM Created: 9/7/2005 18:15:12 REM REM ***** Main Source File ***** REM ****** DAY & NIGHT DEMO **** REM ** By John Keenleyside ***** global sun=3 global sunangle=0 global seconds global count posy#=90 posx#=0 perform checklist for graphics cards for c=1 to checklist quantity() name$=checklist string$(c) next c set graphics card name$ SET DISPLAY MODE 640,480,32 sync on : sync rate 0 : Autocam off : hide mouse : randomize timer(): backdrop on make camera 1 set current camera 1 set camera range 1,2,8300 set ambient light 10 load object "media\mesh.x",1 Position Object 1,0,0,0 make object sphere sun,150 position object sun,2000,0,6000 SET POINT LIGHT 0,object position X(sun),object position Y(sun),object position Z(sun) SET LIGHT RANGE 0,18000 make object sphere 2,200 hide object 2 Position Object 2,-1600,1000,2000 do text 0,40, "FPS :"+str$(screen fps()) text 0,80, "Sun Angle :"+str$(sunangle) text 0,100, "Player x POS :"+str$(object position x(2)) text 0,120, "Player z POS :"+str$(object position z(2)) gosub Movement gosub TimerS gosub sunmove sync loop Movement: posy#=posy#+(mousemovex()/4) posx#=posx#+(mousemovey()/4) posx#=posx# posy#=posy# Rotate Object 2,posx#,posy#,0 SET camera TO OBJECT ORIENTATION 1,2 POSITION CAMERA 1,object position x(2),object position y(2),object position Z(2) if upkey() then Move Object 2,4 if downkey() then Move Object 2,-4 if leftkey() then Move Object Left 2,4 if rightkey() then Move Object Right 2,4 return TimerS: seconds=count/100 cycle=Timer()/1000 if cycle=Timer()/1000 then count=count+1 return sunmove: if seconds=1 `Activate to slow time restore sun for l= 1 to 8 read d if sunangle=d then color backdrop rgb(d,d,d) next l position light 0,object position X(sun),object position Y(sun),object position Z(sun) EZro_SetEuler OBJECT ANGLE X(sun),OBJECT ANGLE Y(sun),OBJECT ANGLE Z(sun) EZro_SetPos OBJECT POSITION X(sun),OBJECT POSITION Y(sun),OBJECT POSITION Z(sun) EZro_Orbit 1,-500,0,2000,4500,0,2000,1 sunangle=sunangle+1 if sunangle=360 then sunangle=0 EZro_FindEuler Rotate Object sun,EZro_GetEulerX(),EZro_GetEulerY(),EZro_GetEulerZ() Position Object sun,EZro_GetPosX(),EZro_GetPosY(),EZro_GetPosZ() count=0 endif `Activate to slow time return sun: data 4,170,170,255, 10,200,200,255, 140,170,170,255, 100,160,60,60 data 176,40,40,80, 186,0,0,20, 344,60,150,200, 355,150,150,200 |