Update Super Man Game - Better code for checking collision between SuperMan and Walls
@@ -350,36 +350,34 @@ func checkwall oGame,oself,diffx,diffy
alist = [1,2,3]
return checkwall2(oGame,oself,diffx,diffy,aList)
+func checkpoint oGame,xPos,yPos,aList
+ nValue = oGame.aObjects[2].getvalue(xPos,yPos)
+ return inlist(nValue,aList)
+
+
func checkwall2 oGame,oself,diffx,diffy,aList
xPos = oSelf.x + diffx
yPos = oSelf.y + diffy
- nValue = oGame.aObjects[2].getvalue(xPos,yPos)
- nValue = inlist(nValue,aList)
- nValue = not nValue
- if nValue = 0 return nValue ok
-
+ if checkPoint(oGame,xPos,yPos,aList) return False ok
xPos = oSelf.x + diffx
yPos = oSelf.y + diffy + oSelf.height
- nValue = oGame.aObjects[2].getvalue(xPos,yPos)
- nValue = inlist(nValue,aList)
- nValue = not nValue
- if nValue = 0 return nValue ok
-
+ if checkPoint(oGame,xPos,yPos,aList) return False ok
xPos = oSelf.x + diffx + oSelf.width
yPos = oSelf.y + diffy
- nValue = oGame.aObjects[2].getvalue(xPos,yPos)
- nValue = inlist(nValue,aList)
- nValue = not nValue
- if nValue = 0 return nValue ok
-
+ if checkPoint(oGame,xPos,yPos,aList) return False ok
xPos = oSelf.x + diffx + oSelf.width
yPos = oSelf.y + diffy + oSelf.height
- nValue = oGame.aObjects[2].getvalue(xPos,yPos)
- nValue = inlist(nValue,aList)
- nValue = not nValue
- if nValue = 0 return nValue ok
-
- return nValue
+ if checkPoint(oGame,xPos,yPos,aList) return False ok
+ xPos = oSelf.x + diffx
+ yPos = oSelf.y + diffy + oSelf.height / 2
+ if checkPoint(oGame,xPos,yPos,aList) return False ok
+ xPos = oSelf.x + diffx + oSelf.width / 2
+ yPos = oSelf.y + diffy
+ if checkPoint(oGame,xPos,yPos,aList) return False ok
+ xPos = oSelf.x + diffx + oSelf.width / 2
+ yPos = oSelf.y + diffy + oSelf.height / 2
+ if checkPoint(oGame,xPos,yPos,aList) return False ok
+ return True
func checkopenwall oGame
if oGameState.score = 900
