Skip to content

Instantly share code, notes, and snippets.

@bashbaugh
Last active February 26, 2019 03:37
Show Gist options
  • Save bashbaugh/c9887f8346de35cd2e7d7b8999a6ddb7 to your computer and use it in GitHub Desktop.
Save bashbaugh/c9887f8346de35cd2e7d7b8999a6ddb7 to your computer and use it in GitHub Desktop.
// Ensure that player is within canvas:
player_x = Math.max(0, Math.min(player_x, canvas_element.width))
// Draw player:
canvas.beginPath(); // Start drawing
canvas.arc(player_x, player_y, player_radius, 0, 2*Math.PI); // Draw 360 degree arc (full circle)
canvas.fillStyle = player_color; // Set color
canvas.fill(); // Fill in circle
canvas.closePath(); // End drawing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment