Author Topic: Blargel's Danmakufu Corner (Ikareimu Revival? and Contest)  (Read 64997 times)

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: Blargel's Danmakufu Corner (StB/DS Engine)
« Reply #180 on: May 02, 2010, 04:17:48 AM »
Arrrrrrrrrgh, stop making my head hurt! :colonveeplusalpha:

Your code is still incorrect I believe. Just because the two points of one line segment are on opposite ends of the other line segments doesn't mean they intersect because they're line segments. For example, a situation like this:

                      |
-----------           |
                      |
                      |
                      |
                      |


The two points on the vertical line are above and below the horizontal line, but the segments obviously don't intersect. Of course, maybe I didn't read your code carefully enough since I only read the comments and glimpsed the code a little (it's hard to read on the forum and I was too lazy to copy it to Notepad++) and maybe you did catch that. Your Collision_Box_Laser is similar to how I was planning to do the collision detection eventually, but there are a lot of other issues I need to work out later as well. Anyways, like I said on IRC, I already generally know how I'm going to solve this problem and the line to line collision detection is probably gonna be handled differently than how you have it. More math, less if-else construction.
« Last Edit: May 02, 2010, 04:21:37 AM by Blargel »
<WorkingKeine> when i get home i just go to the ps3 and beat people up in blazblue with a loli
<Azure> Keine: Danmakufu helper by day, violent loli by night.

Kylesky

  • *The Unknown*
  • Local Unbalanced Danmakufu Idiot Scripter
    • My useless youtube account... (will be useful in the future *I promise*)
Re: Blargel's Danmakufu Corner (StB/DS Engine)
« Reply #181 on: May 02, 2010, 03:09:07 PM »
Your code is still incorrect I believe.

yeah... I noticed that after I left... :V

here's a very much simplified version of that block of code
Code: [Select]
function PointSideFromLine(x1, y1, x2, y2, x3, y3)
{
    let lineangle=atan2(y3-y2, x3-x2);
    let slope=(y3-y2)/(x3-x2);
    let x4=(y2-y1)/slope+x1; //hope this makes sense... tried morphing y=mx+b into x=(y-b)/m
    if(x1<=x4 || x3-x2==0){return "LEFT";}else{return "RIGHT";}
}

function Collision_Segment_Line(x1, y1, x2, y2, x3, y3, x4, y4)
{
    if(PointSideFromLine(x1, y1, x3, y3, x4, y4)=="LEFT"){
        if(PointSideFromLine(x2, y2, x3, y3, x4, y4)=="RIGHT"){return true;}else{return false;}
    }else{
        if(PointSideFromLine(x2, y2, x3, y3, x4, y4)=="LEFT"){return true;}else{return false;}
    }
}

function Collision_Segment_Segment(x1, y1, x2, y2, x3, y3, x4, y4) //either do this, or find a way to make a GetPOI function (point of intersection) and use Collision_Line_Circle to check if it's on both segments... these 2 things both make sure that it checks segment to segment and not segment to line
{
    if(Collision_Segment_Line(x1, y1, x2, y2, x3, y3, x4, y4)==true && Collision_Segment_Line(x3, y3, x4, y4, x1, y1, x2, y2)==true)
    {
    return true;
    }else{
    return false;
    }
}

function Collision_Box_Line(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6)
{
    if(Collision_Segment_Segment(x1, y1, x3, y3, x5, y5, x6, y6)==true || Collision_Segment_Segment(x2, y2, x4, y4, x5, y5, x6, y6)==true)
    {
    return true;
    }else{
    return false;
    }
}

function Collision_Box_Laser(centx, centy, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, width)
{
    if(PointSideFromLine(centx, centy, x5, y5, x6, y6)=="LEFT"){
        if(Collision_Box_Line(x1, y1, x2, y2, x3, y3, x4, y4, x5-width/2, y5-width/2, x6-width/2, y6-width/2)==true){return true;}else{return false;}
    }else{
        if(Collision_Box_Line(x1, y1, x2, y2, x3, y3, x4, y4, x5+width/2, y5+width/2, x6+width/2, y6+width/2)==true){return true;}else{return false;}
    }
}

most comments are gone :V (by the way... this also works for curvy lasers :V the only problem is measuring the length to cut the laser, and I doubt if you're gonna even bother doing that)

Also, the reason why I'm trying to perfect this function/s is cause I'm also gonna use them... (in the future)
« Last Edit: May 02, 2010, 03:20:08 PM by Kylesky »
Danmakufu Script Thread :V Latest Script: Intertwining Mechanical Intervention (temp name)

Yooooouuutuuuubeeee Channel Latest Video: Contest #8 Entry

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: Blargel's Danmakufu Corner (Ikareimu Revival? and Contest)
« Reply #182 on: December 19, 2012, 02:53:36 AM »
Ikareimu Fucking What Contest
My goal for this is really just to get exposure so I might be able to get a spriter and/or composer to help me with this and future games.
« Last Edit: December 19, 2012, 02:59:58 AM by Blargel »
<WorkingKeine> when i get home i just go to the ps3 and beat people up in blazblue with a loli
<Azure> Keine: Danmakufu helper by day, violent loli by night.