Skip to content

Instantly share code, notes, and snippets.

// Convert world coordinates to local screen pixels coordinates.
function worldToScreenCoordinates(player_global_pixel_position_x, player_global_pixel_position_y) {
// All players to this player distance.
let another_player_x_distance = players[current_player_ID].position.x - player_global_pixel_position_x;
let another_player_y_distance = players[current_player_ID].position.y - player_global_pixel_position_y;
// Get screen pixel coordintes from 0,0.
return [(windowWidth / 2) - another_player_x_distance, (windowHeight / 2) - another_player_y_distance];
@AhmedSa-mir
AhmedSa-mir / Main Loop
Created April 13, 2018 18:44
Simulation Loop
// Player attributes:
// 1 = ID
// 2 = Tail
// 3 = Block
// 4 = Shadow
while (true) {
for(player in rooms[room_name].players) {
let time = process.hrtime();