06-10-2003, 08:00 AM
I wrote this so I can store values of different items in each tile for my bomberman clone Unibomber.
Code:
' By Seph
' Originally created for use in his Unibomber game.
' Who knows if he finished it by now...
DECLARE FUNCTION setITEM% (mapitem AS INTEGER, item AS INTEGER)
DECLARE FUNCTION getITEM% (mapitem AS INTEGER, item AS INTEGER)
' Each CONST must be a power of 2 (except 0 and 1)
CONST rBLANK = 0, rMAN = 1, rSOLID = 2, rBRICK = 4, rBOMB = 8, rEXPLO = 16
' Use the OR command to initially set all the "items" as TRUE that you want
mapitem% = rMAN OR rSOLID OR rBRICK OR rBOMB OR rEXPLO
' Use setITEM to change the value of a specific "item"
mapitem% = setITEM(mapitem%, rBRICK)
' Use getITEM to get the value of a specific "item"
CLS
PRINT "Blank:"; getITEM(mapitem%, rBLANK)
PRINT "Man: "; getITEM(mapitem%, rMAN)
PRINT "Solid:"; getITEM(mapitem%, rSOLID)
PRINT "Brick:"; getITEM(mapitem%, rBRICK)
PRINT "Bomb: "; getITEM(mapitem%, rBOMB)
PRINT "Explo:"; getITEM(mapitem%, rEXPLO)
PRINT
PRINT "mapitem% ="; mapitem%
PRINT
PRINT "Simple and easy to use! Not to mention it's stored in a small number =)"
FUNCTION getITEM% (mapitem AS INTEGER, item AS INTEGER)
IF item = 0 THEN getITEM% = ABS(mapitem% = item) ELSE getITEM% = ABS((mapitem% AND item) = item)
END FUNCTION
FUNCTION setITEM% (mapitem AS INTEGER, item AS INTEGER)
IF item = 0 THEN setITEM% = 0 ELSE setITEM% = ABS(mapitem% XOR item)
END FUNCTION
earn.