1. 51.
    0
    #include <d3d9.h>
    5. include <d3dx9.h>
    6. include <driver_kutuphanem.h>
    7. include <time.h>
    8. include <stdio.h>

    lresult winapi winproc( hwnd hwnd, uint msg, wparam wparam, lparam lparam )
    {
    switch( msg )
    {
    case wm_destroy:

    if (d3ddev != null) d3ddev->release();
    if (d3d != null) d3d->release();


    if (dinput != null) dinput->release();
    kill_keyboard();
    kill_mouse();


    game_end(hwnd);


    postquitmessage(0);
    return 0;
    }
    return defwindowproc( hwnd, msg, wparam, lparam );
    }

    {

    wndclassex wc;
    wc.cbsize = sizeof(wndclassex);


    wc.style = cs_hredraw | cs_vredraw;
    wc.lpfnwndproc = (wndproc)winproc;
    wc.cbclsextra = 0;
    wc.cbwndextra = 0;
    wc.hinstance = hinstance;
    wc.hicon = null;
    wc.hcursor = loadcursor(null, idc_arrow);
    wc.hbrbackground = (hbrush)getstockobject(black_brush);
    wc.lpszmenuname = null;
    wc.lpszclassname = apptitle;
    wc.hiconsm = null;


    return registerclassex(&wc);
    }

    int winapi winmain(hinstance hinstance,
    hinstance hprevinstance,
    lpstr lpcmdline,
    int ncmdshow)
    {
    msg msg;
    hwnd hwnd;


    myregisterclass(hinstance);


    dword style;
    if (fullscreen)
    style = ws_ex_topmost | ws_visible | ws_popup;
    else
    style = ws_overlapped;


    hwnd = createwindow(
    apptitle,
    apptitle,
    style,
    cw_usedefault,
    cw_usedefault,
    screen_width,
    screen_height,
    null,
    null,
    hinstance,
    null);


    if (!hwnd)
    return false;


    showwindow(hwnd, ncmdshow);
    updatewindow(hwnd);


    if (!init_direct3d(hwnd, screen_width, screen_height, fullscreen))
    {
    messagebox(hwnd, "error initializing direct3d", "error", mb_ok);
    return 0;
    }


    if (!init_directinput(hwnd))
    {
    messagebox(hwnd, "error initializing directinput", "error", mb_ok);
    return 0;
    }


    if (!game_init(hwnd))
    {
    messagebox(hwnd, "error initializing the game", "error", mb_ok);
    return 0;
    }


    while (msg. message != wm_quit)
    {
    if (peekmessage(&msg, null, 0, 0, pm_remove))
    {

    translatemessage(&msg);
    dispatchmessage(&msg);
    }
    else

    game_run(hwnd);
    }

    return msg. wparam;
    }
    Tümünü Göster
    ···
   tümünü göster