Byte Knight, on Sat Jun 18, 2011 11:48 PM, said:
I didn't even know you could re-dim variables. I can now save two variables in my next game...
That's mentioned on the bB page:
http://www.randomter...mmands.html#dim
Quote
Note that more than one alias may be mapped to the same variable. This is useful for when you will inevitably need to reuse variables in multiple places.
But it's about the 5th paragraph down, so people might miss it. I'll put it in a "Did You Know?" box so it will be more noticeable.
I do it for a few variables that can be reused, but I especially do it for bit operations:
rem ****************************************************************
rem ****************************************************************
rem *
rem * Create aliases for variables.
rem *
rem ****************************************************************
rem '
rem ' (You can have more than one alias for each variable.)
rem '
rem '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
rem ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
rem '
rem ' All-purpose bits for various jobs.
rem '
rem ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
rem '
dim BitOp_All_Purpose_01 = t
dim BitOp0_Debounce_Reset = t
dim BitOp4_Toggle_Screen = t
dim BitOp5_B_Direction_X = t
dim BitOp6_B_Direction_Y = t
dim BitOp7_Missile0_Moving = t
rem ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
rem '
rem ' Player0/Missile0 direction bits.
rem '
rem ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
rem '
dim BitOp_P0_M0_Direction = u
dim BitOp0_Player0_Direction_Up = u
dim BitOp1_Player0_Direction_Down = u
dim BitOp2_Player0_Direction_Left = u
dim BitOp3_Player0_Direction_Right = u
dim BitOp4_Missile0_Direction_Up = u
dim BitOp5_Missile0_Direction_Down = u
dim BitOp6_Missile0_Direction_Left = u
dim BitOp7_Missile0_Direction_Right = u
I've had weird random problems with
def, so I'm back to just using
bit operations the old regular way. Using a separate name for each bit helps me know exactly what is going on at a glance.
Edited by Random Terrain, Sun Jun 19, 2011 12:16 AM.