New update with the Bengismo contribution to reverse the mirror image.
// Project: mirror
// Created: 2019-01-02
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "mirror" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
`train
for i= 1 to 20
createobjectbox(i,2,2,4)
setobjectposition(i,0,0,2)
fixobjectpivot(i)
setobjectposition(i,0,0,-i*4.5)
next i
setobjectvisible(1,0)
CreateObjectCapsule(30,2.3,5,2)
setobjectposition(30,0,0,2)
FixObjectToObject(30,2)
`waypoints
for i= 1 to 5
createobjectsphere(i+20,1,10,10)
next i
setobjectposition(21,-20,0,30)
setobjectposition(22,30,0,50)
setobjectposition(23,40,0,0)
setobjectposition(24,20,0,-30)
setobjectposition(25,-10,0,-20)
`----------
createobjectbox(100,1300,1,1300)
setobjectcolor(100,100,80,30,0)
setobjectposition(100,0,-2,0)
ob=100
for i= 1 to 30
inc ob
createobjectbox(ob,3,5+random(0,5),3)
setobjectrotation(ob,0,random(0,360),0)
moveobjectlocalz(ob,100+random(0,100))
next
`sky
createobjectsphere(1200,2000,10,10)
SetObjectColorEmissive(1200,0,0,50)
SetObjectCullMode(1200,0)
`for camera shaking
createobjectbox(300,0,0,0)
`mirror object
createobjectbox(400,0.6,0.3,0)
setobjectposition(400,0,1,1)
fixobjecttoobject(400,6)
`Red pilote
pilote=401
createobjectsphere(pilote,0.2,10,10)
SetObjectColorEmissive(pilote,255,0,0)
SetObjectLightMode(pilote,0)
fixobjecttoobject(pilote,8)
setobjectposition(pilote,0.96,0.8,0)
SetSunActive(0)
SetAmbientColor(40,40,40)
createpointlight(1,0,0,0,80,255,255,0)
createpointlight(2,0,0,0,50,0,255,0)
createpointlight(3,0,0,0,80,255,0,0)
SetCameraRange(1,0.1,50000)
setcameraposition(1,-130,60,-130)
SetCameraLookAt(1,0,0,0,0)
ob=21
ima=0
counter=0
do
SetObjectLookAt(1,getobjectx(ob),getobjecty(ob),getobjectz(ob),0)
MoveObjectLocalZ(1,0.1)
x#=getobjectx(1)
y#=getobjecty(1)
z#=getobjectz(1)
obx#=getobjectx(ob)
oby#=getobjecty(ob)
obz#=getobjectz(ob)
dis#=distance#(x#,y#,z#,obx#,oby#,obz#)
if dis#<2 then ob=ob+1
if ob>25 then ob=21
for i= 2 to 20
//point object i,object position x(i-1),0,object position z(i-1)
SetObjectLookAt(i,getobjectx(i-1),0,getobjectz(i-1),0)
dx#=getobjectx(i-1)-getobjectx(i)
dz#=getobjectz(i-1)-getobjectz(i)
dist#=sqrt((dx#*dx#)+(dz#*dz#))
if dist#>5 then MoveObjectLocalZ( i,0.1)
next i
`camera shaking
setobjectposition(300,0,0,0)
MoveObjectLocalZ(300,0.005)
mv#=mv#+12
setobjectrotation(300,0,mv#,0)
tx#=getobjectx(300)
tz#=getobjectz(300)
`mirror
SetCameraLookAt(1,getobjectx(8),getobjecty(8),getobjectz(8),0)
render()
inc ima,1
getimage(ima,340,250,320,320)
ClearScreen()
deleteimage(ima-1)
setcameraposition(1,getobjectx(6)+tx#,getobjecty(6)+1.5+(tz#/5),getobjectz(6)+tz#)
SetCameraLookAt(1,getobjectx(4),0,getobjectz(4),0)
setobjectimage(400,ima,0)
`revers mirror BENGISMO METHOD *******************************
SetObjectScale(400,-1,1,1)
SetObjectCullMode(400,2)
`**************************************************************
setpointlightposition(1,getobjectx(1),10,getobjectz(1))
setpointlightposition(2,getobjectx(9),2,getobjectz(9))
`pilote light
setpointlightposition(3,GetObjectWorldX(401),0.8,GetObjectWorldZ(401))
counter=counter+1
if counter=50 then counter=0
if counter<20 then SetPointLightRadius(3,50) else SetPointLightRadius(3,0)
if counter<20 then SetObjectColor(401,255,0,0,0) else SetObjectColor(401,0,0,0,0)
Print( ScreenFPS() )
Sync()
loop
function distance#(x1#,y1#,z1#,x2#,y2#,z2#)
value#=sqrt(((x2#-(x1#))^2)+((y2#-(y1#))^2)+((z2#-(z1#))^2))
ENDFUNCTION value#
I'm not a grumpy grandpa