• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

100 Neutral


  • Rank
    Advanced Member
  1. download accelerator lets u resume i think its free. -Cory
  2. Map drawing help....

    This is in c++ I am trying to write a win32 program that will draw a map from this array but when it draws it does not draw it right. Leme show you. 10x20 array to hold map info int map[10][20] = {{1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3}, {4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4}, {4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4}, {4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4}, {4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4}, {4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4}, {4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4}, {4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4}, {4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4}, {5,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,6}}; How it should be drawn: HDC hdc = GetDC(hwnd); HDC idc = CreateCompatibleDC(hdc); for(int x = 0; x < 20; x++){ for(int y = 0; y < 10; y++){ switch(map[x][y]){ case 0: SelectObject(idc,bit0); break; case 1: SelectObject(idc,bit1); break; case 2: SelectObject(idc,bit2); break; case 3: SelectObject(idc,bit3); break; case 4: SelectObject(idc,bit4); break; case 5: SelectObject(idc,bit5); break; case 6: SelectObject(idc,bit6); break; } if(pacman.getX() == x && pacman.getY() == y){ SelectObject(idc,bitman); } BitBlt(hdc,x * 20,y * 20,20,20,idc,0,0,SRCCOPY); } } DeleteDC(idc); I have all of the drawing done on key down. The tiles are clearly loaded but its displaying them in the wrong order for some reason. Any Ideas? Thx, cory
  3. ID3DXSprite problems

    pumpkin pie man can u tell me how ur class initializes the sprite and texture. Every time i do it it doesnt work i guess when i'm passing the device to my init(IDirect3DDevice9 *device) it isnt valid or something can u show me how u do it. thanks, Cory
  4. Super crash.

    i changed it so the constructor does nothing and i have a method caled setup and it is called after d3d is initialized now no access violation it just doesnt draw it. -Cory
  5. Super crash.

    Is there anyone out there who knows the answer to my problem? cory
  6. Super crash.

    After messing with it i have come to a conclusion that it is definately the setup method. When i call cPlayer::setup(IDirect3DDevice9 *device) it is not doing the device right i guess because this is the method that is screwing up. Is that whats happening? Is there a way to fix this. Cuz my draw function works when i make the sprite and texture public members and create them with d3dx directly. Any help will be greatly appreciated! Thanks a lot, Cory
  7. Super crash.

    BUMPZORS! -Cory
  8. I think when u create the d3d interface IDirect3DCreate#(D3D_SDK_VERSION) the D3D_SDK_VERSION is the version of directx they have? -Cory
  9. sounds right from the different alpha filtering techniques that i've used but i havent used dx before so i dont know the exact way. -Cory
  10. Help Please ! !

    Try using instead of LPTSTR using PSTR that should fix ur problem :-D -cory
  11. Help Please ! !

    no the error means ur winmain has more or less paramters than it is supposed to which is wierd bc ur WinMain has the right params as far as i can see. -Cory
  12. Super crash.

    still cant figure it out :'( -Cory
  13. Super crash.

    The tile still isnt showing up tho :-/ but no access violation. #ifndef MAIN_H #define MAIN_H #include<windows.h> #include<d3d9.h> #include<d3dx9.h> #include<string> using namespace std; class cPlayer{ private: ID3DXSprite *sprite; IDirect3DTexture9 *texture; int x; int y; string name; public: cPlayer(){ } cPlayer(IDirect3DDevice9 *device,string filename){ D3DXCreateSprite(device,&sprite); D3DXCreateTextureFromFile(device,filename.c_str(),&texture); x = 0; y = 0; name = "Default"; } cPlayer(IDirect3DDevice9 *device,string filename,string newname){ D3DXCreateSprite(device,&sprite); D3DXCreateTextureFromFile(device,filename.c_str(),&texture); x = 0; y = 0; name = newname; } void setUp(IDirect3DDevice9* device){ D3DXCreateSprite(device,&sprite); D3DXCreateTextureFromFile(device,"default.bmp",&texture); x = 0; y = 0; name = "Default"; } ID3DXSprite* getsprite(){ return sprite; } IDirect3DTexture9* gettexture(){ return texture; } void draw(){ sprite->Begin(); sprite->Draw(texture,NULL,NULL,NULL,NULL,NULL,NULL); sprite->End(); } }; #endif .cpp #include<d3d9.h> #include<d3dx9.h> #include"main.h" #pragma comment(lib,"d3d9.lib") #pragma comment(lib,"d3dx9.lib") IDirect3D9 *pd3d; IDirect3DDevice9 *pdevice; bool done = false; cPlayer player1; void initD3D(HWND hwnd){ pd3d = Direct3DCreate9(D3D_SDK_VERSION); D3DDISPLAYMODE displaymode; pd3d->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&displaymode); D3DPRESENT_PARAMETERS params; ZeroMemory(&params,sizeof(params)); params.BackBufferHeight = 500; params.BackBufferWidth = 500; params.SwapEffect = D3DSWAPEFFECT_DISCARD; params.Windowed = true; params.BackBufferFormat = displaymode.Format; pd3d->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&params,&pdevice); } void render(){ D3DXMATRIX matWorld; D3DXMatrixIdentity(&matWorld); pdevice->SetTransform(D3DTS_WORLD,&matWorld); D3DXMATRIX matView; D3DXMatrixIdentity(&matView); D3DXMatrixLookAtLH(&matView, &D3DXVECTOR3(0,0,-50), &D3DXVECTOR3(0,0,0),&D3DXVECTOR3(0,1,0)); pdevice->SetTransform(D3DTS_VIEW,&matView); D3DXMATRIX matProj; D3DXMatrixIdentity(&matProj); D3DXMatrixPerspectiveFovLH(&matProj,D3DX_PI/4,GetSystemMetrics(SM_CXSCREEN)/GetSystemMetrics(SM_CYSCREEN),1,1000); pdevice->SetTransform(D3DTS_PROJECTION,&matProj); pdevice->Clear(0,NULL,D3DCLEAR_TARGET,RGB(0,0,0),1,0); pdevice->BeginScene(); player1.getsprite()->Begin(); player1.getsprite()->Draw(player1.gettexture(),NULL,NULL,NULL,NULL,NULL,NULL); player1.getsprite()->End(); pdevice->EndScene(); pdevice->Present(NULL,NULL,NULL,NULL); } void shutdownD3D(){ if(pd3d) pd3d->Release(); if(pdevice) pdevice->Release(); } LRESULT CALLBACK WndProc(HWND hwnd,UINT iMsg,WPARAM wParam,LPARAM lParam){ switch(iMsg){ case WM_DESTROY: PostQuitMessage(0); done = true; break; case WM_KEYDOWN: switch(wParam){ case VK_ESCAPE: PostQuitMessage(0); done = true; break; } break; } return DefWindowProc(hwnd,iMsg,wParam,lParam); } int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hpInstance,PSTR cmdLine,int iCmd){ WNDCLASS wc; ZeroMemory(&wc,sizeof(wc)); wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wc.hCursor = LoadCursor(NULL,IDC_ARROW); wc.hIcon = LoadIcon(NULL,IDI_APPLICATION); wc.hInstance = hInstance; wc.lpfnWndProc = WndProc; wc.lpszClassName = "class"; wc.lpszMenuName = NULL; wc.style = CS_VREDRAW|CS_HREDRAW; RegisterClass(&wc); HWND hwnd = CreateWindow("class","",WS_OVERLAPPEDWINDOW,0,0, 500,500,NULL,NULL,hInstance,NULL); initD3D(hwnd); player1.setUp(pdevice); ShowWindow(hwnd,iCmd); UpdateWindow(hwnd); MSG msg; while(!done){ if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)){ TranslateMessage(&msg); DispatchMessage(&msg); } else{ render(); } } shutdownD3D(); return 0; } Thanks, Cory
  14. Super crash.

    I figured it out i'm creating the sprite and texture with a device that is not been created yet because i made the player global. So what i ended up having to do was have the constructor do nothing and i made a method called setUP(IDirect3DDevice9* device){ same as constructor } that i call after i call initD3D(). Thanks for your help load_bitmap_file, -Cory
  15. Super crash.

    access violation sprite->Begin ...? -Cory
  • Advertisement