Behdadsoft, are you actually trying or you just hoping someone does your project for you? Have you tried reading the help file?
That code says if the sprite doesn't exist then create it by cloning the original ground sprite. It will then position the sprite and set it's size (setting size is necessary when dealing with percentage)
rem Landscape App
setVirtualResolution(1200,800)
AddVirtualJoystick(1,68,750,64)
AddVirtualButton (1,1132,750,64)
rem Create Sprite
spr = createSprite(0)
setSpriteSize(spr,32,64)
setSpriteOffset(spr,16,32)
setSpritePositionByOffset(spr,650,0)
setSpritePhysicsOn(spr,2)
setSpritePhysicsCanRotate(spr,0)
boxman = spr
// Load ground Texture
img = LoadImage ("Texture.png")
ground = CreateSprite(img)
setSpriteAnimation(ground,128,128,2)
SetSpriteVisible(ground,0)
// Create top of ground tiles
for x = 0 to 10
y = 100
spr = 100+x
cloneSprite(spr, ground)
setspritephysicson(spr, 1)
setspriteframe(spr, 2)
setspritevisible(spr, 1)
y = 800-384
SetSpritePosition(spr, x*128, y)
next x
// Create ground fill tiles
for y = 0 to 1
for x = 0 to 10
spr = spr + 1
cloneSprite(spr, ground)
setspriteframe(spr, 1)
setspritevisible(spr, 1)
SetSpritePosition(spr, x*128, 544+y*128)
next x
next y
repeat
SetSpritePhysicsVelocity (boxman, GetVirtualJoystickX(1)*300, GetSpritePhysicsVelocityY(boxman))
// Handle jumping
jump = GetVirtualButtonPressed(1)
if jump > 0
if (Press = 0)
setSpritePhysicsVelocity(boxman,getSpritePhysicsVelocityX(boxman), -jump*160)
Press = 1
endif
endif
if getSpritePhysicsVelocityY(boxman) = 0 Then Press = 0
Sync()
until getrawkeypressed(27) = 1
end
You can use
Tiled to create maps and import them using my
TMX library. It doesn't use physics for collision, so you'd have to manually set that up.