Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
K

Korowai

@Korowai
About
Posts
10
Topics
4
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • c++ directx9 center background
    K Korowai

    Hello, i am trying to code some graphics for a little game in c++ and winapi / directx9. I have established a background as a surface. Then i put some sprites on the background. The problem is, as i call a function that has to center the screen on the active sprite, it doesn't show the background. Here is the code so far, if you miss an information, please ask and i will answer. First, the part of main, that is called, when user pushes button (winapi)

    case ID_ZENTRIEREN:
    {
    for (int x=0;x<4;x++)
    if (Spieler[x].Rundenaktiv==true)
    {
    Spielx=Spieler[x].posx;
    Spiely=Spieler[x].posy;
    d3ddev->Clear(0,NULL,D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_COLORVALUE(0.0f,0.0f,0.0f,1.0f), 1.0f, 0);
    render_frame_center(hDlg1, Worldposx, Worldposy, Bildschirmbreite, Bildschirmhoehe, Spielx, Spiely);
    if (Spieler[x].Mobilart==0) //Schuerfer
    {
    float Mobilposx, Mobilposy;
    Mobilposx=Spieler[x].posx;
    Mobilposy=Spieler[x].posy;
    render_Schuerfer(oWorldposx, oWorldposy, Mobilposx, Mobilposy);
    }
    else if (Spieler[x].Mobilart==1) //Frachter
    {
    float Mobilposx, Mobilposy;
    Mobilposx=Spieler[x].posx;
    Mobilposy=Spieler[x].posy;
    render_Frachter(oWorldposx, oWorldposy, Mobilposx, Mobilposy);
    }
    else if (Spieler[x].Mobilart==2) //Flugwaechter
    {
    float Mobilposx, Mobilposy;
    Mobilposx=Spieler[x].posx;
    Mobilposy=Spieler[x].posy;
    render_Flugwaechter(oWorldposx, oWorldposy, Mobilposx, Mobilposy);
    }
    else if (Spieler[x].Mobilart==3) //Jaeger
    {
    float Mobilposx, Mobilposy;
    Mobilposx=Spieler[x].posx;
    Mobilposy=Spieler[x].posy;
    render_Jaeger(oWorldposx, oWorldposy, Mobilposx, Mobilposy);
    }

                    render\_Zeichenak
    
    Graphics c++ graphics game-dev help

  • DirectX9 - Problems to arrange bitmap
    K Korowai

    Hi, i properly have coded a bitmap to be drawn in a control child of a dialogue in WINAPI. Now i want to fit the bitmap, that has to be bigger than the window size, in specific coordinates, lateron i want to make controls that move the picture in the window. My problem is i really don't know where i can set the variables who arrange the picture. Here's the code (only the main, the headers are not neccessary):

    #if defined(UNICODE) && !defined(_UNICODE)
    #define _UNICODE
    #elif defined(_UNICODE) && !defined(UNICODE)
    #define UNICODE
    #endif

    #include
    #include
    #include
    #include
    #include
    #include "Resource.h"

    #pragma comment (lib, "d3d9.lib")

    /* Declare Windows procedure */
    LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
    BOOL CALLBACK Raumaktionproc (HWND, UINT, WPARAM, LPARAM);

    /* Make the class name into a global variable */

    = _T("CodeBlocksWindowsApp");

    LPDIRECT3D9 d3d;
    LPDIRECT3DDEVICE9 d3ddev;
    LPDIRECT3DVERTEXBUFFER9 g_pVertexBuffer = NULL;
    LPDIRECT3DTEXTURE9 g_pTexture = NULL;

    #define D3DFVF_CUSTOMVERTEX ( D3DFVF_XYZ | D3DFVF_TEX1 )

    struct Vertex
    {
    float x, y, z;
    float tu, tv;
    };

    Vertex g_quadVertices[] =
    {
    {-1.0f, 1.0f, 0.0f, 0.0f,0.0f },
    { 1.0f, 1.0f, 0.0f, 1.0f,0.0f },
    {-1.0f,-1.0f, 0.0f, 0.0f,1.0f },
    { 1.0f,-1.0f, 0.0f, 1.0f,1.0f }
    };
    static HWND hwndRaumkarte;

    void initD3D(HWND hwndRaumkarte);
    void render_frame(void);
    void cleanD3D(void);
    void loadTexture(void);

    #define ID_StartDialog 1

    int WINAPI WinMain (HINSTANCE hThisInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpszArgument,
    int nCmdShow)
    {
    HWND hwnd; /* This is the handle for our window */
    MSG messages; /* Here messages to the application are saved */
    WNDCLASSEX wincl; /* Data structure for the windowclass */

    memset(&messages,0,sizeof(messages));
    
    /\* The Window structure \*/
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /\* This function is called by windows \*/
    wincl.style = CS\_DBLCLKS;                 /\* Catch double-clicks \*/
    wincl.cbSize = sizeof (WNDCLASSEX);
    
    /\* Use default icon and mouse-pointer \*/
    wincl.hIcon = LoadIcon (NULL, IDI\_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI\_APPLICATION);
    wincl.hCur
    
    Graphics graphics help learning

  • Error in returning array of int as reference
    K Korowai

    addition: i feel like an idiot. Maybe i am one. There must be everything allright. It just misses a ">=" in the function instead of a ">", because the variable is equal 1. So the entrypoint is never beeing reached. I ll change it and then we ll see. Thank you so far, i hope i just gave you an evening with something to smile about. Thanks.

    C / C++ / MFC data-structures help question

  • Error in returning array of int as reference
    K Korowai

    Is it possible that the array int Schadensnummer[] establishs a copy of the member variable of the class RestonaGuldon_Gegner[0]? The class is global, the variable m_Schutzwall is public. The class is capsulated in an array. I dont see a solution so far. it couldnt be that i have to give the array of the class in its own function. i think i forgot something, but i still cant see it. :(

    C / C++ / MFC data-structures help question

  • Error in returning array of int as reference
    K Korowai

    Hi, i made a step per step view on the code. It runs through "Schadensnummer[y]=RestonaGuldon_Gegner[0].Basistrefferermittlung();" and returns 1 after it doesn't enter the line it should

    //...
    if (m_Schutzwall>1)
    {
    Einschlagsnummer=1;
    m_Schutzwall=m_Schutzwall-1;
    return (Einschlagsnummer);
    }
    //...

    it should enter there, because the class array object has .m_Schutzwall>1. But it neither enters and sets Einschlagsnummer to 1 or subtracts the m_Schutzwall by 1. There must be something wrong with my declaration of the array of the class "RestonaGuldon_Gegner[0]" oder initialization of the function "Basistrefferermittlung()". But i can't see what it is. I'm blindfolded. I just did everything how i am used to do and it worked fine till now. I am stunned.

    C / C++ / MFC data-structures help question

  • Error in returning array of int as reference
    K Korowai

    I did that. Debugger s showing the array is filled with "1" in each of the 5 instances.

    C / C++ / MFC data-structures help question

  • Error in returning array of int as reference
    K Korowai

    Hi, i have to ask a question about some codelines, where i have a mistake, because the array of int always returns 1 for every instance and i spent a lot of hours and still cannot find the fail i have maid. I simply post the necessary codelines in hope that someone can put away the wood infront of my head. Inside a modal dialogue, these are the calls

    for (int y=0;y<5;y++)
    {
    Schadensnummer[y]=KlendautKlendaut_Gegner[0].Basistrefferermittlung();
    }

    The class "KlendautKlendaut_Gegner0" - function Basistrefferermittlung:

    int CBasis::Basistrefferermittlung()
    {
    int Zufallstreffer;
    Zufallstreffer=rand()%99+1;
    int Trefferchance;
    Trefferchance=rand()%99+1;
    static int Einschlagsnummer;

    if (Trefferchance>80)
    {
        if (Zufallstreffer>95)
        {
        if (m\_Bodyguard>1)
        {
        Einschlagsnummer=20;
        m\_Bodyguard=m\_Bodyguard-1;
        return (Einschlagsnummer);
        }
        else if (m\_Bodyguard<1&&m\_Palast>1)
        {
        Einschlagsnummer=21;
        m\_Palast=m\_Palast-1;
        return (Einschlagsnummer);
        }
        }
        else if (Zufallstreffer>90&&Zufallstreffer<95)
        {
            if (m\_Fabrik>1)
        {
        Einschlagsnummer=16;
        m\_Fabrik=m\_Fabrik-1;
        return (Einschlagsnummer);
        }
        }
        else if (Zufallstreffer>85&&Zufallstreffer<90)
        {
        if (m\_Scanner>1)
        {
        Einschlagsnummer=17;
        m\_Scanner=m\_Scanner-1;
        return (Einschlagsnummer);
        }
        }
        else if (Zufallstreffer>80&&Zufallstreffer<85)
        {
        if (m\_Kraftwerk>1)
        {
        Einschlagsnummer=18;
        m\_Kraftwerk=m\_Kraftwerk-1;
        return (Einschlagsnummer);
        }
        }
        else if (Zufallstreffer>75&&Zufallstreffer<80)
        {
        if (m\_Zentrale>1)
        {
        Einschlagsnummer=19;
        m\_Zentrale=m\_Zentrale-1;
        return (Einschlagsnummer);
        }
        }
    
    }
    if (m\_Schutzwall>1)
    {
        Einschlagsnummer=1;
        m\_Schutzwall=m\_Schutzwall-1;
        return (Einschlagsnummer);
    }
    else if (m\_Gefechtsstand>1)
    {
        Einschlagsnummer=2;
        m\_Gefechtsstand=m\_Gefechtsstand-1;
        return (Einschlagsnummer);
    }
    else if (m\_Geschuetzturm>1)
    {
        Einschlagsnummer=3;
        m\_Geschuetzturm=m\_Geschuetzturm-1;
        return (Einschlag
    
    C / C++ / MFC data-structures help question

  • DirectX 9 in code:blocks fails on initD3D
    K Korowai

    I added these lines. There is still no effect. Please take a look at the code i postet with a thread i made in questions. I think it has something to do with the way i manage the edit control where directx is supposed to render. It would be really nice if you take a look in my other thread. Thanks a lot.

    C / C++ / MFC help visual-studio graphics game-dev tutorial

  • DirectX 9 in code:blocks fails on initD3D
    K Korowai

    Hello, i tried to fix this, but it still doesn't work. I thougth about it and i guess it could be anything with the ressource file of the dialogue.

    LANGUAGE 0, SUBLANG_NEUTRAL
    IDD_DIALOG30 DIALOG 0, 0, 1000, 600
    STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU
    CAPTION "Raumkarte"
    FONT 8, "Ms Shell Dlg"
    {
    CONTROL "", ID_RAUMKARTE31, WC_STATIC, SS_BLACKFRAME, 201, 0, 800, 600, WS_EX_ACCEPTFILES | WS_CLIPSIBLINGS | WS_CLIPCHILDREN
    SCROLLBAR ID_SCROLLBARVER32, 202, 2, 19, 186, SBS_VERT, WS_EX_LEFT
    SCROLLBAR ID_SCROLLBARHOR33, 222, 2, 214, 15, 0, WS_EX_LEFT
    LISTBOX ID_RAUMKARTEAKTIONSLISTE34, 1, 0, 198, 183, WS_TABSTOP | WS_VSCROLL | LBS_NOINTEGRALHEIGHT | LBS_SORT | LBS_NOTIFY, WS_EX_LEFT
    LISTBOX ID_RAUMKARTEWAHLAKTIONSLISTE35, 1, 187, 198, 188, WS_TABSTOP | WS_VSCROLL | LBS_NOINTEGRALHEIGHT | LBS_SORT | LBS_NOTIFY, WS_EX_LEFT
    }

    The DirectX Code should be in the Static Control "ID_RAUMKARTE31". Maybe i have to add a parameter. Thx & Greetings

    C / C++ / MFC help visual-studio graphics game-dev tutorial

  • DirectX 9 in code:blocks fails on initD3D
    K Korowai

    Hello, i am trying to handle problem with directX 9 and code:blocks. i searched the internet and after installing the sdk properly and used a tutorial to compile the directx code in an static control window of my winapi program. The IDE doesn't give an error, but instead of compiling a grey window the code only does a black window over the other dialog elements, who won't be compiled properly on screen. The programm doesn't shutdown and the window bar still is in function. Does anyone knows what's to do? Here ist the code in cuts:

    void initD3D(HWND hDlg30)
    {
    d3d = Direct3DCreate9(D3D_SDK_VERSION);

    D3DPRESENT\_PARAMETERS d3dpp;    
    
    ZeroMemory(&d3dpp, sizeof(d3dpp));    
    d3dpp.Windowed = TRUE;    
    d3dpp.SwapEffect = D3DSWAPEFFECT\_DISCARD;    
    d3dpp.hDeviceWindow = hDlg30;    
    
    d3d->CreateDevice(D3DADAPTER\_DEFAULT,
                      D3DDEVTYPE\_HAL,
                      hDlg30,
                      D3DCREATE\_SOFTWARE\_VERTEXPROCESSING,
                      &d3dpp,
                      &d3ddev);
    

    }

    HRESULT CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags,
    D3DPRESENT_PARAMETERS *pPresentationParameters, IDirect3DDevice9 **ppReturnedDeviceInterface);

    void render_frame(void)
    {
    d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(70, 70, 70), 1.0f, 0);

    d3ddev->BeginScene();    
    
    d3ddev->EndScene();    
    
    d3ddev->Present(NULL, NULL, NULL, NULL);    
    

    }

    void cleanD3D(void)
    {
    d3ddev->Release();
    d3d->Release();
    }

    And this is the dialog code so far:

    BOOL CALLBACK RaumkarteProc(HWND hDlg30, UINT message, WPARAM wParam, LPARAM lParam)
    {
    PAINTSTRUCT ps;
    HDC hdc;
    HDC hdcZeichnung;
    RECT rect;

    static HWND hwndRaumkarteAktion1, hwndRaumkarteAktion2,
    hwndRaumkarteHScroll, hwndRaumkarteVScroll, hwndRaum;
    int AnzahlGegner;
    static int rightWidth=1100;
    static int lowerHeight=650;
    static int leftWidth=300;
    static int upperHeight=50;
    bool Kartezeichnen=true;
    static int iAktions1index;
    static int Aktion1auslesen;
    static char Aktion1auswahl\[100\];
    int Kartenmobilanzahl;
    Kartenmobilanzahl=Zufallsgegner\_Raum.size();
    hwndRaum=GetDlgItem(hDlg30,ID\_RAUMKARTE31);
    initD3D(hDlg30);
    
    switch (message)
    {
        case WM\_INITDIALOG:
        {
            SendDlgItemMessage(hDlg30, ID\_RAUMKARTEAKTIONSLISTE34,LB\_ADDST
    
    C / C++ / MFC help visual-studio graphics game-dev tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups