Collsiion on two sprite, dummy ?

Página 1/3
| 2 | 3

Por DanySoft

Champion (452)

imagem de DanySoft

16-06-2012, 21:26

Hello,
this source is complicated and return the result of collision of two sprite, but wrong .
This source is this :

        ORG   $B000
SPEED:  EQU   4
>
BEGIN:
        LD    A,1
        CALL  $5F
        LD    A,255
        LD    HL,$3800
        LD    BC,32
        CALL  $56
        JR    GAME
LOOP:
        CALL  $9F
        CP    28
        JR    Z,DES
        CP    29
        JR    Z,SIN
        CP    31
        JR    Z,GIU
        CP    30
        JR    Z,SU
;
        CP    27
        JP    Z,EXIT
GAME:
        LD    HL,OMINO
        LD    DE,$1B00
        LD    BC,8
        CALL  $5C

        LD    HL,6144
        LD    A,(P1)
        ADD   48
        CALL  $4D
        INC   HL
        LD    A,(POK)
        CALL  $4D
        CALL  CHECK
        CP    255
        JR    NZ,SKIP
        LD    IX,OMINO
        LD    (IX+3),14
        HALT
        JR    LOOP
SKIP:
        LD    IX,OMINO
        LD    (IX+3),2
        HALT
        JR    LOOP
SU:
        LD    IX,OMINO
        LD    A,(IX+0)
        SBC   SPEED
        LD    (IX+0),A
        JR    GAME
>
GIU:
        LD    IX,OMINO
        LD    A,(IX+0)
        ADD   SPEED
        LD    (IX+0),A
        JR    GAME

DES:
        LD    IX,OMINO
        LD    A,(IX+1)
        ADD   SPEED
        LD    (IX+1),A
        JR    GAME
SIN:
        LD    IX,OMINO
        LD    A,(IX+1)
        SBC   SPEED
        LD    (IX+1),A
        JR    GAME
EXIT:
        LD    A,0
        JP    $5F
        RET
>
CHECK:
        LD    HL,0
        LD    (P1),HL
;
        LD    IX,P1
;
        LD    IY,OMINO
;
        CALL  GET
        INC   IY
        CALL  GET
;
        LD    HL,POK
        LD    A,"X"
        LD    (HL),A
;
        LD    HL,P1
        LD    A,(HL)
        CP    2
        RET   NZ
;
        LD    HL,POK
        LD    A,"O"
        LD    (HL),A
        RET
>
GET:
        LD    B,(IY+0)
        LD    D,(IY+4)
;       LD    C,16
;       LD    E,16
        CALL  COLLIS
        RET   NC

; ok set 1
        LD    A,(IX+0)
        INC   A
        LD    (IX+0),A
        CCF
        RET

;B=Object1, C=size
;D=Object2, E=size
;OUT: Carry set if collis
;
COLLIS:
        LD    A,D
        SUB   B
        JR    C,ALTRO
        SUB   C
        RET
ALTRO:
        NEG
        SUB   E
        RET

P1:     DB    0
P2:     DB    0
POK:    DB    0

OMINO:  DB    100,80,1,2
             DB    100,100,0,8

And see this link : Collision detection

But get four item : B=X, C=size and D=I, E=size and return OK but this game is *Not OK*

Can't help to resolved this problems ? It search this forum, but not found 2* parametrs . Y (J+16) ?!? oO

Entrar ou registrar-se para comentar

Por gasparrini

Champion (329)

imagem de gasparrini

16-06-2012, 22:25

Hello Guys,

His should solve also the problem of th collision between
sprite and characters of background in SCREEN1 in assembly.

Regards
AG.

Por PingPong

Prophet (3898)

imagem de PingPong

17-06-2012, 00:02

Why instead of use some prepared listing one does not use this time to learn
how to code, how does work some algorithm, how does work machine code?

Would be more useful than cut-and-paste some code ( maybe even untested ) then asking some magician help.

DanySoft wrote:

Hello,
this source is complicated and return the result of collision of two sprite, but wrong .
This source is this :

        ORG   $B000
SPEED:  EQU   4
>
BEGIN:
        LD    A,1
        CALL  $5F
        LD    A,255
        LD    HL,$3800
        LD    BC,32
        CALL  $56
        JR    GAME
LOOP:
        CALL  $9F
        CP    28
        JR    Z,DES
        CP    29
        JR    Z,SIN
        CP    31
        JR    Z,GIU
        CP    30
        JR    Z,SU
;
        CP    27
        JP    Z,EXIT
GAME:
        LD    HL,OMINO
        LD    DE,$1B00
        LD    BC,8
        CALL  $5C

        LD    HL,6144
        LD    A,(P1)
        ADD   48
        CALL  $4D
        INC   HL
        LD    A,(POK)
        CALL  $4D
        CALL  CHECK
        CP    255
        JR    NZ,SKIP
        LD    IX,OMINO
        LD    (IX+3),14
        HALT
        JR    LOOP
SKIP:
        LD    IX,OMINO
        LD    (IX+3),2
        HALT
        JR    LOOP
SU:
        LD    IX,OMINO
        LD    A,(IX+0)
        SBC   SPEED
        LD    (IX+0),A
        JR    GAME
>
GIU:
        LD    IX,OMINO
        LD    A,(IX+0)
        ADD   SPEED
        LD    (IX+0),A
        JR    GAME

DES:
        LD    IX,OMINO
        LD    A,(IX+1)
        ADD   SPEED
        LD    (IX+1),A
        JR    GAME
SIN:
        LD    IX,OMINO
        LD    A,(IX+1)
        SBC   SPEED
        LD    (IX+1),A
        JR    GAME
EXIT:
        LD    A,0
        JP    $5F
        RET
>
CHECK:
        LD    HL,0
        LD    (P1),HL
;
        LD    IX,P1
;
        LD    IY,OMINO
;
        CALL  GET
        INC   IY
        CALL  GET
;
        LD    HL,POK
        LD    A,"X"
        LD    (HL),A
;
        LD    HL,P1
        LD    A,(HL)
        CP    2
        RET   NZ
;
        LD    HL,POK
        LD    A,"O"
        LD    (HL),A
        RET
>
GET:
        LD    B,(IY+0)
        LD    D,(IY+4)
;       LD    C,16
;       LD    E,16
        CALL  COLLIS
        RET   NC

; ok set 1
        LD    A,(IX+0)
        INC   A
        LD    (IX+0),A
        CCF
        RET

;B=Object1, C=size
;D=Object2, E=size
;OUT: Carry set if collis
;
COLLIS:
        LD    A,D
        SUB   B
        JR    C,ALTRO
        SUB   C
        RET
ALTRO:
        NEG
        SUB   E
        RET

P1:     DB    0
P2:     DB    0
POK:    DB    0

OMINO:  DB    100,80,1,2
             DB    100,100,0,8

And see this link : Collision detection

But get four item : B=X, C=size and D=I, E=size and return OK but this game is *Not OK*

Can't help to resolved this problems ? It search this forum, but not found 2* parametrs . Y (J+16) ?!? oO

Por WORP3

Paladin (857)

imagem de WORP3

17-06-2012, 00:08

You can use the VDP sprite collision detection, if a collision has been detected you only have to search for the two sprites colliding. Will save you a lot of cpu performance Wink

Por DanySoft

Champion (452)

imagem de DanySoft

17-06-2012, 11:10

The bit 5 of VDP (0xF3E7) is present and check if two o more sprites is collision.
Yes, but the position X-X2 and Y-Y2 is not correct or corruption, please, insert the example short to calculate
of position and distanz by two sprite.

Search "collision" on your site MSX.org, is presents but can't get the 2* paramet of Y (first X-X2, the second is Y ????) Shocked!
... and return two variables or flag and return "collision ON" else "collision OFF". Tongue
bye bye
DanySoft

Por DanySoft

Champion (452)

imagem de DanySoft

17-06-2012, 11:13

Please, set the example of get label "collision"

COLLIS:
        LD    A,D
        SUB   B
        JR    C,ALTRO
        SUB   C
        RET
ALTRO:
        NEG
        SUB   E
        RET

And calculated of X and Y vs X2 and Y2 to return false o true of collision check.

Great. Smile
DanySoft

Por DanySoft

Champion (452)

imagem de DanySoft

17-06-2012, 21:27

But... can't help this problem ?!?!
Can't resolved the problem of collision for two sprites ?!
wait...

Por DanySoft

Champion (452)

imagem de DanySoft

19-06-2012, 16:29

But no one help me to solve the solution in Z80 assembly on collsiione sprite?

Alllora I will no longer come into this forum for a while!
And then I have been very good at BASIC, ASSEMBLEER (with WBASS2 and SJASM) especially on the graphics that I can use as well as a utility created by the CALL assembleer for personal use only.

In this case, you leave. I take a vacation. bye bye!

Por Metalion

Paragon (1529)

imagem de Metalion

19-06-2012, 17:35

Oooooh boy.
Running Naked in a Field of Flowers

Por faxerpelle

Expert (98)

imagem de faxerpelle

19-06-2012, 17:49

DanySoft wrote:

But no one help me to solve the solution in Z80 assembly on collsiione sprite?

Alllora I will no longer come into this forum for a while!
And then I have been very good at BASIC, ASSEMBLEER (with WBASS2 and SJASM) especially on the graphics that I can use as well as a utility created by the CALL assembleer for personal use only.

In this case, you leave. I take a vacation. bye bye!

Enjoy your holidays! Cool

Por ARTRAG

Enlighted (6845)

imagem de ARTRAG

19-06-2012, 17:53

come back soon, I already miss your posts
Crying

Página 1/3
| 2 | 3