改變鍵盤事件
function doKeys()
// 改變高度,讓入侵者打不到, 或改為3D模式
if( keys.l && playerMoveEnable )
{
objects.Player_1.pos.z += playerMoveSpeed;
}
if( keys.k && playerMoveEnable )
{
objects.Player_1.pos.z -= playerMoveSpeed;
}
// 增加 y方向移動
if( keys.up && playerMoveEnable )
{
objects.Player_1.pos.y += playerMoveSpeed;
}
if( keys.down && playerMoveEnable )
{
objects.Player_1.pos.y -= playerMoveSpeed;
}
// 改a,d 為 left, right 鍵
if( keys.right && playerMoveEnable )
{
objects.Player_1.pos.x += playerMoveSpeed;
if( objects.Player_1.pos.x > 15 )objects.Player_1.pos.x = 15;
}
if( keys.left && playerMoveEnable )
{
objects.Player_1.pos.x -= playerMoveSpeed;
if( objects.Player_1.pos.x < 0 )objects.Player_1.pos.x = 0;
}
沒有留言:
張貼留言