Beispiel #1
0
bool init()
{
    int width = getwindowwidth() / 4;
    int height = getwindowheight() / 4;

    float distance = 25.0f;
    int size = width / distance;
    
    for (int i = 0; i < size; i++)
    {
        ZVertex3D *vertex = new ZVertex3D[4];

        vertex[0].x = -width / 2 + i * distance;
        vertex[0].y = -100;
        vertex[0].z = -height;

        vertex[1].x = -width / 2 + i * distance;
        vertex[1].y = -100;
        vertex[1].z = height;

        vertex[2].x = -width / 2 + (i + 1) * distance;
        vertex[2].y = -100;
        vertex[2].z = height;

        vertex[3].x = -width / 2 + (i + 1) * distance;
        vertex[3].y = -100;
        vertex[3].z = -height;

        platForm.push_back(vertex);
    }

    return true;
}
Beispiel #2
0
void main()
{
    float delta = 0;
    float FPS = 1.0 / 60.0;

    int gd = DETECT, gm;

    initgraph(&gd, &gm, "c:\\tc\\bgi");

    graphics = new Graphics3D(new Graphics3D(), getwindowwidth(), getwindowheight());
    graphicsOXYZ = new Graphics3D(new Graphics3D(), getwindowwidth(), getwindowheight());

    //graphicsOXYZ->Rotate(60, 0, 1, 0);
    //graphics->Rotate(60, 0, 1, 0);

    init();

    while (true)
    {
        TimeCounter::GetInstance()->StartCounter();

        if (delta >= FPS)
        {
            cleardevice();

            loop();

            //std::cout << "delta time:  " << delta << std::endl;

            delta = 0;
        }

        delta += TimeCounter::GetInstance()->GetCouter();
    }

    getch();
    closegraph();
}
Point getBoardTile(int x, int y) {
    Point p = { INVALID_POSITION, INVALID_POSITION };

    int boardSize = getwindowwidth()-2*BOARD_PADDING;

    x -= BOARD_PADDING;
    y -= BOARD_PADDING;

    if (x > 0 && x < boardSize) {
        p.x = x / TILE_SIZE;
    }
    if (y > 0 && y < boardSize) {
        p.y = y / TILE_SIZE;
    }

    return p;
}