I am new to C ++ and DirectX, I came from XNA. I developed a game like Fly The Copter . What I did was created by the Wall class. While the game is running, I draw all the walls. In XNA, I saved the walls in ArrayList, and in C ++ I used a vector. In XNA, the game is fast and very slow in C ++. Here is the C ++ code:
void GameScreen::Update() { //Update Walls int len = walls.size(); for(int i = wallsPassed; i < len; i++) { walls.at(i).Update(); if (walls.at(i).pos.x <= -40) wallsPassed += 2; } } void GameScreen::Draw() { //Draw Walls int len = walls.size(); for(int i = wallsPassed; i < len; i++) { if (walls.at(i).pos.x < 1280) walls.at(i).Draw(); else break; } }
In the Update method, I decrease the value of X by 4. In the Draw method, I call sprite-> Draw (Direct3DXSprite). These are the only codes that run in the game loop. I know this is bad code, if you have an idea to improve it, please help. Thanks and sorry for my english.
source share