xspeed = -walk_speed; } } if (Key.isDown(Key.RIGHT)) { if (jump_walk or can_jump) { xspeed = walk_speed; } } if (Key.isDown(Key.SPACE) and can_jump) { yspeed -= jump_power; can_jump = false; } yspeed += gravity; if (yspeed>max_yspeed) { yspeed = max_yspeed; } while (_root.lev.hitTest(this._x, this._y+this._height/2-1+yspeed, true)) { yspeed--; can_jump = true; } while (_root.lev.hitTest(this._x-this._width/2+1+xspeed, this._y, true)) { xspeed++; } while (_root.lev.hitTest(this._x+this._width/2-1+xspeed, this._y, true)) { xspeed--; } while (_root.lev.hitTest(this._x, this._y-this._height/2+1+yspeed, true)) { yspeed++; } this._y += yspeed; this._x += xspeed; if (jump_walk or can_jump) { xspeed = 0; } };
最终效果(按左右方向键和空格键试试)
上一篇:新手入门:PHP网站开发中常见问题汇总
下一篇:用Photoshop快速打造海水冲击特效文字
|