Sorry - couldnt resist
// Project: cubeexplode
// Created: 2018-08-24
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "cubeexplode" )
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
type _exploders
id
x#
y#
z#
dirx#
diry#
dirz#
endtype
explode as _exploders[10]
cubesize#=2
plane=CreateObjectPlane(40,40)
SetObjectRotation(plane,90,0,0)
SetObjectColor(plane,0,100,0,255)
SetObjectPosition(plane,0,-cubesize#,0)
cube= CreateObjectBox(cubesize#,cubesize#,cubesize#)
SetObjectColor(cube,0,0,255,255)
forward=1
forwardspeed#=.2
exploded=0
framestep#=timer()
restart=1
do
RotateObjectLocalY(cube,forwardspeed#)
if restart=1
SetObjectVisible(cube,1)
for a=0 to explode.length
explode[a].dirx# = random2(-0.8,0.8)
explode[a].diry# = random2(-0.8,0.8)
explode[a].dirz# = random2(-0.8,0.8)
explode[a].x# = 0
explode[a].y# = 0
explode[a].z# = 0
if GetObjectExists(explode[a].id) then SetObjectVisible(explode[a].id,1)
next
restart=0
release=0
endif
if GetRawKeyPressed(32)
SetObjectVisible(cube,0)
for a=0 to explode.length
explode[a].id = InstanceObject(cube)
explode[a].dirx# = random2(-0.8,0.8)
explode[a].diry# = random2(-0.8,0.8)
explode[a].dirz# = random2(-0.8,0.8)
explode[a].x# = 0
explode[a].y# = 0
explode[a].z# = 0
SetObjectPosition(explode[a].id,explode[a].x#,explode[a].y#,explode[a].z#)
SetObjectScale(explode[a].id,.2,.2,.2)
SetObjectColor(explode[a].id,0,0,255,255)
SetObjectVisible(explode[a].id,1)
exploded=1
restart=0
framestep#=timer()
next
endif
if exploded=1
for a=0 to explode.length
explode[a].x#=explode[a].x#+explode[a].dirx# / 20
explode[a].y#=explode[a].y#+explode[a].diry# /20
explode[a].z#=explode[a].z#+explode[a].dirz# /20
SetObjectPosition(explode[a].id,explode[a].x#,explode[a].y#,explode[a].z#)
if release=1 then SetObjectVisible(explode[a].id,0)
next
//framestep#=timer()
if timer()-framestep#>1.5
release=1
exlploded=0
endif
//framestep#=timer()
if timer()-framestep#>3
restart=1
exlploded=0
endif
endif
if forward=1 then inc forwardspeed#
if forward=0 then dec forwardspeed#
if forwardspeed# > 10
forwardspeed#=10
forward=0
endif
if forwardspeed# < -10
forwardspeed#=-10
forward=1
endif
Print("Press Space")
Print( ScreenFPS() )
Sync()
loop