Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

134 Neutral

About RogDX9

  • Rank
  1. Ok never mind, i figured it out, it was easier than i thought, i just needed to subtract distance from Rect.X to sprite canvas width.
  2. Hello Everyone,    I have Custom Hitboxes defined per sprite for enemies as std::vector<Rectangle> where each rectangle is relative coordinates to the sprite, when doing collision detection, i just translate those Rects coordinates to screen coordinates and check for colliding objects and it works fine when sprite is not flipped and its in the same shape when the hitboxes were defined for it, however, in some cases when the enemy gets behind the player character it flips horizontally to give the enemy the ability to attack the player as well, there is no vertical flipping, thus hitboxes positions are now invalid and will cause wrong collision detection, i'm trying to find an algorithm to flip hitboxes sort of mirroring them. what is the easiest way to (not sure about the right term here) flip hitboxes to match same positions when the sprite gets flipped. Thanks for help.
  3.   makes sense actually and i guess 30 FPS option is valid if you look to it that way, i'll add it up , thx for feedback.
  4.   Thanks, Since there is refresh rate that you can select, the purpose is the same, i have 60,80,100,120,144 and unlocked refresh rates support and can add more if required.       Thanks, sprites have transparent areas, i have MSAA option for x2,x4 and x8 but i have been reading that MSAA has no effect on sprites, it has effects on primitives to smoothen the edges for vertex based rendering, maybe the effect is minimal but i have set it to x16 and to be honest didnt notice any change in quality, perhaps its just me, if it has effects then ill keep this option, please confirm? the color blindness option seems very good, thx :) what about textures filtering and AF, i'm not sure if it will have any effect on 2D game based on sprites and if so, which is the better option Trilinear filtering or AF?   Thanks  
  5. Hello,   i was wondering what graphics options that i can include for DX9 2D sprite based game, currently i have resolution, window mode (Fullscreen, windowed and borderless) and refresh rate, do you guys have any suggestions?   Thanks
  6. Thanks guys for further explanation, however i'm using multithreading in loading levels and creating textures, so it wont be a problem since the game didnt start rendering -except for the loading screen- and other parts of multithreading have nothing to do with DirectX like AI and collisions are completely based on C++ objects and no calls for DX whatsoever.
  7.   THANKKKKKKKKKKKKKKKKKKKKKKKKKKKS :D   how small flag can make a big difference, i was not aware of this flag, thanks a million mate :)
  8. Hello everyone,   this is a very weird problem i'm getting when using D3DXCreateTextureFromFileInMemoryEx, i have TextureFactory class that is responsible of creating all textures in game, i have everything working properly in single threaded environment, now to make things better, i separated textures loading into a different thread, there are no other threads, just main thread and texture loading thread (2 threads only) also i'm using proper locking just incase, however, D3DXCreateTextureFromFileInMemoryEx fails sometimes to create the texture with error:   D3DX: Failed trying to create texture   if i'm debugging the code and going slowly over the lines, it works fine, but if the code is running without hitting any breakpoint it fails. everytime on different texture, and sometimes it works just fine without failing.   i cannot get why it fails when its running on different thread other than the main thread, here is my code, its pretty straight forward: std::lock_guard<std::recursive_mutex> lock(_mutex); D3DXIMAGE_INFO imageInfo; std::vector<char*> buffer = GetFileFromCache(); HRESULT hr = D3DXGetImageInfoFromFileInMemory((LPCVOID)&buffer[0], buffer.size(), &imageInfo); LPDIRECT3DTEXTURE9 D3dTexture; if (SUCCEEDED(hr)) { hr = D3DXCreateTextureFromFileInMemoryEx(*device3d, (LPCVOID)&buffer[0], buffer.size(), imageInfo.Width, imageInfo.Height, D3DX_DEFAULT, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, TRANSPARENT_COLOR, &imageInfo, NULL, &D3dTexture); } if i change the D3DPOOL to DEFAULT, it will always fail with this error:   D3DX: Failed trying to create texture First-chance exception at 0x61921416 (nvd3dum.dll) in Game.exe: 0xC0000005: Access violation reading location 0xFEEEFEEE. Removing mutex lock will not change anything, it will fail as well.   i noticed some pattern on where it fails on nested objects when trying to create the texture like this: Thread  { GameObject->TextureFactory.CreateTexture()  <--- this rarely fails GameObject->CreateNestedGameObject() -> TextureFactory.CreateTexture()     <---- it fails here } i have too many game objects and they contain nested objects, when it always fail on creating nested objects textures but rarely on parent/base object, if i clean the solution and rebuild the failure on base/parent object disappears, i guess because of cached headers since this happens when i change something in code.   Thanks for your help
  9. Thanks guys for your suggestions, Erik suggestion is viable, great and i like the pre-generated mask option which makes loading time near zero, now it takes 1-2 seconds max on my machine but might take alot on other weaker CPUs, so this is great.   However for multiple HitBoxes, its not viable because i feel its too hard for the end user to grasp, i thought of that earlier and to give him a window and he defines hitboxes by drawing Rects marking those areas for the Boss, but if i'm an end user/player then i would be very annoyed to do it for every frame in the sprite sheet, or am i thinking wrong in this part, you guys as players and end users would be annoyed if the designer forced you to define hitboxes for every frame in a sprite sheet?   Krohm, 1600x3200 is sprite sheet, its processed once to get collision masks for all frames, then when collision is checked only the current displayed frame in this image will be processed which is like 800x800 along with the small intersected area between Rects, so its not a problem and actually fast, havent noticed any peaks and lags in frametimes and CPU usage is actually 30%-50% on one core and other cores are drinking tea at 3%, but i still dont get the part of forcing CPU/GPU full sync, could you please explain as it seems a very important note?  
  10.   Yes i hear you and this approach is done for enemies since they dont take much space and textures are pretty small on screen so the difference is too narrow, but for the Boss which occupies half of the screen, the transparent area is too big for the player not to notice especially for dynamic game like mine, my game is sandbox not a static game and the player can create his own Enemies, Bosses,.... and import any image he wants, where as it would be much more easier if its static by defining hitboxes for Bosses and just Rect intersection.  
  11. Hello Everyone,   i'm looking for thoughts and ideas about optimizing Per Pixel Collisions with DX 9 for 2D game, the performance now is good but if there are some others things to do in order to optimize it further, then why not?   Currently i have done the following (there is nothing special in the code since its the standard algorithm):   1. Build Bool Collision mask for every frame in Texture Sprite Sheet. so it goes with lockRect , nested loops and get alpha color then populate the mask with 0,1 based on that.   2. Checking normal collisions with Rect Intersection first, if collision detected then perform per pixel collision check based on collisions masks per the displayed frames. first IntresectRect, if true then check the intersectedRect pixels for source and destination for non alpha pixels colliding.    3. Put a timer to check per pixel collisions if any collision detected for every 2-3 frames instead of every frame since the user will not notice the difference.   Now one of my concerns is loading time when building collisions masks, now it takes less than 1 second to populate a sprite sheet 3200x1600 which is the level's boss, most of other sprite sheets are like 1/4 or 1/3 the size of Boss's sheet, but my CPU is pretty powerful 3770k@ 4.5Ghz and cannot take it as standard.   so what others things i can do to optimize and improve performance for loading and collision further?    Thanks
  12. RogDX9

    2D Collision Mask DX9

    Thanks guys for replies and help.
  13. Hello,   i'm trying to create 2D Collision Mask for A8R8G8B8 Texture, i'm not sure whats wrong, here is the code:   D3DLOCKED_RECT rect; HRESULT hResult = _currentTexture->LockRect(0, &rect, NULL, D3DLOCK_READONLY); if (SUCCEEDED(hResult)) { for (int y = 0; y < GetHeight(); ++y) { for (int x = 0; x < GetWidth(); ++x) { //Should i keep getting this or just put it up outside of the loops will do? D3DCOLOR* pixels = (D3DCOLOR*)rect.pBits; //It fails here sometimes, there is something off when getting the pixel D3DCOLOR a = (pixels[y * rect.Pitch + x] & 0xFF000000) >> 24; } } } i appreciate all the help, thanks.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!