Okay, here is the code that is in the zip file above.
// Project: FallingUp
// Started: October 7, 2014
// set window properties
SetWindowTitle("Falling Up")
SetVirtualResolution(600, 480)
Gosub _Setup
Gosub _SetupScreen
// Debugging Text Setup
CreateText(1, ""): CreateText(2, ""): CreateText(3, "")
SetTextSize(1, 12): SetTextSize(2, 12): SetTextSize(3, 12)
SetTextPosition(1, 0, 420): SetTextPosition(2, 0, 440): SetTextPosition(3, 0, 400)
do
Gosub _MoveHero
// Detect The Ground and Climable objects - **** Climable Not Working With Or Without Physics!!!
Climable = PhysicsRayCastGroup(canClimb, GetSpriteX(sprHero)+7, GetSpriteY(sprHero)+11, GetSpriteX(sprHero)+16, GetSpriteY(sprHero)+24)
Grounded = PhysicsRayCastGroup(onGround, GetSpriteX(sprHero)+7, GetSpriteY(sprHero)+11, GetSpriteX(sprHero)+7, GetSpriteY(sprHero) + 24)
// Display Variables for Debugging
SetTextString(1, "Grounded: " + str(Grounded))
SetTextString(2, "Climable: " + str(Climable))
SetTextString(3, "X: " + (str(GetRawMouseX()) + " Y: " + str(GetRawMouseY())))
// Press ESC to Exit Program
if GetRawKeyPressed(27) = 1 then End
Sync()
loop
_MoveHero:
// Move Left or Right
SetSpritePhysicsVelocity(sprHero, (GetRawKeyState(39) - GetRawKeyState(37)) * 50, GetSpritePhysicsVelocityY(sprHero))
// Jumping
jump = GetRawKeyPressed(32)
if jump > 0 and Grounded = 1
SetSpritePhysicsVelocity(sprHero, GetSpritePhysicsVelocityX(sprHero), -jump * 100)
endif
// Climb Ladders or Ropes
climb = GetRawKeyState(38)
if climb > 0 and Climable = 1
SetSpritePhysicsVelocity(sprHero, GetSpritePhysicsVelocityX(sprHero), -climb * 50)
endif
Return
_Setup:
// Groups
canClimb = 1
onGround = 2
Enemy = 3
// Load Images
imgHero = LoadImage("man.png")
imgBaddie = LoadImage("baddie.png")
imgPlatLeft = LoadImage("platform2-16.png")
imgPlatMiddle = LoadImage("platform3-16.png")
imgPlatRight = LoadImage("platform4-16.png")
imgLadder = LoadImage("ladder-16.png")
imgPlatLadder = LoadImage("platformladder-16.png")
imgRope = LoadImage("rope-16.png")
// Setup Hero
hX# = 16.0: hY# = 348.0
sprHero = CreateSprite(imgHero)
SetSpritePosition(sprHero, hX#, hY#)
SetSpriteDepth(sprHero, 1)
SetSpritePhysicsOn(sprHero, 2)
SetSpritePhysicsCanRotate(sprHero, 0)
SetSpriteGroup(sprHero, canClimb)
// Physics Properties
SetPhysicsDebugOn()
SetPhysicsGravity(0, 100)
Return
_SetupScreen:
Gosub _Level1Data
// Create Level
BLOCK = 999: loc = 0: WX = 0: WY = 0
For Y = 1 to 24
For X = 1 to 32
if mid(m$[loc], X, 1) = "2" // Platform Left
Inc BLOCK
CreateSprite(BLOCK, imgPlatLeft)
SetSpritePosition(BLOCK, WX, WY)
SetSpritePhysicsOn(BLOCK,1)
SetSpriteGroup(BLOCK, onGround)
Endif
if mid(m$[loc], X, 1) = "3" // Platform Middle
Inc BLOCK
CreateSprite(BLOCK, imgPlatMiddle)
SetSpritePosition(BLOCK, WX, WY)
SetSpritePhysicsOn(BLOCK,1)
SetSpriteGroup(BLOCK, onGround)
Endif
if mid(m$[loc], X, 1) = "4" // Platform Right
Inc BLOCK
CreateSprite(BLOCK, imgPlatRight)
SetSpritePosition(BLOCK, WX, WY)
SetSpritePhysicsOn(BLOCK,1)
SetSpriteGroup(BLOCK, onGround)
Endif
if mid(m$[loc], X, 1) = "5" // Ladder
Inc BLOCK
CreateSprite(BLOCK, imgLadder)
SetSpritePosition(BLOCK, WX, WY)
SetSpriteDepth(BLOCK, 9)
SetSpritePhysicsIsSensor(BLOCK, 0)
SetSpriteGroup(BLOCK, canClimb)
Endif
if mid(m$[loc], X, 1) = "6" // Rope
Inc BLOCK
CreateSprite(BLOCK, imgRope)
SetSpritePosition(BLOCK, WX, WY)
SetSpriteDepth(BLOCK, 9)
SetSpritePhysicsIsSensor(BLOCK, 1)
SetSpriteGroup(BLOCK, canClimb)
Endif
if mid(m$[loc], X, 1) = "L" // Ladder Platform Combo
Inc BLOCK
CreateSprite(BLOCK, imgPlatLadder)
SetSpritePosition(BLOCK, WX, WY)
SetSpriteDepth(BLOCK, 9)
SetSpritePhysicsIsSensor(BLOCK, 1)
SetSpriteGroup(BLOCK, canClimb)
Endif
if mid(m$[loc], X, 1) = "B" // Enemies
Inc BLOCK
CreateSprite(BLOCK, imgBaddie)
SetSpritePosition(BLOCK, WX, WY)
SetSpritePhysicsOn(BLOCK,2)
SetSpritePhysicsCanRotate(BLOCK,0)
SetSpriteGroup(BLOCK, Enemy)
Endif
inc WX, 16
Next X
inc loc
inc WY, 16
WX = 0
Next Y
Return
_Level1Data:
Dim m$[24]
m$[0] = "23333333333333333333333333333334"
m$[1] = "11111116111116111111161111111111"
m$[2] = "11111116111116111111161111111111"
m$[3] = "1111111611B116111111161111111111"
m$[4] = "11111116123416111111161111111111"
m$[5] = "1233L416111116111111161111111111"
m$[6] = "11115116111116111111161111111111"
m$[7] = "11115116111116111111161111111111"
m$[8] = "11115116111116111111161111111111"
m$[9] = "11123416111116111111161112341111"
m$[10] = "1B111116111116111B11161111111111"
m$[11] = "23411116111116123334161111112L34"
m$[12] = "11111111111111111111111111111511"
m$[13] = "11111111111111111111111111111511"
m$[14] = "11111111111111111111111111111511"
m$[15] = "11111111111111111111111111111511"
m$[16] = "11111111111111111111111111111511"
m$[17] = "11111111111111111111111111111511"
m$[18] = "11111111111111112341111111111511"
m$[19] = "11111111111111111111111111111511"
m$[20] = "11111115234111111111111111234511"
m$[21] = "11111115111111111111111111111511"
m$[22] = "11111115111111111111111111111511"
m$[23] = "23333333333333333333333333333334"
Return
The attachment in the previous post is safe. I just included it, because the media is in there too.
I'll keep working on this, but any help would be greatly appreciated.
Thanks!!
JHA
Proverbs Challenge: http://pc.potentialsunleashed.com/