Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Uno Mas: Homing */
- platform3D(-25, -25, 0, 70, 70, 1, color(82, 255, 82));
- function homingEnemy(x, y, z, id, speed) {
- if (!"homingEnemies" in player || player["homingEnemies"] === undefined) {
- player["homingEnemies"] = {};
- }
- if (!id in player["homingEnemies"] || player["homingEnemies"][id] === undefined) {
- player["homingEnemies"][id] = [x, y, z];
- } else {
- currentLocation = player["homingEnemies"][id];
- var direction = [player.pos[0] - currentLocation[0], player.pos[1] - currentLocation[1], player.pos[2] - currentLocation[2]];
- var normal = Math.sqrt(direction[0] * direction[0] + direction[1] * direction[1] + direction[2] * direction[2]);
- newLocation = [currentLocation[0] + speed * direction[0] / normal, currentLocation[1] + speed * direction[1] / normal, currentLocation[2] + speed * direction[2] / normal];
- player["homingEnemies"][id] = newLocation;
- }
- platform3D(player["homingEnemies"][id][0] - 1, player["homingEnemies"][id][1] - 1, player["homingEnemies"][id][2] - 1, 2, 2, 2, color(0, 0, 0));
- if (isColliding(player.pos[0] - player.size[0], player.pos[1] - player.size[1], player.pos[2] - player.size[2], player.size[0] * 2, player.size[1] * 2, player.size[2] * 2, player["homingEnemies"][id][0] - 1, player["homingEnemies"][id][1] - 1, player["homingEnemies"][id][2] - 1, 2, 2, 2)) {
- player.pos[2] = 10;
- }
- if (player.pos[0] == player.respawnPos[0] && player.pos[1] == player.respawnPos[1] && player.pos[2] == player.respawnPos[2]) {
- player["homingEnemies"][id] = undefined;
- }
- }
- homingEnemy(30, 30, -30, "W", 0.2);
- homingEnemy(-30, 30, -30, "X", 0.2);
- homingEnemy(-30, -30, -30, "Y", 0.2);
- homingEnemy(30, -30, -30, "Z", 0.2);
- platform3D(10, 10, -2, 15, 15, 1, color(255, 82, 82));
- platform3D(-15, -20, -8, 10, 15, 3, color(82, 255, 255));
- addCheckpoint(15, 20, -1);
- addCoin(-10, 20, -1);
Advertisement
Add Comment
Please, Sign In to add comment