Re: TIB: Lists


[Prev][Next][Index][Thread]

Re: TIB: Lists




Kevin J DeGraaf wrote:
> 
> SWISH 97 wrote:
> >
> > Hey, i was told that i need to make a list to have the items thing in
> my game
> > were people can buy items and if they have it it shows up on the screen
> but if
> > they dont it doesn't, can someone explain to me(us all) how to make a
> > list?-thanx-Frank
> 
> Another method exists which can be quite confusing, but saves lots of
> RAM.  The name of the technique is "bitwise manipulation," and is useful
> if you are recording only the _presence_ or _absence_ of an item.
> Examine the following code segments (keep in mind, comments cannot be
> included in TI-BASIC).
> 
> :0 -> INV   (* Sets up inventory variable.  Notice it is of type REAL,
> taking up ~20 bytes *)
> 
> :Input "Which item do you want to add: ",N
> :INV or 2^(N-1) -> INV
> 
> :Input "Which item do you want to check: ",N
> :If INV and 2^(N-1)
> :Then
> (* Statements-if-player-has-item *)
> :Else
> (* Statements-if-player-lacks-item *)
> :End
> 
> :Input "Which item do you want to remove: ",N
> :If INV and 2^(N-1):INV-2^(N-1) -> INV
> 
> Input "Which item do you want to change: ",N
> :INV xor 2^(N-1) -> INV
> 
> Hope this helps!
> 
> Kevin J. DeGraaf
> Class of 1999, Unity Christian High School

I just saw your bit about using lists. While the math seems easy 
enough, I was wondering if you could explain, in plain language, just 
what exactly is happening. Thanks!

Jody Snider
jody1@alaska.net


References: