ASM to Sega Genesis Platform

Would you like to react to this message? Create an account in a few clicks or log in to continue.
ASM to Sega Genesis Platform

All about assembly programming in the Sega Genesis console.


5 posters

    Homing Attack - Variant 2 - Quadratic Method

    avatar
    OuricoDoido
    Admin


    Mensagens : 46
    Data de inscrição : 2011-01-09
    Current Project : Sonic Open Source Project

    Homing Attack - Variant 2 - Quadratic Method Empty Homing Attack - Variant 2 - Quadratic Method

    Post  OuricoDoido Thu Feb 03, 2011 7:00 pm

    In this method, the Sonic goes in enemy direction by the edges of a imaginary rectangle between they.

    Homing Attack - Variant 2 - Quadratic Method Quadraticmethod

    When the Sonic enter in blue range, the horizontal alignment is activated and the vertical alignment is disabled.

    To download the Rom and the Source Code, click here: http://goo.gl/2SH7T
    To apply this you need first apply the Homing Attack in Sonic 1 guide.


    Now in HA_Move change this:
    Code:
    ; Recalculating the distance between the Sonic and the object (d1 = x distance / d2 = y distance)
          move.w  8(a1),d1   ; move the object x-position to d1
          move.w  $C(a1),d2   ; move the object y-position to d2
          sub.w  8(a0),d1   ; sub sonic x-position of object x-position
          sub.w  $C(a0),d2   ; sub sonic y-position of object y-position

          jsr      (CalcAngle).l   ; calculates the angle
          jsr      (CalcSine).l   ; calculates the sine and the cosine
          muls.w  #$C,d1         ; multiply cosine by $C
          move.w  d1,$10(a0)      ; move d1 to X-velocity
          muls.w  #$C,d0         ; multiply sine by $C
          move.w  d0,$12(a0)      ; move d0 to Y-velocity

    Sonic_HA_rts:
          rts                  ; return
    To this:
    Code:
       ; vertical alignment
          move.w  $C(a1),d2   ; move the object y-position to d2
          sub.w  $C(a0),d2   ; sub sonic y-position of object y-position
          move.w   d2,d3      ; copy y-distance to d3
          muls.w   d3,d3      ; vertical distance squared
          cmp.w   #400,d3      ; is y-distance of Sonic, less than or equal 20 pixels of the object? (20^2=400 // $14^2=$190)
          ble.s   Ha_GO      ; if yes, attack him
          clr.w  $10(a0)      ; if not, stop Sonic's X-velocity
          muls.w   #5,d2         ; multiply y-distance by 5
          add.w  d2,$12(a0)      ; add y-distance*5 to Y-velocity
          rts


    Ha_GO:   ; horizontal alignment
          move.w  8(a1),d1   ; move the object x-position to d1
          sub.w  8(a0),d1   ; sub sonic x-position of object x-position
          clr.w  $12(a0)      ; stop Sonic's Y-velocity
          muls.w   #5,d1         ; multiply x-distance by 5
          add.w  d1,$10(a0)      ; add x-distance*5 to X-velocity

    Sonic_HA_rts:
          rts                  ; return


    Last edited by OuricoDoido on Fri Feb 04, 2011 12:34 pm; edited 1 time in total
    avatar
    TailsX-Doll


    Mensagens : 1
    Data de inscrição : 2011-02-02

    Homing Attack - Variant 2 - Quadratic Method Empty Re: Homing Attack - Variant 2 - Quadratic Method

    Post  TailsX-Doll Fri Feb 04, 2011 12:56 am

    Cool!!!
    hacker___
    hacker___


    Mensagens : 1974
    Data de inscrição : 2013-05-06
    Localização : 41.383863, 108.866009
    Current Project : Breathing nitrogen

    Homing Attack - Variant 2 - Quadratic Method Empty [youtube]qVCFV7jT9ho[/youtube]

    Post  hacker___ Sun May 19, 2013 11:45 am

    Jdpense
    Jdpense


    Mensagens : 100554
    Data de inscrição : 2014-08-21

    Homing Attack - Variant 2 - Quadratic Method Empty Re: Homing Attack - Variant 2 - Quadratic Method

    Post  Jdpense Thu Dec 27, 2018 10:49 am

    Just an annual year bump! Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy bounce bounce bounce bounce bounce affraid Basketball cheers bom drunken Basketball cheers bom drunken cherry sunny Sleep
    Green Snake
    Green Snake


    Mensagens : 2185
    Data de inscrição : 2012-04-07
    Localização : I do not even know
    Current Project : nope

    Homing Attack - Variant 2 - Quadratic Method Empty Re: Homing Attack - Variant 2 - Quadratic Method

    Post  Green Snake Wed Sep 04, 2019 2:03 pm


    Sponsored content


    Homing Attack - Variant 2 - Quadratic Method Empty Re: Homing Attack - Variant 2 - Quadratic Method

    Post  Sponsored content


      Current date/time is Fri Apr 19, 2024 10:05 am