CONST idInfiniteJumps
= 4
goalGlyph
= "C" + STR$(_RGB32(255, 255, 255)) + "e10f10g10 h8e8f6g6 h4 e4f2g1"airJumpGlyph
= "C" + STR$(_RGB32(255, 255, 255)) + "e10f10g10h10"gravity = .8
thisLevel = 1
Restart:
setLevel thisLevel
processInput
doPhysics
adjustCamera
drawObjects
IF restartRequested
THEN restartRequested
= false:
GOTO Restart
this = newObject
obj(this).id = idWater
FOR i
= 1 TO totalObjects
_PUTIMAGE (obj
(i
).x
+ camera
, obj
(i
).y
), obj
(i
).img
DRAW "bm" + STR$(obj
(goal
).x
+ camera
) + "," + STR$(obj
(goal
).y
+ obj
(goal
).h
/ 2) DRAW "bm" + STR$(obj
(i
).x
+ camera
) + "," + STR$(obj
(i
).y
+ obj
(i
).h
/ 2) obj(i).x = obj(i).x - obj(i).xv
IF obj
(i
).x
+ obj
(i
).w
< 0 THEN obj
(i
).x
= arenaWidth
LINE (obj
(i
).x
+ camera
/ 2.5, obj
(i
).y
)-STEP(obj
(i
).w
, obj
(i
).h
), _RGBA32(255, 255, 255, 30), BF
_PUTIMAGE (obj
(i
).x
+ camera
/ obj
(i
).xv
, obj
(i
).y
), obj
(i
).img
obj(hero).alive = true
obj(hero).yv = 0
restartRequested = true
IF obj
(hero
).x
+ obj
(hero
).w
< arenaWidth
+ _WIDTH THEN obj
(hero
).x
= obj
(hero
).x
+ 5
'IF _KEYDOWN(19712) THEN 'character goes left, screen goes right
' obj(hero).x = obj(hero).x + 5
'END IF
'IF _KEYDOWN(19200) THEN 'character goes right, screen goes left
' obj(hero).x = obj(hero).x - 5
'END IF
IF jumpKeyDown
= false
AND (obj
(hero
).standing
= true
OR airJumps
> 0) THEN IF airJumps
> 0 THEN airJumps
= airJumps
- 1 jumpKeyDown = true
obj(hero).standing = false
lastJump! = 0
obj(hero).yv = obj(hero).yv - gravity * jumpFactor
lastJump! = lastJump! + 1
obj(hero).yv = obj(hero).yv - gravity * jumpFactor
jumpKeyDown = false
camera
= _WIDTH / 4 - obj
(hero
).x
IF camera
< -arenaWidth
THEN camera
= -arenaWidth
LINE (obj
(hero
).x
+ camera
, obj
(hero
).y
)-STEP(obj
(hero
).w
, obj
(hero
).h
), obj
(hero
).
color, BF
obj(hero).standing = false
drowned = false
FOR j
= 1 TO totalObjects
IF obj
(j
).id
= idPlatform
THEN IF obj
(hero
).x
+ obj
(hero
).w
> obj
(j
).x
AND obj
(hero
).x
< obj
(j
).x
+ obj
(j
).w
THEN shadowCast = true
LINE ((obj
(hero
).x
- 3) + camera
, obj
(j
).y
+ 5)-STEP(obj
(hero
).w
+ 6, 2), _RGBA32(0, 0, 0, 30), BF
IF obj
(hero
).y
+ obj
(hero
).yv
+ gravity
< obj
(j
).y
- (obj
(hero
).h
- 5) THEN ELSEIF obj
(hero
).y
+ obj
(hero
).yv
+ gravity
<= obj
(j
).y
- (obj
(hero
).h
- 20) THEN obj(hero).standing = true
obj(hero).y = obj(j).y - (obj(hero).h - 5)
ELSEIF obj
(hero
).y
>= obj
(j
).y
- (obj
(hero
).h
- 20) THEN obj(hero).alive = false
obj(hero).yv = obj(hero).yv + gravity
IF obj
(hero
).yv
> gravityCap
THEN obj
(hero
).yv
= gravityCap
obj(hero).y = obj(hero).y + obj(hero).yv
obj(hero).yv = 0
hit%%
= obj1.x
+ obj1.w
> obj2.x
AND obj1.x
<= obj2.x
+ obj2.w
AND obj1.y
+ obj1.h
> obj2.y
AND obj1.y
< obj2.y
+ obj2.h
FUNCTION darken~&
(WhichColor~&
, ByHowMuch%
) darken~&
= _RGB32(_RED32(WhichColor~&
) * (ByHowMuch%
/ 100), _GREEN32(WhichColor~&
) * (ByHowMuch%
/ 100), _BLUE32(WhichColor~&
) * (ByHowMuch%
/ 100))
'the order of creation of objects is also the draw order
resetObjects
arenaWidth = 3200
totalPlatforms = 30
levelData.landColor
= _RGB32(194, 127, 67) levelData.waterColor
= _RGB32(33, 166, 188) levelData.grassColor
= _RGB32(83, 161, 72)
this = newObject
obj(this).id = idSky
addScene level
addWater
addClouds 5
platformDecoration
= "c" + STR$(_RGB32(166, 111, 67)) + " bd5 e10r1g10r1e10r1g10r1e10r1g10r1e10r1g10" levelData.symbolSpacingX = 11
levelData.symbolSpacingY = 11
FOR i
= 1 TO totalPlatforms
this = newObject
obj(this).id = idPlatform
obj
(this
).w
= RND * 200 + 50 obj
(this
).w
= obj
(this
).w
- (obj
(this
).w
MOD 20) firstPlatform = this
obj(this).h = 200
obj
(this
).x
= RND * (arenaWidth
/ totalPlatforms
) obj
(this
).h
= RND * 50 + 50 obj
(this
).x
= obj
(this
- 1).x
+ obj
(this
- 1).w
+ (RND * (arenaWidth
/ (totalPlatforms
* 1.5))) drawPlatform obj(this)
goal = newObject
obj(goal).id = idGoal
obj(goal).x = arenaWidth
obj(goal).h = 20
obj(goal).w = 20
hero = newObject
obj(hero).x = obj(firstPlatform).x
obj(hero).y = obj(firstPlatform).y - 25
obj(hero).w = 15
obj(hero).h = 30
obj(hero).alive = true
obj(hero).standing = true
totalObjects = totalObjects + 1
newObject& = totalObjects
DIM emptyObject
AS newObject
obj(i) = emptyObject
totalObjects = 0
SUB drawPlatform
(this
AS newObject
) LINE (0, 10)-STEP(this.w
- 1, this.h
- 1), levelData.landColor
, BF
FOR x
= -10 TO this.w
STEP levelData.symbolSpacingX
FOR y
= 15 TO this.h
+ 10 STEP levelData.symbolSpacingY
PSET (x
, y
), levelData.landColor
LINE (0, 0)-STEP(this.w
- 1, 20), levelData.grassColor
, BF
this = newObject
obj(this).id = idCloud
obj
(this
).x
= RND * arenaWidth
obj(this).h = 30
obj(this).w = arenaWidth / max
'green mountains, 2 layers
'farther range
this = newObject
firstItem = this
obj(this).img = obj(firstItem).img
obj(this).imgPointer = true
obj(this).id = idScene
obj
(this
).x
= RND * arenaWidth
obj(this).xv = 2.5
'closer range
this = newObject
firstItem = this
obj(this).img = obj(firstItem).img
obj(this).imgPointer = true
obj(this).id = idScene
obj
(this
).x
= RND * arenaWidth
obj(this).xv = 2