When one object is loaded, for example, it works.
When 2 objects load - does not work.
// Project: simple space game
// Created: 2017-04-01
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "simple space game " )
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
global object_id
object_id=100
global image_id
image_id=100
SetCameraRange( 1, 0.1, 4000 )
gosub _load_sky_box:
do
rem Move camera
if ( GetRawKeyState( 87 ) ) then MoveCameraLocalZ( 1, 4 )
if ( GetRawKeyState( 83 ) ) then MoveCameraLocalZ( 1, -4 )
if ( GetRawKeyState( 65 ) ) then MoveCameraLocalX( 1, -4 )
if ( GetRawKeyState( 68 ) ) then MoveCameraLocalX( 1, 4 )
rem rotate camera
if ( GetPointerPressed() )
startx# = GetPointerX()
starty# = GetPointerY()
angx# = GetCameraAngleX(1)
angy# = GetCameraAngleY(1)
pressed = 1
endif
if ( GetPointerState() = 1 )
fDiffX# = (GetPointerX() - startx#)/1.0
fDiffY# = (GetPointerY() - starty#)/1.0
newX# = angx# + fDiffY#
if ( newX# > 89 ) then newX# = 89
if ( newX# < -89 ) then newX# = -89
SetCameraRotation( 1, newX#, angy# + fDiffX#, 0 )
endif
Print ( ScreenFPS())
print (GetCameraX(1))
print (GetCameraY(1))
print (GetCameraZ(1))
SetObjectPosition( space_box_id, GetCameraX(1), GetCameraY(1), GetCameraZ(1) )
SetObjectPosition( sun_object_id, GetCameraX(1), GetCameraY(1), GetCameraZ(1)+1500 )
Sync()
loop
end
_load_sky_box:
space_box_id=free_object()
space_image_id=free_image()
CreateObjectBox( space_box_id, 2000, 2000, 2000 )
LoadImage ( space_image_id,"space.jpg" )
setobjectimage (space_box_id,space_image_id,0)
SetObjectCullMode( space_box_id, 0 )
SetObjectLightMap( space_box_id, 0 )
SetObjectLightMode( space_box_id, 0 )
sun_object_id=free_object()
sun_image_id=free_image()
LoadImage ( sun_image_id,"sun.jpg" )
setobjectimage (sun_object_id,sun_image_id,0)
SetObjectCullMode( sun_object_id, 0 )
SetObjectLightMap( sun_object_id, 0 )
SetObjectLightMode( sun_object_id, 0 )
return
function free_image()
inc image_id
while GetImageExists(image_id)=1
inc image_id
endwhile
endfunction image_id
function free_object()
inc object_id
while GetObjectExists(object_id)=1
inc object_id
endwhile
endfunction object_id
See for yourself