Removed debug lines

This commit is contained in:
JJFlash 2022-11-01 08:43:12 +01:00
parent 5b062803ba
commit cd038a76b6
1 changed files with 181 additions and 202 deletions

View File

@ -1,202 +1,181 @@
Const MASK_SUBGROUP = 8 '0000 1000 Const MASK_SUBGROUP = 8 '0000 1000
Const MASK_WALK_LOWHALF = 24 '0001 1000 Const MASK_WALK_LOWHALF = 24 '0001 1000
Dim SHARED bMonster_Col as BYTE Dim SHARED bMonster_Col as BYTE
Dim SHARED bMonster_Row as BYTE Dim SHARED bMonster_Row as BYTE
Dim bMonster_Direction as BYTE Dim bMonster_Direction as BYTE
Dim bMonster_Lag as BYTE Dim bMonster_Lag as BYTE
Dim bMonster_PreviousTile as BYTE Dim bMonster_PreviousTile as BYTE
Dim SHARED bMonster_SpeedUpMode as BYTE Dim SHARED bMonster_SpeedUpMode as BYTE
Dim bMonster_MarkingMode as BYTE Dim bMonster_MarkingMode as BYTE
Dim bMonster_DelayFrame as BYTE Dim bMonster_DelayFrame as BYTE
Dim bMonster_Distance_TurnONSpeedUp as BYTE Dim bMonster_Distance_TurnONSpeedUp as BYTE
Dim bMonster_Distance_TurnOFFSpeedUp as BYTE Dim bMonster_Distance_TurnOFFSpeedUp as BYTE
Dim bManhattanDistance as BYTE Dim bManhattanDistance as BYTE
declare sub monsterMovement() STATIC declare sub monsterMovement() STATIC
sub initMonster() SHARED STATIC sub initMonster() SHARED STATIC
bMonsterIsOn = FALSE bMonsterIsOn = FALSE
if bSkillLevel < 8 then if bSkillLevel < 8 then
bTreasuresToActivateMonster = 8 - bSkillLevel bTreasuresToActivateMonster = 8 - bSkillLevel
end if end if
bMonster_Col = 1 bMonster_Col = 1
bMonster_Row = 1 bMonster_Row = 1
bMonster_Direction = EAST bMonster_Direction = EAST
bMonster_Lag = 10 bMonster_Lag = 10
bMonster_PreviousTile = SPACE bMonster_PreviousTile = SPACE
bMonster_SpeedUpMode = FALSE bMonster_SpeedUpMode = FALSE
bMonster_MarkingMode = FALSE bMonster_MarkingMode = FALSE
if bSkillLevel < 16 then if bSkillLevel < 16 then
bMonster_Distance_TurnONSpeedUp = 21 - bSkillLevel 'minimum: 6 bMonster_Distance_TurnONSpeedUp = 21 - bSkillLevel 'minimum: 6
bMonster_Distance_TurnOFFSpeedUp = 12 - shr(bSkillLevel, 1) 'minimum: 5 bMonster_Distance_TurnOFFSpeedUp = 12 - shr(bSkillLevel, 1) 'minimum: 5
end if end if
bMonster_DelayFrame = 9 '= Lag - 1 bMonster_DelayFrame = 9 '= Lag - 1
VOICE 2 OFF TONE 256 WAVE NOISE ADSR 0, 0, VOI2_S, VOI2_R 'monster sound VOICE 2 OFF TONE 256 WAVE NOISE ADSR 0, 0, VOI2_S, VOI2_R 'monster sound
'~ textat 33, 3, " " end sub
'~ textat 33, 4, " "
'~ textat 33, 21, " " sub handleMonster() SHARED STATIC
end sub Dim bMoveFrame as BYTE
sub handleMonster() SHARED STATIC bManhattanDistance = myByteABS(bPlayer_Row - bMonster_Row) + myByteABS(bPlayer_Col - bMonster_Col)
Dim bMoveFrame as BYTE if bManhattanDistance > bMonster_Distance_TurnONSpeedUp then
bMonster_SpeedUpMode = TRUE
bManhattanDistance = myByteABS(bPlayer_Row - bMonster_Row) + myByteABS(bPlayer_Col - bMonster_Col) else
'~ textat 33, 21, str$(bManhattanDistance) + " ", 11 'dark gray if bManhattanDistance < bMonster_Distance_TurnOFFSpeedUp then
if bManhattanDistance > bMonster_Distance_TurnONSpeedUp then if bMonster_SpeedUpMode then
bMonster_SpeedUpMode = TRUE if bMonster_Lag > 1 then
else bMonster_Lag = bMonster_Lag - 1
if bManhattanDistance < bMonster_Distance_TurnOFFSpeedUp then textat 33, 20, 11 - bMonster_Lag, 2 'red
if bMonster_SpeedUpMode then end if
if bMonster_Lag > 1 then bMonster_SpeedUpMode = FALSE
bMonster_Lag = bMonster_Lag - 1 VOICE 2 TONE 256 ADSR 0, 0, VOI2_S, VOI2_R
textat 33, 20, 11 - bMonster_Lag, 2 'red end if
end if end if
bMonster_SpeedUpMode = FALSE end if
VOICE 2 TONE 256 ADSR 0, 0, VOI2_S, VOI2_R if bMonster_SpeedUpMode then
end if VOICE 2 TONE shl(cword(bManhattanDistance), 8) ADSR 0, 0, 2, VOI2_R
end if call monsterMovement()
end if exit sub
if bMonster_SpeedUpMode then end if
VOICE 2 TONE shl(cword(bManhattanDistance), 8) ADSR 0, 0, 2, VOI2_R
call monsterMovement() if bMonster_DelayFrame then
exit sub bMonster_DelayFrame = bMonster_DelayFrame - 1
end if if bMonster_DelayFrame = 0 then bMoveFrame = bSkillLevel
else
if bMonster_DelayFrame then call monsterMovement()
bMonster_DelayFrame = bMonster_DelayFrame - 1 if bMoveFrame then bMoveFrame = bMoveFrame - 1
if bMonster_DelayFrame = 0 then bMoveFrame = bSkillLevel if bMoveFrame = 0 then bMonster_DelayFrame = bMonster_Lag - 1
else end if
call monsterMovement()
if bMoveFrame then bMoveFrame = bMoveFrame - 1 end sub
if bMoveFrame = 0 then bMonster_DelayFrame = bMonster_Lag - 1
end if sub monsterMovement() STATIC
Const MINUS_ONE = 255
'~ textat 33, 3, str$(bMonster_DelayFrame), 10 'light red Dim wPeekingLocation as WORD
'~ textat 33, 4, str$(bMoveFrame) + " ", 13 'light green Dim bMonster_PreviousColour as BYTE
end sub
Dim bTravelingDirection as BYTE
sub monsterMovement() STATIC
Const MINUS_ONE = 255 Dim bThisTileDistance as BYTE
Dim wPeekingLocation as WORD Dim bClosestDistance as BYTE
Dim bMonster_PreviousColour as BYTE Dim bThisTileRow as BYTE
Dim bThisTileCol as BYTE
Dim bTravelingDirection as BYTE Dim bClosestTileDirection as BYTE
Dim bPeekedDirection as BYTE FAST
Dim bThisTileDistance as BYTE
Dim bClosestDistance as BYTE Dim bWalkableDirections(4) as BYTE '0...3
Dim bThisTileRow as BYTE Dim bWalkableDirections_Count as BYTE FAST
Dim bThisTileCol as BYTE Dim bTrailDirections(4) as BYTE '0...3
Dim bClosestTileDirection as BYTE Dim bTrailDirections_Count as BYTE FAST
Dim bPeekedDirection as BYTE FAST '------------------------------------------------
wPeekingLocation = scrAddrCache(bMonster_Row) + bMonster_Col
Dim bWalkableDirections(4) as BYTE '0...3
Dim bWalkableDirections_Count as BYTE FAST bTravelingDirection = bMonster_Direction
Dim bTrailDirections(4) as BYTE '0...3
Dim bTrailDirections_Count as BYTE FAST bWalkableDirections_Count = MINUS_ONE
'------------------------------------------------ bTrailDirections_Count = MINUS_ONE
wPeekingLocation = scrAddrCache(bMonster_Row) + bMonster_Col
bClosestDistance = 255
bTravelingDirection = bMonster_Direction
bMonster_Direction = (bMonster_Direction - 1) AND 3 'starting from the Monster's right (going clockwise)
bWalkableDirections_Count = MINUS_ONE For bPeekedDirection = 1 to 4
bTrailDirections_Count = MINUS_ONE bPeekedTileContent = peek(wPeekingLocation + iDirections(bMonster_Direction))
bClosestDistance = 255 if (bPeekedTileContent AND MASK_ALL) = GROUP_CREATURES then bExitEvent = EVENT_PLAYER_CAUGHT : exit for 'Gotcha, Player!!
bMonster_Direction = (bMonster_Direction - 1) AND 3 'starting from the Monster's right (going clockwise) if (bPeekedTileContent AND MASK_WALK_LOWHALF) = GROUP_WALKABLE then
For bPeekedDirection = 1 to 4 if bPeekedTileContent = TRAIL then
bPeekedTileContent = peek(wPeekingLocation + iDirections(bMonster_Direction)) bWalkableDirections_Count = bWalkableDirections_Count + 1
bTrailDirections_Count = bTrailDirections_Count + 1
if (bPeekedTileContent AND MASK_ALL) = GROUP_CREATURES then bExitEvent = EVENT_PLAYER_CAUGHT : exit for 'Gotcha, Player!! bTrailDirections(bTrailDirections_Count) = bMonster_Direction
else
if (bPeekedTileContent AND MASK_WALK_LOWHALF) = GROUP_WALKABLE then if bPeekedDirection < 4 then 'ignoring the opposite travelled direction!
if bPeekedTileContent = TRAIL then bWalkableDirections_Count = bWalkableDirections_Count + 1
bWalkableDirections_Count = bWalkableDirections_Count + 1 bWalkableDirections(bWalkableDirections_Count) = bMonster_Direction
bTrailDirections_Count = bTrailDirections_Count + 1 'ALSO, find the closest tile to the player...
bTrailDirections(bTrailDirections_Count) = bMonster_Direction bThisTileRow = bMonster_Row : bThisTileCol = bMonster_Col
else if (bMonster_Direction AND 1) then 'odd number, vertical direction
if bPeekedDirection < 4 then 'ignoring the opposite travelled direction! bThisTileRow = bMonster_Row + cbyte(SGN(iDirections(bMonster_Direction)))
bWalkableDirections_Count = bWalkableDirections_Count + 1 else 'even number, horizontal direction
bWalkableDirections(bWalkableDirections_Count) = bMonster_Direction bThisTileCol = bMonster_Col + cbyte(iDirections(bMonster_Direction))
'ALSO, find the closest tile to the player... end if
bThisTileRow = bMonster_Row : bThisTileCol = bMonster_Col bThisTileDistance = myByteABS(bPlayer_Row - bThisTileRow) + myByteABS(bPlayer_Col - bThisTileCol)
if (bMonster_Direction AND 1) then 'odd number, vertical direction if bThisTileDistance < bClosestDistance then
bThisTileRow = bMonster_Row + cbyte(SGN(iDirections(bMonster_Direction))) bClosestDistance = bThisTileDistance
else 'even number, horizontal direction bClosestTileDirection = bMonster_Direction
bThisTileCol = bMonster_Col + cbyte(iDirections(bMonster_Direction)) end if
end if end if
bThisTileDistance = myByteABS(bPlayer_Row - bThisTileRow) + myByteABS(bPlayer_Col - bThisTileCol) end if
if bThisTileDistance < bClosestDistance then end if
bClosestDistance = bThisTileDistance
bClosestTileDirection = bMonster_Direction bMonster_Direction = (bMonster_Direction + 1) AND 3 'now going counter-clockwise
end if next bPeekedDirection
end if
end if if bExitEvent = EVENT_NONE then
end if if bTrailDirections_Count <> MINUS_ONE then
bMonster_Direction = bTrailDirections(myRandom(bTrailDirections_Count, 3))
bMonster_Direction = (bMonster_Direction + 1) AND 3 'now going counter-clockwise else
next bPeekedDirection if bWalkableDirections_Count = MINUS_ONE then
bMonster_Direction = (bTravelingDirection + 2) AND 3 'go to the opposite direction and start marking tiles
if bExitEvent = EVENT_NONE then bMonster_MarkingMode = TRUE
if bTrailDirections_Count <> MINUS_ONE then else
bMonster_Direction = bTrailDirections(myRandom(bTrailDirections_Count, 3)) if bWalkableDirections_Count = 2 then 'if there are *three* walkable tiles...
else bWalkableDirections_Count = bWalkableDirections_Count + 1
if bWalkableDirections_Count = MINUS_ONE then bWalkableDirections(bWalkableDirections_Count) = bClosestTileDirection
bMonster_Direction = (bTravelingDirection + 2) AND 3 'go to the opposite direction and start marking tiles end if
bMonster_MarkingMode = TRUE bMonster_Direction = bWalkableDirections(myRandom(bWalkableDirections_Count, 3))
else end if
if bWalkableDirections_Count = 2 then 'if there are *three* walkable tiles... end if
bWalkableDirections_Count = bWalkableDirections_Count + 1 if bWalkableDirections_Count AND (bWalkableDirections_Count <> MINUS_ONE) then bMonster_MarkingMode = FALSE 'if there are at least *two* walkable tiles...
bWalkableDirections(bWalkableDirections_Count) = bClosestTileDirection end if
end if
bMonster_Direction = bWalkableDirections(myRandom(bWalkableDirections_Count, 3)) '------------------------DRAW-------------------------------------------
end if if (bMonster_PreviousTile AND MASK_ALL) <> GROUP_TREASURE then
end if bMonster_PreviousTile = SPACE
if bWalkableDirections_Count AND (bWalkableDirections_Count <> MINUS_ONE) then bMonster_MarkingMode = FALSE 'if there are at least *two* walkable tiles... end if
end if if bMonster_MarkingMode then
bMonster_PreviousTile = bMonster_PreviousTile OR MASK_SUBGROUP
'------------------------DRAW------------------------------------------- end if
if (bMonster_PreviousTile AND MASK_ALL) <> GROUP_TREASURE then
bMonster_PreviousTile = SPACE charat bMonster_Col, bMonster_Row, bMonster_PreviousTile, bMonster_PreviousColour
end if
if bMonster_MarkingMode then bMonster_PreviousTile = peek(wPeekingLocation + iDirections(bMonster_Direction))
bMonster_PreviousTile = bMonster_PreviousTile OR MASK_SUBGROUP bMonster_PreviousColour = peek(VIC_COLOR_OFFSET + wPeekingLocation + iDirections(bMonster_Direction))
end if
if (bMonster_Direction AND 1) then 'odd number, vertical direction
charat bMonster_Col, bMonster_Row, bMonster_PreviousTile, bMonster_PreviousColour bMonster_Row = bMonster_Row + cbyte(SGN(iDirections(bMonster_Direction)))
else 'even number, horizontal direction
bMonster_PreviousTile = peek(wPeekingLocation + iDirections(bMonster_Direction)) bMonster_Col = bMonster_Col + cbyte(iDirections(bMonster_Direction))
bMonster_PreviousColour = peek(VIC_COLOR_OFFSET + wPeekingLocation + iDirections(bMonster_Direction)) end if
charat bMonster_Col, bMonster_Row, MONSTER, 2 'red
if (bMonster_Direction AND 1) then 'odd number, vertical direction VOICE 2 ON
bMonster_Row = bMonster_Row + cbyte(SGN(iDirections(bMonster_Direction)))
else 'even number, horizontal direction end sub
bMonster_Col = bMonster_Col + cbyte(iDirections(bMonster_Direction))
end if
charat bMonster_Col, bMonster_Row, MONSTER, 2 'red
VOICE 2 ON
'debug code right after -DRAW-
'~ for bMonsterDebug as BYTE = 0 to 3
'~ textat 33, 2 + bMonsterDebug, " "
'~ next bMonsterDebug
'~ if bWalkableDirections_Count <> MINUS_ONE then
'~ for bMonsterDebug as BYTE = 0 to bWalkableDirections_Count
'~ if bWalkableDirections(bMonsterDebug) = bMonster_Direction then
'~ textat 33, 2 + bMonsterDebug, str$(bWalkableDirections(bMonsterDebug)), 1 'white
'~ else
'~ textat 33, 2 + bMonsterDebug, str$(bWalkableDirections(bMonsterDebug)), 11 'gray
'~ end if
'~ next bMonsterDebug
'~ end if
end sub