Game Development Reference
In-Depth Information
Here is the full code for the restartPlayer function:
private function restartPlayer():void {
//find the region of the map the player is i
camera.x = player.worldX - (.5 * camera.width);
camera.y = player.worldY - (.5 * camera.height);
if (camera.x < 0) {
camera.x = 0;
player.x = player.worldX + camera.x;
}else if ((camera.x+camera.width) > worldWidth) {
camera.x = worldWidth - camera.width;
player.x = player.worldX - camera.x;
}else {
player.x = .5 * camera.width;
}
if (camera.y < 0) {
camera.y = 0;
player.y = player.worldY + camera.y;
}else if ((camera.y+camera.height) > worldHeight) {
camera.y = worldHeight - camera.height;
player.y = player.worldY - camera.y;
}else {
player.y = .5 * camera.height;
}
camera.nextX = camera.x;
camera.nextY = camera.y;
player.nextX = player.x;
player.nextY = player.y;
player.worldNextX = player.worldX;
player.worldNextY = player.worldY;
player.dx = 0;
player.dy = 0;
player.nextRotation=levelPlayerStartFacing;
player.turnSpeed = .3;
player.maxTurnSpeed = .6;
player.minTurnSpeed = .3;
player.maxVelocity=10;
player.acceleration =.05;
player.deceleration=.03;
player.radius = .5 * player.width;
player.reverseVelocityModifier = .3;
player.animationDelay = 3;
player.velocity = 0;
//reset Look Aheads
lookAheadPoints[0].x = lookAheadPoints[0].y = 0;
lookAheadPoints[1].x = lookAheadPoints[1].y = 0;
lookAheadPoints[2].x = lookAheadPoints[2].y = 0;
Search WWH ::




Custom Search