void Character::Movement_Sub_Sub() { if (Key_Down(DIK_DOWN)) { char_status = 11; Movement_Lock(); move_direction = 1; } else if (Key_Down(DIK_RIGHT)) { char_status = 21; Movement_Lock(); move_direction = 2; } else if (Key_Down(DIK_LEFT)) { char_status = 31; Movement_Lock(); move_direction = 3; } else if (Key_Down(DIK_UP)) { char_status = 41; Movement_Lock(); move_direction = 4; } else { move_status = 0; } }
void Game_Run(HWND window) { //make sure the Direct3D device is valid if (!d3ddev) return; //update input devices DirectInput_Update(); d3ddev->Clear(0, NULL, D3DCLEAR_TARGET , D3DCOLOR_XRGB(0,0,100), 1.0f, 0); bool isInput = false; SpeedX = 0; SpeedY = 0; //scroll based on key or controller input if (Key_Down(DIK_DOWN) || controllers[0].sThumbLY < -2000) { SpeedY = steps; isInput = true; } if (Key_Down(DIK_UP) || controllers[0].sThumbLY > 2000) { SpeedY = -steps; isInput = true; } if (Key_Down(DIK_LEFT) || controllers[0].sThumbLX < -2000) { SpeedX = -steps; isInput = true; } if (Key_Down(DIK_RIGHT) || controllers[0].sThumbLX > 2000) { SpeedX = steps; isInput = true; } //keep the game running at a steady frame rate if (GetTickCount() - start >= 30) { //reset timing start = GetTickCount(); //start rendering if (d3ddev->BeginScene()) { //update the scrolling view ScrollScreen(isInput); spriteobj->Begin(D3DXSPRITE_ALPHABLEND); std::ostringstream oss; oss << "Scroll Position = " << ScrollX << "," << ScrollY; PrintFont(font, 0, 0, oss.str()); spriteobj->End(); //stop rendering d3ddev->EndScene(); d3ddev->Present(NULL, NULL, NULL, NULL); } } //to exit if (Key_Down(VK_ESCAPE) || controllers[0].wButtons & XINPUT_GAMEPAD_BACK) gameOver = true; }
void Character::Attack() { if (move_status == 0) { if (Key_Down(DIK_SPACE)) { if (attack_delay == 0) { attack_delay = 1; attack_status = 1; combat_status = 1; } } if (attack_delay >= 1) { attack_delay++; if (attack_delay == 30) { attack_delay = 0; attack_status = 0; } } if (attack_delay <= 15 && attack_delay >= 3) { if (move_direction == 1) { char_status = 111; } else if (move_direction == 2) { char_status = 211; } else if (move_direction == 3) { char_status = 311; } else if (move_direction == 4) { char_status = 411; } } else { if (move_direction == 1) { char_status = 1; } else if (move_direction == 2) { char_status = 2; } else if (move_direction == 3) { char_status = 3; } else if (move_direction == 4) { char_status = 4; } } if (attack_delay == 15) { attack_status = 2; } } if (move_status == 1) { attack_delay = 0; attack_status = 0; } }
void Character::Movement() { if (attack_status != 1) { if (move_status == 1) { if (move_direction == 1) { char_status = 11; Movement_Sub(1); } else if (move_direction == 2) { char_status = 21; Movement_Sub(2); } else if (move_direction == 3) { char_status = 31; Movement_Sub(3); } else if (move_direction == 4) { char_status = 41; Movement_Sub(4); } } if (move_status == 0) { if (move_direction == 1) { char_status = 1; } else if (move_direction == 2) { char_status = 2; } else if (move_direction == 3) { char_status = 3; } else if (move_direction == 4) { char_status = 4; } if (Key_Down(DIK_DOWN)) { char_status = 1; if (move_direction == 1) { move_count_keeper++; } else { move_count_keeper = 0; } move_direction = 1; if (move_direction == 1) { move_instant_count++; } } else if (Key_Down(DIK_RIGHT)) { char_status = 2; if (move_direction == 2) { move_count_keeper++; } else { move_count_keeper = 0; } move_direction = 2; if (move_direction == 2) { move_instant_count++; } } else if (Key_Down(DIK_LEFT)) { char_status = 3; if (move_direction == 3) { move_count_keeper++; } else { move_count_keeper = 0; } move_direction = 3; if (move_direction == 3) { move_instant_count++; } } else if (Key_Down(DIK_UP)) { char_status = 4; if (move_direction == 4) { move_count_keeper++; } else { move_count_keeper = 0; } move_direction = 4; if (move_direction == 4) { move_instant_count++; } } else { move_count_keeper = 0; move_instant_count = 0; } } if (move_count_keeper >= 10 && move_status == 0) { Movement_Lock(); } if (move_instant_count == 2 && move_count_keeper == 2) { Movement_Lock(); } } }