大佬教程收集整理的这篇文章主要介绍了c – 游戏跳跃逻辑,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
以下功能用于在按下特定键时更新玩家的位置.允许玩家左右移动,并跳到同一个地方,或者向左或向右跳(形成弧形).
bool updatePlayerPosition(Movement* mov){ if (this->keyPressed(SDLK_RIGHT)) { mov->applyForce(1); // Changes the veLocity in X } if (this->keyPressed(SDLK_LEFT)) { mov->applyForce(-1); // Changes the veLocity in X } if (this->keyPressed(SDLK_SPACE)) { mov->jump(); // Changes the veLocity in Y } if (this->keyPressed(SDLK_DOWN)) { mov->fallDown(); // Changes the veLocity in X and Y } Point* pos = mov->getPosition(); // check whether the position is out of bounds if(Level::allowsMove(pos)){ // If it is not,I update the player's current position position->x = pos->x; position->y = pos->y; return true; } // If the movement is not allowed,I don't change the position else { mov->setPosition(*position); return false; } }@H_616_10@这是一个错误:当我到达关卡的末端(有一个固定的宽度)时,如果我试图向右移动并同时跳跃,则玩家会跳起并停留在空中.只有当我释放空格键时,玩家才会到达地面.
我怎样才能解决这个问题?
以上是大佬教程为你收集整理的c – 游戏跳跃逻辑全部内容,希望文章能够帮你解决c – 游戏跳跃逻辑所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。