Of course -- see attached! (Move the figure with WASD)
// Project: crazy-cow-0
// Created: 2017-07-10
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "Green Hero Box" )
SetWindowSize( 640, 480, 1, 0 )
SetWindowAllowResize( 0 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 3200, 2400 ) // doesn't have to match the window
//SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
//SetSyncRate( 90, 0 ) // 30fps instead of 60 to save battery
//SetVSync( 1 )
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
SetDefaultMagFilter( 1 )
SetDefaultMinFilter( 1 )
SetGenerateMipmaps( 0 )
SetRawMouseVisible(0)
SetBorderColor(0, 0, 0)
heroImg = LoadImage("hero.png")
BackdropImg = LoadImage("Backdrop.png")
BackdropSpr = CreateSprite(BackdropImg)
SetSpritePosition ( BackdropSpr, 0, 0 )
SetSpriteDepth ( BackdropSpr, 110 )
heroSpr = CreateSprite(heroImg)
SetSpritePosition ( heroSpr, 1578, 1157 )
SetSpriteDepth ( heroSpr, 100 )
setphysicsscale(0.05)
SetPhysicsGravity(0 , 0)
SetSpritePhysicsOn( heroSpr, 2)
SetSpritePhysicsCanRotate( heroSpr, 0 )
SetSpritePhysicsDamping( heroSpr, 20.0)
heroSpeed as Float = 500000.0
heroSkraat as float = 0.7
SetSpritePosition (heroSpr, GetVirtualWidth()/2, GetVirtualHeight()/2)
do
if GetRawKeyPressed(27) //Esc
End //Close App
endif
//SetSpriteAngle (heroSpr, GetSpriteAngle(heroSpr)+2)
// W
// A S D
//
// 8 directional navigation here:
if GetRawKeyState(65) // A, possibly in combination with W or S
if GetRawKeyState(87) // W
//SetSpriteAngle (heroSpr, 315)
SetSpritePhysicsForce(heroSpr,GetSpriteXByOffset(heroSpr),GetSpriteYByOffset(heroSpr),-heroSpeed*heroSkraat,-heroSpeed*heroSkraat)
elseif GetRawKeyState(83) // S
//SetSpriteAngle (heroSpr, 225)
SetSpritePhysicsForce(heroSpr,GetSpriteXByOffset(heroSpr),GetSpriteYByOffset(heroSpr),-heroSpeed*heroSkraat,heroSpeed*heroSkraat)
else
//SetSpriteAngle (heroSpr, 270)
SetSpritePhysicsForce(heroSpr,GetSpriteXByOffset(heroSpr),GetSpriteYByOffset(heroSpr),-heroSpeed, 0)
endif
endif
if GetRawKeyState(68) // D, possibly in combination with W or S
if GetRawKeyState(87) // W
//SetSpriteAngle (heroSpr, 45)
SetSpritePhysicsForce(heroSpr,GetSpriteXByOffset(heroSpr),GetSpriteYByOffset(heroSpr),heroSpeed*heroSkraat,-heroSpeed*heroSkraat)
elseif GetRawKeyState(83) // S
//SetSpriteAngle (heroSpr, 135)
SetSpritePhysicsForce(heroSpr,GetSpriteXByOffset(heroSpr),GetSpriteYByOffset(heroSpr),heroSpeed*heroSkraat,heroSpeed*heroSkraat)
else
//SetSpriteAngle (heroSpr, 90)
SetSpritePhysicsForce(heroSpr,GetSpriteXByOffset(heroSpr),GetSpriteYByOffset(heroSpr),heroSpeed,0)
endif
endif
if GetRawKeyState(87) and not GetRawKeyState(65) and not GetRawKeyState(68) // W (A or D not pressed)
//SetSpriteAngle (heroSpr, 0)
SetSpritePhysicsForce(heroSpr,GetSpriteXByOffset(heroSpr),GetSpriteYByOffset(heroSpr),0,-heroSpeed)
endif
if GetRawKeyState(83) and not GetRawKeyState(65) and not GetRawKeyState(68) // S (A or D not pressed)
//SetSpriteAngle (heroSpr, 180)
SetSpritePhysicsForce(heroSpr,GetSpriteXByOffset(heroSpr),GetSpriteYByOffset(heroSpr),0,heroSpeed)
endif
StepPhysics(1.0/60.0)
Sync()
loop