Products
Features
YouTube Video Summarizer
Summarize YouTube videos
Web & PDF Highlighter
Highlight web pages & PDFs
Chat with PDF
Ask any PDF questions with AI
Ask AI Clone
Chat with your highlights & memories
Audio Transcriber
Transcribe audio files to text
Glasp Reader
Read and highlight articles
Kindle Highlight Export
Export your Kindle highlights
Idea Hatch
Hatch ideas from your highlights
Integrations
Obsidian Plugin
Notion Integration
Pocket Integration
Instapaper Integration
Medium Integration
Readwise Integration
Snipd Integration
Hypothesis Integration
Apps & Extensions
Chrome Extension
Safari Extension
Edge Add-ons
Firefox Add-ons
iOS App
Android App
Discover
Discover
Ideas
Discover new ideas and insights
Articles
Curated articles and insights
Books
Book recommendations by great minds
Posts
Essays and notes from readers
Quotes
Inspiring quotes collection
Videos
Curated videos and summaries
Explore Glasp
Glasp Newsletter
Weekly insights and updates
Glasp Talk
Interview series with great minds
Glasp Blog
Latest news and articles
Glasp Use Cases
Learn how others use Glasp
Build & Support
Glasp API
Access Glasp's API for developers
MCP Connector
Connect Glasp to Claude & ChatGPT
Community
Glasp Reddit Community
Students
Student discount and benefits
FAQs
Frequently Asked Questions
AboutPricing
DashboardLog inSign up

Coding Challenge #3: The Snake Game

3.4M views
•
April 20, 2016
by
The Coding Train
YouTube video player
Coding Challenge #3: The Snake Game

TL;DR

In this coding challenge, the creator attempts to program the popular Snake game using JavaScript and p5js framework.

Transcript

Hello and welcome to what today will be a 15 minute coding challenge! I am going to attempt to program, from scratch, in JavaScript, the snake game. I don't think I've ever done this before, perhaps I have I've certainly made stuff that resembles it. But if you're not familiar with the Snake game, pause this video, Google it, play it - I think you'... Read More

Key Insights

  • 👾 The snake game can be recreated using JavaScript and frameworks like p5js.
  • 🐍 Object-oriented programming principles can be applied to create a snake object with properties and functions.
  • 😋 Collision detection is crucial in the game to handle interactions with food and the snake's own body.
  • 🎮 Randomization and user control are important aspects of gameplay design.
  • 👾 The game development process involves continuous iteration and testing to improve functionality and fix errors.

Install to Summarize YouTube Videos and Get Transcripts

Explore YouTube Video Summarizer or Get YouTube Transcript Extractor

Questions & Answers

Q: What is the purpose of the setup and draw functions in p5js?

The setup function is executed once at the start and is used for initialization. The draw function is called repeatedly and is used for animation or updating visual elements.

Q: How does the snake object handle movement and direction?

The snake object has an xspeed and yspeed, which determine the direction and speed of movement. These values are updated in the update function, which is called repeatedly in the draw loop.

Q: How is the food generated in the game?

The food position is randomly selected within the canvas using the pickLocation function. The food is represented by a rectangle of a specific size and color.

Q: How does the snake object increase its length when it eats food?

When the snake object detects a collision with the food, its total property is incremented, and a new location is assigned for the food using the pickLocation function. This causes the tail array to grow by one element.

Q: How is collision detection implemented in the game?

The snake object checks if its current position intersects with any of the positions in its tail array. If a collision is detected, the game ends and the snake's length and tail array are reset.

Summary & Key Takeaways

  • The creator explains the process of developing the Snake game using JavaScript and p5js framework.

  • They start by creating a canvas and a Snake object with properties like x, y, xspeed, and yspeed.

  • They implement functions for updating the snake's position, displaying it on the canvas, and allowing user control with arrow keys.

  • The creator adds food for the snake to eat, increases its length, and handles collision detection with its own body.


Read in Other Languages (beta)

English

Share This Summary 📚

Summarize YouTube Videos and Get Video Transcripts with 1-Click

Download browser extensions on:

Try YouTube Summary with ChatGPT & Claude or YouTube Transcript Generator

Explore More Summaries from The Coding Train 📚

8.1: Fractals - The Nature of Code thumbnail
8.1: Fractals - The Nature of Code
The Coding Train
ITP/IMA Winter Show 2019 thumbnail
ITP/IMA Winter Show 2019
The Coding Train
9.4: Genetic Algorithm: Looking at Code - The Nature of Code thumbnail
9.4: Genetic Algorithm: Looking at Code - The Nature of Code
The Coding Train
Coding Challenge #116: Lissajous Curve Table thumbnail
Coding Challenge #116: Lissajous Curve Table
The Coding Train
Coding Challenge #126: Toothpicks thumbnail
Coding Challenge #126: Toothpicks
The Coding Train
Text Generation using Spell with Nabil Hassein thumbnail
Text Generation using Spell with Nabil Hassein
The Coding Train

Summarize YouTube Videos and Get Video Transcripts with 1-Click

Download browser extensions on:

Try YouTube Summary with ChatGPT & Claude or YouTube Transcript Generator

Apps & Extensions

  • Chrome Extension
  • Safari Extension
  • Edge Add-ons
  • Firefox Add-ons
  • iOS App
  • Android App

Key Features

  • YouTube Video Summarizer
  • Web & PDF Summarizer
  • Web & PDF Highlighter
  • Chat with PDF
  • Ask AI Clone
  • Audio Transcriber
  • Glasp Reader
  • Kindle Highlight Export
  • Idea Hatch

Integrations

  • Obsidian Plugin
  • Notion Integration
  • Pocket Integration
  • Instapaper Integration
  • Medium Integration
  • Readwise Integration
  • Snipd Integration
  • Hypothesis Integration

More Features

  • APIs
  • MCP Connector
  • Blog & Post
  • Embed Links
  • Image Highlight
  • Personality Test
  • Quote Shots

Company

  • About us
  • Blog
  • Community
  • FAQs
  • Job Board
  • Newsletter
  • Pricing
Terms

•

Privacy

•

Guidelines

© 2026 Glasp Inc. All rights reserved.