RSPPOS
BASIC keyword | |
Keyword: | RSPPOS |
Abbreviation: | R SHIFT+S |
Type: | Function |
Token code: | $ce $05 (206 5) |
Handling routine in BASIC ROM: |
|
List of all BASIC keywords |
Remark: This article describes the BASIC function RSPPOS in Commodore BASIC V7.0 or higher.
Type: Function General Programming-Syntax: RSPPOS(<sprite>, <n>)
The function RSPPOS is used to query the position and speed of a sprite.
The parameters have the following meaning:
- <sprite>: Number of the sprite whose position is queried. This value may be between 1 and 8, other values cause an abort with the error message ?ILLEGAL QUANTITY ERROR. If the parameter is missing, ?SYNTAX ERROR is output, if the parameter is a string, ?TYPE MISMATCH ERROR is output.
- <n>: This parameter specifies which sprite-specific value is to be determined and can take the following values:
- 0: Query X-coordinate (horizontal position) of the sprite; the result can be between 0 and 511.
- 1: Query Y-coordinate (vertical position) of the sprite; the result can be between 0 and 255.
- 2: Determine the speed of the sprite; the result can be between 0 and 15.
The angle of movement of a sprite cannot be queried (but calculated, see Examples).
Another sprite commands in BASIC 7.0 are MOVSPR, RSPCOLOR, RSPRITE, SPRCOLOR, SPRITE, SPRDEF and SPRSAV, also BUMP, COLLISION, GSHAPE and SSHAPE
Examples[edit | edit source]
IF RSPPOS(1,0)>343 THEN MOVSPR 1,0,+0
If the horizontal position of sprite 1 is greater than 343 (sprite is completely in the right frame area), it is moved to the X-coordinate 0. The vertical position remains unchanged.
V='RSPPOS(1,2):IF V<15 THEN MOVSPR 1,A#V+1
Stores the speed of sprite 1 in the variablen V and then increases it (if the maximum value has not yet been reached) by 1. Since the angle of movement cannot be queried directly (see the following example), it is stored in the variable A (for Angle).
100 GRAPHIC 1,1 : REM HIRES 110 REM SPRITE ERZEUGEN (GROSSES X) 120 DRAW 1, 0,0 TO 23,20 121 DRAW 1, 0,20 TO 23,0 130 S=1 : REM SPRITE-NUMMER 140 SSHAPE A$, 0,0,23,20 150 SPRSAV A$,S 160 SPRITE S,1,8,0,0,0,0 170 MOVSPR S,21,50 1000 GRAPHIC 0 : REM WIEDER TEXTMODUS 1010 PRINT "{clr}" 1020 AO=315 : REM ANGLE ORIGINAL 1030 V=3 : REM SPRITE-GESCHWINDIGKEIT 1100 MOVSPR S,AO#V 1110 XL=RSPPOS(S,0) 1120 YL=RSPPOS(S,1) 1200 DO 1210 X=RSPPOS(S,0):Y=RSPPOS(S,1) 1230 DX=XL-X:IF ABS(DX)>100 THEN DX=DX-512*SGN(DX) : REM BEREICHSUEBERLAUF X 1240 DY=Y-YL:IF ABS(DY)>100 THEN DY=DY-256*SGN(DY) : REM BEREICHSUEBERLAUF Y 1250 IF DY=0 THEN DY=1E-30 : REM DIVISION DURCH 0 VERMEIDEN 1260 A=INT(ATN(DX/DY)*180/π+.5) : REM WINKEL ERMITTELN UND UMRECHNEN 1265 A=A-180*(A<0)-180*(DX>=0): REM WINKEL VON -90 BIS 90 AUF 0-360 ABBILDEN 1270 XL=X:YL=Y : REM ALTE (LAST) POSITION MERKEN 1280 PRINT ".WINKEL: GESETZT="AO;"{left} GEMESSEN="A"{left} " 1290 GET A$:IF A$="" THEN LOOP : REM TASTENABFRAGE FUER WINKEL 1300 IF A$="{left}" AND AO>=5 THEN AO=AO-5 1310 IF A$="{right}" AND AO<=355 THEN AO=AO+5: IF AO=360 THEN AO=0 1320 MOVSPR S,AO#V : REM SPRITE-RICHTUNG NEU SETZEN 1390 LOOP
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 FN | DELETE | DIM | DIRECTORY | DLOAD | DO | DOPEN | DRAW | DS | DS$ | DSAVE | DVERIFY | EL | ELSE | END | ENVELOPE | ER | ERR$ | EXIT | EXP | FAST | FETCH | FILTER | FN | FOR | FRE | GET | GET# | GETKEY | GO64 | GOSUB | GOTO | GRAPHIC | GSHAPE | HEADER | HELP | HEX$ | IF | INPUT | INPUT# | 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 | PRINT USING | PRINT# | PUDEF | (QUIT) | RCLR | RDOT | READ | RECORD | REM | RENAME | RENUMBER | RESTORE | RESUME | RETURN | RGR | RIGHT$ | 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$ | TO | TRAP | TROFF | TRON | USR | VAL | VERIFY | VOL | WAIT | WHILE | WINDOW | WIDTH | XOR