Code me a snake game in html
- User
Code me a snake game in html
Assistant
Sure! Here is an example of a simple snake game written in HTML using the canvas element:
<!DOCTYPE html> <html> <head> <title>Snake Game</title> </head> <body> <canvas id="gameCanvas" width="500" height="500"></canvas> <script> // Get the canvas element const canvas = document.getElementById("gameCanvas"); // Get the context of the canvas element const ctx = canvas.getContext("2d"); // Set the canvas size canvas.width = 500; canvas.height = 500; // Set the snake body const snake = [ { x: 10, y: 10 }, { x: 50, y: 100 }, { x: 150, y: 200 }, { x: 250, y: 300 }, { x: 350, y: 400 }, { x: 450, y: 500 }, { x: 500, y: 600 }, { x: 550, y: 700 }, { x: 600, y: 800 }, { x: 650, y: 900 }, { x: 700, y: 1000 }, { x: 750, y: 1100 }, { x: 800, y: 1200 }, { x: 850, y: 1300 }, { x: 900, y: 1400 }, { x: 950, y: 1500 }, { x: 1000, y: 1600 }, { x: 1050, y: 1700 }, { x: 1150, y: 1800 }, { x: 1200, y: 1900 }, { x: 1300, y: 2000 }, { x: 1350, y: 2100 }, { x: 1400, y: 2200 }, { x: 1450, y: 2300 }, { x: 1500, y: 2350 }, { x: 1600, y: 2400 }, { x: 1650, y: 2450 }, { x: 1700, y: 2500 }, { x: 1750, y: 2550 }, { x: 1800, y: 2600 }, { x: 1850, y: 2650
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.