Yes. The slower camera was an example of how to move the view offset.
Thus:
// set "wayToAdjustView" to "1" for a direct way - set to "2" to have a more fluid camera movement
Turn setPhysicsDebugOn() to see what's in the way, and figure it out
Edit:
Ok I fixed the camera movement a bit, one line added:
this was added:
viewSpeed# = abs((x# - 50)- viewX#) * 0.03
rem Landscape App
SetDisplayAspect( -1 )
AddVirtualJoystick(1,6,91,8)
AddVirtualButton (1,95,91,5)
rem Create Sprite
spr = createSprite(0)
setSpriteSize(spr,4,8)
setSpriteOffset(spr,2,4)
setSpritePositionByOffset(spr,50,50)
setSpritePhysicsOn(spr,2)
setSpritePhysicsCanRotate(spr,0)
boxman = spr
ground = CreateSprite(0)
setSpriteAnimation(ground,128,128,2)
SetSpriteVisible(ground,0)
// create a ground for boxman to walk on, make it striped to see the view moving
dim physicalGround[20] as integer
odd = 0
for n = 0 to 20
physicalGround[n] = createSprite(0)
setSpriteSize(physicalGround[n], 5, 5)
if odd = 1 then setSpriteColor(physicalGround[n], 150, 50, 50, 255) else setSpriteColor(physicalGround[n], 50, 150, 50, 255)
setSpritePosition(physicalGround[n], n * 5, 95)
setSpritePhysicsOn(physicalGround[n], 1)
odd = 1 - odd
next n
// set "wayToAdjustView" to "1" for a direct way - set to "2" to have a more fluid camera movement
wayToAdjustView = 2
viewX# = 0.0
viewXTarget# as float
viewSpeed# = 0.1
do
x# = getSpriteX (boxman)
y# = getSpriteY (boxman)
if wayToAdjustView = 1 then SetViewOffset( x# - 50.0, 0 ) // x# - 50 will set the view to show the sprite in the middle of the screen
if wayToAdjustView = 2
viewXTarget# = x# - 50.0 // The views target x value is to have boxman in the middle of the screen
viewSpeed# = abs((x# - 50)- viewX#) * 0.03
if viewXTarget# > viewX# then viewX# = viewX# + viewSpeed#
if viewXTarget# < viewX# then viewX# = viewX# - viewSpeed#
setViewOffset(viewX#, 0)
endif
Print ("Joystick X: " + str(GetVirtualJoystickX(1)))
Print ("Joystick Y: " + str(GetVirtualJoystickY(1)))
SetSpritePhysicsVelocity (boxman, GetVirtualJoystickX(1) * 10, GetSpritePhysicsVelocityY(boxman))
jump = GetVirtualButtonPressed(1)
if jump>0
if (Press = 0)
setSpritePhysicsVelocity(boxman,getSpritePhysicsVelocityX(boxman),-jump*60)
Press = 1
endif
endif
if getSpritePhysicsVelocityY(boxman) = 0 Then Press = 0
Print (cspr)
Sync()
loop
I don't understand problem number two, if what you want is a wall on the left or that there is one present that you don't want.
The floor I made was just an example so you can see the view move. You can have whatever you want there.
But since you are moving the view offset, the top/bottom/left/right barriers are not present any longer.
My hovercraft is full of eels