| Home CBM ASCII-X BASIC Disk Commands Enter RUN mode Program Format Secret Variables Variable Format Expressions Keywords (divide) (equal) (less) (minus) (more) (multiply) (plus) (power) Abs And Append Asc Atn Auto Backup Bank Begin Bend Bload Boot Box Bsave Bump Catalog Char Chr Circle Close Clr Cmd Collect Collision Color Concat Cont Copy Cos Data Dclear Dclose Dec Def Delete Dim Directory Dispose Dload Do Dopen Draw Ds Ds string Dsave Dverify El Else End Envelope Er Err Exit Exp Fast Fetch Filter Fn For Fre Get Get num Getkey Go Gosub Goto Graphic Gshape Header Help Hex If Input Input num Instr Int Joy Key Left Len Let List Load Locate Log Loop Mid Monitor Movspr New Next Not Off On Open Or Paint Peek Pen Pi Play Pointer Poke Pos Pot Print num Pudef Quit Rclr Rdot Read Record Rem Rename Renumber Restore Resume Return Rgr Right Rlum Rnd Rreg Rspcolor Rsppos Rsprite Run Rwindow Save Scale Scnclr Scratch Sgn Sin Sleep Slow Sound Spc Sprcolor Sprdef Sprite Sprsav Sqr Sshape St Stash Step Stop Str Swap Sys Tab Tan Tempo Then Ti Ti string To Trap Troff Tron Until Using Usr Val Verify Vol Wait While Width Window Xor Syntax Tokens C128 D64plus Disk Escape Codes Hardware PCxface PETSCII Pet2asc Futurama IBM PC-AT Contact Games Glossary Hall of fame Hall of shame Miscellaneous Privacy policy Programming Twisty puzzles |
BUMP ( videoType )
Return the sprite(s) (as bit values) involved in a videoType "collision".
The BUMP function returns a value which is the bit-wise OR of all sprites involved in all "collsions" of the specified videoType that have occured since the last (identical) BUMP command/statemet. It is used to check for sprite "collisions"; there are two types:
The value returned, collisions, is a bit-wise OR of all sprites involved. Note that multiplie "collisions" may be recorded by BASIC before your program has the chance to read the BUMP value. So, a "collsion" involving sprite 1 will have bit 0 (1-1) set; a "collision" involving sprite 2 will have bit 1 (2-1) set; a "collision" involving sprite 3 will have bit 2 (3-1) set, and so on... BUMP will return all collisions that have occured since the last call to BUMP (of the same videoType). So for example, if sprites 1 and 2 "collide" in one frame of video, then BUMP(1) will have a value of 21-1 + 22-1 = 20 + 21 = 1 + 2 = 3. If another collision occurs before you read BUMP, the bit values of the involved sprites will be OR'ed with the previous BUMP value. So (to continue the previous example), a "collision" of sprites 2 and 3, will OR the BUMP(1) value with sprite 3 ( 22 ); thus reading BUMP(1) would return 21-1 + 22-1 (previous bits) + 23-1 (new value) = 20 + 21 + 22 = 1 + 2 + 3 = 7 in this compound example It is important to realize that BUMP does not tell you which pixel in a sprite(s) caused the "collision". Also important is that BUMP will report all "collisions" that have occured (since the last read of the corresponding vType)... so if sprites 1 and 2 have collided, and also sprite 2 and 3 have collided, then BUMP will return 7 (1 + 2 + 3), but this does not neccessarily mean that sprites 1 and 3 have collided. Sorry if that doesn't make much; I guess you need to play with BASIC in order to understand what I'm talking about... BUMP may be used any time, but it is often used in COLLISION routines (so-called interrupt routines). If vType is ommited, or is an invalid expression, SYNTAX ERROR is generated. If vType is not numeric, TYPE MISMATCH ERROR occurs. If vType is floating-point, it will (effectively) be converted with INT. If the (converted) vType is not legal (see table above), then ILLEGAL QUANTITY ERROR is generated. Examples:
© H2Obsession, 2014 |