News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

Basic Efficient Collision Detection Routine

Started by tjohnson, 20:10, 21 September 17

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ZbyniuR

10 FOR a=1 TO 17:POKE 39999+a,VAL("&"+MID$("DD7E00CDB4BBF5CD60BB320000F1C3B4BB",a*2-1,2)):NEXT
20 LOCATE x,y:CALL 40000,0:PRINT CHR$(PEEK(0)) '  this works as COPYCHR$ in any CPC

I used to found this in some magazine. :)

And remember about TEST command, could be usefull to detect pixel color. :)
In STARS, TREK is better than WARS.

mr_lou

Quote from: ZbyniuR on 00:03, 01 April 18
10 FOR a=1 TO 17:POKE 39999+a,VAL("&"+MID$("DD7E00CDB4BBF5CD60BB320000F1C3B4BB",a*2-1,2)):NEXT
20 LOCATE x,y:CALL 40000,0:PRINT CHR$(PEEK(0)) '  this works as COPYCHR$ in any CPC
This is great!
Can someone turn this into an RSX command please?  :)
What are the BASIC lines to create a small RSX command like |charCodeAt(x,y)Returns ASCII code for the character at location x,y
Or |code(x,y)

asertus

Basically all these are already implemented as RSX by 8 bits de poder i.e.:


|COLAY,umbral_ascii, #,@colision detecs collission with layout and returns 1 if true
|COLSP, #,@id returns 1st sprite collision with #
|COLSPALL,@quien%,@conquien% returns "quien" has collided and with whom

mr_lou

Quote from: asertus on 19:41, 13 October 18
Basically all these are already implemented as RSX by 8 bits de poder i.e.:

|COLAY,umbral_ascii, #,@colision detecs collission with layout and returns 1 if true
|COLSP, #,@id returns 1st sprite collision with #
|COLSPALL,@quien%,@conquien% returns "quien" has collided and with whom

It doesn't look like the same to me. There's a difference between a sprite and an ASCII character.

These are commands that checks for collision. That's not what I'm asking for. I just want to be able to get the ASCII code for the character on a certain location on the screen. The above BASIC code does that. All I need now is to turn it into an RSX command - and include the LOCATE command in the RSX as well. so I can call |charCodeAt,x,y  :)

fgbrain

At your service  @mrlou ,

CALL &A500 to set command (fully relocatable!!)

then use: 

a%=0
|charcode,@a%,x,y

returns at a% = number of chr found else a%=0





org &A500

INITIALIZE:
    LD HL,WORK_SPACE ;RSX power - up Routine
    LD BC,RSX_TABLE
    JP &BCD1

WORK_SPACE: DEFS  4 ;Area for Kernel to use

RSX_TABLE: DEFW NAME_TABLE
    JP CHAR_CODE ;

NAME_TABLE: DEFB 'CHARCOD','E'+#80 ;
    DEFB #00

CHAR_CODE
CP 3
RET NZ  ;EXIT if not 3 parameters
LD D,(IX+5) ;
LD E,(IX+4) ; DE = ADR OF A%
LD H,(IX+2) ; H = X
LD L,(IX+0) ;  L = Y
CALL &BB75
CALL &BB60
LD(DE),A ; STORE VALUE IN A%
RET
_____

6128 (UK keyboard, Crtc type 0/2), 6128+ (UK keyboard), 3.5" and 5.25" drives, Reset switch and Digiblaster (selfmade), Inicron Romram box, Bryce Megaflash, SVideo & PS/2 mouse, , Magnum Lightgun, X-MEM, X4 Board, C4CPC, Multiface2 X4, RTC X4 and Gotek USB Floppy emulator.

Powered by SMFPacks Menu Editor Mod