Hi guys, I am making a space ship game where I am trying to fly a space ship... gravity is supposed to drag the ship down, and obviously pressing up will thrust it up... and then when you stop thrust it starts dropping back to the ground... but I find that I cant get it to accelerate, it just goes at a constant speed...
My apologies if this shows up twice, I tried to post it before and it just dissapeared.
// Project: 2D fly the triangle
// Created: 2018-02-13
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "2D fly the triangle" )
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
CreateSprite ( LoadImage ( "space1.jpg" ) )
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
//Accelerometer gravity
spr = CreateSprite ( LoadImage ( "spaceship2.png" ) )
SetSpriteSize (spr,80,80)
SetPhysicsGravity(0 ,100 )
SetPhysicsScale (.04)
SetSpritePosition (spr,160,200)
SetJoystickScreenPosition ( 50, 300, 64 )
SetSpritePhysicsOn(spr,2)
SetSpriteDepth(spr,0)
SetSpritePhysicsCanRotate (spr,0)
SetSpritePhysicsMass (spr,60)
setspritephysicsisbullet(spr,1)
SetSpritePhysicsFriction(spr,0.1)
SetSpritePhysicsRestitution(spr,0.25)
SetSpritePhysicsDamping(spr,0.25)
do
Print ( "Flippityflop" )
x# = GetJoystickX ( )
y# = GetJoystickY ( )
Print ( x# )
Print ( y# )
SetSpritePosition ( spr, GetSpriteX ( spr ) + x#, GetSpriteY ( spr ) + y# )
if ( GetSpriteX ( spr ) < 30 )
SetSpriteX ( spr, 30 )
endif
if ( GetSpriteX ( spr ) > 768 )
SetSpriteX ( spr, 768 )
endif
if ( GetSpriteY ( spr ) < 30 )
SetSpriteY ( spr, 30 )
endif
if ( GetSpriteY ( spr ) > 1024 )
SetSpriteY ( spr, 1024 )
endif
Sync()
loop