Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Prog. that stores values in a small INT
#1
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.
Reply
#2
*clap clap*

Good for you Seth. Guys please tell me if I am wrong here or if it is somewhere but shouldn't he at the very least apologize for his recent outburst?

Just a thought.
apanese girls love Japanese girls...Japanese girls looove Japanese girls lalalaaalaallaaaa...(PanAm : Japanese Girls)
Reply
#3
What?
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#4
Sorry for my recent outburts *confused*

Wink
earn.
Reply
#5
*BUMP* still freakin confused......
earn.
Reply
#6
Me confused too... Seph's done nothing to darth binary...
Reply
#7
Yeah.. i mean,, I've pissed everyone else but this giuy! why on earth is he pssed?
earn.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)