#include "level.h"
#include "physpoint.h"
void level::mmd(bool press,float x,float y)
{
    mmb = press;
}

void level::addvert(float x, float y)
{
/*    tlvlvert = new physpoint[vertnum+1];
    for (int i=0;i<vertnum;i++)
    {
        tlvlvert[i] = lvlvert[i];
    }
    delete[] lvlvert;
    lvlvert = tlvlvert;
    lvlvert[vertnum].c.x = x;
    lvlvert[vertnum].c.y = y;
    vertnum++;*/
}
void level::addline(float x, float y)
{
   /* float lild = 2000;
    int lili = 0;
    for (int i=0;i<vertnum;i++)
    {
        float xd = lvlvert[i].c.x-x;
        float yd = lvlvert[i].c.y-y;
        float td = xd*xd+yd*yd;
        if (td < lild)
        {
            lili = i;
            lild = td;
        }
    }
    if(!linestage)
    {
        linestage = 1;
        tlili = lili;
    }
    else
    {
        linestage = 0;
        tlvlline = new line2d[linenum+1];
        for (int i=0;i<linenum;i++)
        {
            tlvlline[i].p1 = lvlline[i].p1;
            tlvlline[i].p2 = lvlline[i].p2;
        }
        delete[] lvlline;
        lvlline = tlvlline;
        lvlline[linenum].p1 = &lvlvert[tlili];
        lvlline[linenum].p2 = &lvlvert[lili];
        linenum++;
    }*/
}
void level::delvert(float x, float y)
{
   /* float lild = 2000;
    int lili = 0;
    for (int i=0;i<vertnum;i++)
    {
        float xd = lvlvert[i].c.x-x;
        float yd = lvlvert[i].c.y-y;
        float td = xd*xd+yd*yd;
        if (td < lild)
        {
            lili = i;
            lild = td;
        }
    }
    for (int i=0;i<linenum;i++)
    {
        if(lvlline[i].p1 == &lvlvert[lili] || lvlline[i].p2 == &lvlvert[lili])
        {
            delline(i);
            i--;
        }
        ;//del the line
    }*/
}
void level::delline(int lid)
{
   /* tlvlline = new line2d[linenum-1];
    for (int i=0;i<lid;i++)
    {
        tlvlline[i] = lvlline[i];
    }
    for (int i=lid+1;i<linenum;i++)
    {
        tlvlline[i-1] = lvlline[i];
    }

    delete[] lvlline;
    lvlline = tlvlline;
    linenum--;*/
}
