360 Movement System Help

Discussion in 'Programming' started by Kivelocity, Mar 14, 2019 at 1:11 AM.

  1. Kivelocity

    Kivelocity Member

    Joined:
    Feb 19, 2019
    Posts:
    11
    Inside of my platformer, there is a system where there is four different sides the character can move on. When he hits a certain object, he rotates and travels vertically, and if he hits a different instance with a certain image_xscale or image_yscale, he rotates accordingly. I originally tried to do proper 360 movement from a sonic tutorial on youtube, but it didn't work well for me. It was created by single shot gamer, and I didn't understand it well yet. So when sonic hits one of the objects, he is repelled backwards sometimes. This only happens when he has been travelling vertically before hitting it horizontally. If he starts moving again, but on flat ground, he rotates properly. I need sonic to travel properly, so here is the code.
    Code:
    //Quadrants
    
    
    var inst = instance_nearest(x, y, ObjQuad)
    //0
    if place_meeting(x-hsp, y-vsp, inst) && inst.image_xscale = 1 && inst.image_yscale = 1
    {
    
    
    if hsp = 0 && vsp > 0
        {
        hsp += -vsp
        vsp = 0
        quad = 0
        image_angle = 0
        }
    
    if hsp > 0
        {
        vsp += -hsp
        quad = 1
        hsp = 0
        image_angle = 90
        }
            
    }
    
    //1
    if place_meeting(x-hsp, y-vsp, inst) && inst.image_xscale = 1 && inst.image_yscale = -1
    {
    if quad = 2
    {
        vsp += hsp
        hsp = 0
        image_angle = 90
        quad = 1
        
    }
    
    
    if vsp < 0 && quad = 1
    {   
        hsp += vsp
        quad = 2
        vsp = 0
        image_angle = 180
    }
                
            
    }
    
    //2
    if place_meeting(x-hsp, y-vsp, inst) && inst.image_xscale = -1 && inst.image_yscale = -1
    {
    
    if quad = 3
        {
        quad = 2
        hsp -= vsp
        vsp = 0
        image_angle = 180
        }
    
    if quad = 2 && hsp < 0
        {
        vsp -= hsp
        hsp = 0
        quad = 3
        image_angle = 270
        }
            
    }
    
    //3
    if place_meeting(x-hsp, y-vsp, inst) && inst.image_xscale = -1 && inst.image_yscale = 1
    {
    if hsp = 0 && vsp > 0
        {
        hsp += vsp
        vsp = 0
        quad = 0
        image_angle = 0
        }
    
    if hsp < 0
        {   
        vsp -= -hsp
        hsp = 0
        quad = 3
        image_angle = 270
        }
            
    }
    
    
    if hsp > -3 && hsp < 3 && quad = 2
    {
        quad = 0
    }
    
    if vsp > -1 && vsp < 1 && quad = 1 && !place_meeting(x-hsp, y-hsp, inst)
    {
        quad = 0
        hsp = -2
    }
    
    if vsp > -1 && vsp < 1 && quad = 3 && !place_meeting(x-hsp, y-hsp, inst)
    {
        quad = 0
        hsp = 2
    }
    
    while place_meeting(x-hsp, y-vsp, ObjQuad) && up < 15 && image_xscale == inst.image_xscale
    {
        y -= 1
         up += 1
    }
    
    if !place_meeting(x-hsp, y-vsp, ObjQuad)
    {
        up = 0
    }
    
    //Quandrants_T
    var t = instance_nearest(x, y, ObjQuad_T)
    
    //0
    if place_meeting(x-hsp, y-vsp, t) && t.image_xscale == 1 && t.image_yscale == 1
    {
        if quad == 1 && vsp < 0
        {
            hsp = -vsp*0.75
            quad = 0
        }
        
        if quad == 0 && hsp < 0
        {
            vsp = -hsp
            hsp = 0
            quad = 1
        }
    }
    //1
    if place_meeting(x-hsp, y-vsp, t) && t.image_xscale == -1 && t.image_yscale == 1
    {
        if quad == 3 && vsp < 0
        {
            hsp = vsp*0.75
            quad = 0
        }
        
        if quad == 0 && hsp > 0
        {
            vsp = hsp
            hsp = 0
            quad = 3
        }
    }
    
    while place_meeting(x-hsp, y-vsp, ObjQuad_T)
    {
        lerp(image_angle, t.image_xscale*50, 10)
       y -= 1
    }
     
  2. Kivelocity

    Kivelocity Member

    Joined:
    Feb 19, 2019
    Posts:
    11
    Please I need an answer
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice