Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

284 Neutral

About littletray26

  • Rank
  1. littletray26

    Learning Direct3D Programming properly

    I'm not sure I would even know where to begin with that. I wouldn't know how to interact with hardware without using Direct3D functions.   I think that would be putting me way over my head for now, and that I should probably just stick with trying to learn how to use Direct3D properly.    What do you think?
  2. Hi GameDev community, it's been a while!   I've been doing hobby game programming for a few years now, but I feel like considering how long I've been doing it for, I am nowhere near as fluent with it as I should be.   I learned all that I know about DirectX 9 programming from www.directxtutorial.com and while I feel that was a decent start, I feel like I've missed learning a lot of things that is therefore limiting my ability to program. I've been able to make basic games in the past with not much of an issue, but now I decided to take on my biggest personal project so far, which is nothing huge, just a Doom-style FPS, and I'm quickly finding that I'm on the internet looking for help on things that I feel I should already know how to do.   That said, I'm wondering if anyone here can point me to a good resource (website/book/anything) on learning to program in DirectX properly. I had a look through the documentation that ships with the DXSDK but it doesn't make a lot of sense to me.  I need something that will start with the basics again, and not only tell me what to do but explain /why/ it works that way so that I can retain the information without it just being a bunch of jargon.   I'm still using Direct3D 9 functions, I've been meaning to learn Direct3D 11 functions but looking over it briefly it seems a lot more complex and I've been putting it off because of that.   So my questions are as follows:   -Do I need to learn to use 9 effectively before migrating to 11? -What is a good resource to start learning to program in DirectX effectively and know what I'm actually doing?   Thanks in advance.
  3. littletray26

    How Pointers Really Work

  4. Hey GameDev   I'm trying to lock an LPD3DXMESH's vertex buffer so as I can fiddle with the vertices. My problem is that as follows:   When you manually create a mesh in code, you have your own CUSTOMVERTEX kind of struct, and then when you lock the vertex buffer, you can hand it a void pointer to your CUSTOMVERTEX type. EG CUSTOMVERTEX* vert; vb->Lock(0, 0, (void**)&vert, NULL); But when I need to lock the meshs vertex buffer, I don't have a vertex class to lock it with.   So my question is, how do I lock the mesh vertex buffer when I don't have a vertex struct? Is there a kind of default vertex stuct I can use?
  5. littletray26

    First Person Rolling problem

    I'm not sure I understand the question to begin with
  6. littletray26

    Terrain Collision and Bounding spheres?u

    Yeah, I know how to do bounding sphere collision detection, sorry if my question wasn't worded right. I was just wondering why this may be preferrable to a bounding box or cylinder which could be closer to the size of the player then a sphere
  7. Hey Gamedev    I will shortly be making up some terrain for my game. How I do this, I'm yet to decide between a static mesh, or a heightmap.   I have 2 questions;   First of all, what is the best/the simplest/easiest/whatever gets the job done/ way to detect collision between the character, and the terrain. I don't want the player "snapped" onto the terrain, so I don't want him to glide up massive slopes. How would I go about doing this? Detecting the collision and offsetting the characters y position accordingly?   My second question is, I constantly hear people using bounding spheres for player collision. Why is this? It seems to me that a bounding box or cylinder would be more accurate (unless the player was a fatty) why use a sphere?
  8. littletray26

    First Person Rolling problem

    I was able to fix the issue by using D3DXMatrixRotationY instead of D3DXMatrixRotationAxis in the Yaw function. Thanks, guys.
  9. Hey GameDev :)   My first person camera is rolling when I move the mouse in circles. I don't know what's wrong with it, please help me. void Pitch(float angle) { D3DXMATRIX T; D3DXMatrixRotationAxis(&T, &right, angle); D3DXVec3TransformCoord(&up, &up, &T); D3DXVec3TransformCoord(&lookDirection, &lookDirection, &T); } void Yaw(float angle) { D3DXMATRIX T; D3DXMatrixRotationAxis(&T, &up, angle); D3DXVec3TransformCoord(&lookDirection, &lookDirection, &T); D3DXVec3TransformCoord(&right, &right, &T); }
  10. littletray26

    Help rotating a sprite D3D9

    Thank you so much. I don't know why I didn't think of this, I just assumed that because I didn't have to do it in 3D transformations, I wouldn't have to for this.    Thank you :)
  11. littletray26

    Help rotating a sprite D3D9

    Hey GameDev   I've 2 sprites, an enemy and a guy, and I'm trying to rotate guy, but not enemy:   void Draw(LPD3DXSPRITE sprite, LPDIRECT3DDEVICE9 d3dDevice) { sprite->Draw(texture, &enemy, &D3DXVECTOR3(0, 0, 0), &D3DXVECTOR3(400, 400, 0), D3DCOLOR_ARGB(255,255,255,255)); sprite->SetTransform(&matrix); sprite->Draw(texture, &guy, &D3DXVECTOR3(0, 0, 0), &guyPosition, D3DCOLOR_ARGB(255,255,255,255)); }     Problem is it rotates both of them, and I don't know why. Help?
  12. littletray26

    How does tan work exactly?

    So I've been looking for a way to get a sprite to rotate and face my cursor, and I came across this:     Now I understand that it works, but I'm wondering if one of you fine people can help me understand why it works. I'm not that great at  math, but I take every chance I can to improve. I need to understand the concept behind tan, and inverse tan, so I can apply it to any other problems I might face that would require it.   Thanks   Just to clarify, I know what tan is. Tan = opposite / adjacent. I know you feed tan the angle, and it returns o/a but why is o/a needed? What is it used for? and I don't know what inverse tan is at all.
  13. littletray26

    Things aren't drawing to the screen

    Ah thank you so much! 
  14. littletray26

    Things aren't drawing to the screen

      Thank you very much. If it helps I can post the full source code;   main.h   #include <Windows.h> #include <d3d9.h> #include <d3dx9.h> #include <ctime> #include <iostream>   #pragma comment (lib, "d3d9.lib") #pragma comment (lib, "d3dx9.lib") #pragma comment (lib, "winmm.lib")   #ifndef once   const int WINDOWWIDTH = 800; const int WINDOWHEIGHT = 600;   int Clamp(int value, int min, int max) { if (value < min) return min; else if (value > max) return max;   else return value; }   bool IsCollide(RECT a, RECT b) { if (a.left < b.right && a.right > b.left) if (a.top < b.bottom && a.bottom > b.top) return true; return false; }   class Player { private: int points; int paddleSpeed; int paddleWidth; int paddleHeight; D3DXVECTOR3 position; RECT collisionBox; RECT textureBox;   public: void Draw(LPD3DXSPRITE sprite, LPDIRECT3DTEXTURE9 texture); void Update(); void GivePoints(int p); int GetPoints(); RECT GetCollisionBox();   Player(int x, int y, int xx, int yy) { textureBox.left = x; textureBox.bottom = yy; textureBox.right = xx; textureBox.top = y; paddleWidth = xx - x; paddleHeight = yy - y; points = 0; paddleSpeed = 8; position = D3DXVECTOR3((WINDOWWIDTH / 2) - (paddleWidth /2), (WINDOWHEIGHT - paddleHeight - 10), 0); } };   int Player::GetPoints() { return points; }   RECT Player::GetCollisionBox() { return collisionBox; }   void Player::Draw(LPD3DXSPRITE sprite, LPDIRECT3DTEXTURE9 texture) { sprite->Draw(texture, &textureBox, &D3DXVECTOR3(0, 0, 0), &position, D3DCOLOR_ARGB(255, 255, 255, 255)); }   void Player::Update() { collisionBox.bottom = position.y + paddleHeight; collisionBox.left = position.x; collisionBox.right = position.x + paddleWidth; collisionBox.top = position.y;   if(GetAsyncKeyState(VK_LEFT)) position.x -= paddleSpeed; else if(GetAsyncKeyState(VK_RIGHT)) position.x += paddleSpeed;   position.x = Clamp(position.x, 0, WINDOWWIDTH - paddleWidth); }   void Player::GivePoints(int p) { points += p; }   class Ball { private: RECT collisionBox; RECT textureBox; D3DXVECTOR3 position; D3DXVECTOR2 velocity; int ballSpeed; int ballWidth; int ballHeight;   public: RECT GetCollisionBox(); void Draw(LPD3DXSPRITE sprite, LPDIRECT3DTEXTURE9 texture); void Update(RECT* playerCollision, int players);   Ball(int x, int y, int xx, int yy) { textureBox.bottom = yy; textureBox.left = x; textureBox.right = xx; textureBox.top = y; ballSpeed = 2; ballWidth = xx - x; ballHeight = yy - y; position.x = (WINDOWWIDTH / 2) - (ballWidth / 2); position.y = (WINDOWHEIGHT / 2) - (ballHeight / 2); //velocity = D3DXVECTOR2(rand() % ballSpeed + -ballSpeed, ballSpeed); } };   RECT Ball::GetCollisionBox() { return collisionBox; }   void Ball::Draw(LPD3DXSPRITE sprite, LPDIRECT3DTEXTURE9 texture) { sprite->Draw(texture, &textureBox, &D3DXVECTOR3(0, 0, 0), &position, D3DCOLOR_ARGB(255,255,255,255)); }   void Ball::Update(RECT* playerCollision, int players) { //position.x += velocity.x; //position.y += velocity.y;   collisionBox.bottom = position.y + ballHeight; collisionBox.left = position.x; collisionBox.right = position.x + ballWidth; collisionBox.top = position.y;   for (int i = 0; i < players; i++) { if (IsCollide(playerCollision, collisionBox)) velocity.y *= -1; }   if (position.x < 0) velocity.x *= -1; else if (position.x > WINDOWWIDTH - ballWidth) velocity.x *= -1;   if (position.y < 0) velocity.y *= -1; }   class Brick { };   #define once #endif   gameskel.h   #include "main.h"   LPDIRECT3DTEXTURE9 sprites; Player* players; Ball* balls;   void LoadContent(LPDIRECT3DDEVICE9* d3dDevice) { D3DXCreateTextureFromFile(*d3dDevice, L"resources\\graphics\\sprites.png", &sprites); players = new Player(0, 0, 114, 13); balls = new Ball(116, 0, 128, 13); }   void Update(DWORD delta) { players->Update(); balls->Update(&players->GetCollisionBox(), 1); }   void Draw(LPD3DXSPRITE sprite) { balls->Draw(sprite, sprites); players->Draw(sprite, sprites); }   void Cleanup() { sprites->Release(); delete[] players; delete[] balls; }   WinMain.cpp   //Winmain cpp #include "main.h" #include "gameskel.h"   LPDIRECT3D9 d3d; LPDIRECT3DDEVICE9 d3dDevice; LPD3DXSPRITE spriteMachine;   LPARAM CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); void InitializeD3D(HWND hWnd); void Pulse(DWORD delta); void KillD3D();   int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { srand(time(0));   HWND hWnd; WNDCLASSEX wc; DWORD delta = 0; DWORD prevFrameTime = 0; DWORD thisFrameTime = 0;   ZeroMemory(&wc, sizeof(WNDCLASSEX)); wc.cbSize = sizeof(WNDCLASSEX); wc.hbrBackground = (HBRUSH)COLOR_WINDOW; wc.hCursor = LoadCursor(0, IDC_ARROW); wc.lpfnWndProc = WndProc; wc.hInstance = hInstance; wc.lpszClassName = L"WINDOW"; wc.style = CS_HREDRAW | CS_VREDRAW;   RegisterClassEx(&wc);   hWnd = CreateWindowEx( NULL, L"WINDOW", L"Smashout!", WS_OVERLAPPED | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU, 400, 300, WINDOWWIDTH, WINDOWHEIGHT, NULL, NULL, hInstance, NULL);   ShowWindow(hWnd, nShowCmd);   MSG msg = {0}; InitializeD3D(hWnd);   while (true) { thisFrameTime = timeGetTime();   if(prevFrameTime != 0) delta = thisFrameTime - prevFrameTime; else delta = 0;   prevFrameTime = thisFrameTime;   if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg);   if (msg.message == WM_QUIT) break; }   Pulse(delta); }   KillD3D(); return msg.wParam; }   LPARAM CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_DESTROY: { PostQuitMessage(0); return 0; break; } }   return DefWindowProc(hWnd, msg, wParam, lParam); }   void InitializeD3D(HWND hWnd) { d3d = Direct3DCreate9(D3D_SDK_VERSION); D3DPRESENT_PARAMETERS d3dPP;   ZeroMemory(&d3dPP, sizeof(D3DPRESENT_PARAMETERS)); d3dPP.BackBufferWidth = WINDOWWIDTH; d3dPP.BackBufferHeight = WINDOWHEIGHT; d3dPP.BackBufferCount = 1; d3dPP.hDeviceWindow = hWnd; d3dPP.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dPP.Windowed = true;   d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dPP, &d3dDevice); D3DXCreateSprite(d3dDevice, &spriteMachine);   LoadContent(&d3dDevice); }   void Pulse(DWORD delta) { Update(delta); d3dDevice->Clear(0, 0, D3DCLEAR_TARGET, 0x427AFF, 1, 0); d3dDevice->BeginScene(); spriteMachine->Begin(D3DXSPRITE_ALPHABLEND);   Draw(spriteMachine);   spriteMachine->End(); d3dDevice->EndScene(); d3dDevice->Present(NULL, NULL, NULL, NULL); }   void KillD3D() { Cleanup(); spriteMachine->Release(); d3dDevice->Release(); d3d->Release(); }
  15. littletray26

    Things aren't drawing to the screen

      DirectX is indeed running in Debug mode, and the ball is not behind anything. I'm only drawing 2 things to the screen at the moment; the paddle, and the ball. The paddle is at the bottom of the screen, whereas the ball SHOULD be drawing to the middle. There is nothing in the way. As I said in the first post as well, if I change the code to  LPDIRECT3DTEXTURE9 sprites; Player* players; Ball ball1(116, 0, 128, 13); //changed   void LoadContent(LPDIRECT3DDEVICE9* d3dDevice) { D3DXCreateTextureFromFile(*d3dDevice, L"resources\\graphics\\sprites.png", &sprites); players = new Player(0, 0, 114, 13); }   void Update(DWORD delta) { players[0].Update(); ball1.Update(&players[0].GetCollisionBox(), 1); //changed }   void Draw(LPD3DXSPRITE sprite) { players[0].Draw(sprite, sprites); ball1.Draw(sprite, sprites); //changed }   void Cleanup() { sprites->Release(); delete[] players; }    It draws fine. So I'm confident it's not a depth issue
  • 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!