I just recently started a Platform Game Project and got my first level built. I went back to add in all the variables of what makes a game. I.E Player Health, Health Boost, Coins, Enemies...etc...
I ran into a problem when the player is attacked by the enemy my health decreases rapidly when it should only decrease by 1 every hit. The Health is effected by when either of his 2 sides touch the enemy. Determined by Raycast.
///////////////////////Kill Player 2/////////////////////
KillPlayerRight[2]= SpriteRayCastGroup(6, GetSpriteXByOffset(Character), GetSpriteYByOffset(Character), GetSpriteXByOffset(Character)+55, GetSpriteYByOffset(Character) )
KillPlayerLeft[2]= SpriteRayCastGroup(6, GetSpriteXByOffset(Character), GetSpriteYByOffset(Character), GetSpriteXByOffset(Character)-55, GetSpriteYByOffset(Character) )
If KillPlayerRight[2] = 1 or KillPlayerLeft[2]
PlayerHealth = PlayerHealth - 1
DeleteSprite(MonsterID[2])
endif
This works just fine ^ the only thing is I don't want to delete the sprite. I want there to be a recover time so the player can have a 2nd chance of killing it on his own.
If I don't delete the sprite the health decreases by a number greater than 1 throwing off the health cycle and killing the player.
My 2nd attempt.
////////////////////////////////Kill Player1/////////////////////////////////
KillPlayerRight[1]= SpriteRayCastGroup(5, GetSpriteXByOffset(Character), GetSpriteYByOffset(Character), GetSpriteXByOffset(Character)+55, GetSpriteYByOffset(Character) )
KillPlayerLeft[1]= SpriteRayCastGroup(5, GetSpriteXByOffset(Character), GetSpriteYByOffset(Character), GetSpriteXByOffset(Character)-55, GetSpriteYByOffset(Character) )
If KillPlayerRight[1] = 1 or KillPlayerLeft[1]
Recover1 = 1
endif
If Recover1 = 1
Recover()
endif
Function Recover()
Timer1 = Timer()
RecoverTime = 10
If Timer1 < RecoverTime
KillPlayerLeft[1] = 0
KillPlayerRight[1] = 0
KillMonster[1] = 0
endif
If Timer1 > RecoverTime
PlayerHealth = PlayerHealth - 1
recover1 = 0
ResetTimer()
endif
Endfunction
This is the first time iv even looked at timers and there are a few issues.
1. Sometimes it skips to 5-6-7 and continues to finish (Dosnt always start at 0 )
2. It does not turn off the Raycast. What I am trying to accomplish is the Characters Raycast Ignore the Enemy during the Recover Time.
Thanks in Advance, any advice is greatly appreciated.
http://crazyprogrammerproductions.webs.com/