Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

250
Views
Javascript Snake Game Canvas colour collision not working

Collision works inconsistently, trying to make it work every time. The code below is referencing the colour collision that's used to check if the snake is hitting itself. There are other functions in use as well but I believe this is where the problem is occuring.

function snakeCollide() {
  checkColour = ctx.getImageData(rx, ry, 1, 1).data;
  if (rdx > 0) {
    checkColour = ctx.getImageData(rx + rw + 1, ry + rh / 2, 1, 1).data;
  } else if (rdx < 0) {
    checkColour = ctx.getImageData(rx - 1, ry + rh / 2, 1, 1).data;
  } else if (rdy > 0) {
    checkColour = ctx.getImageData(rx + rw / 2, ry + rh + 1, 1, 1).data;
  } else if (rdy < 0) {
    checkColour = ctx.getImageData(rx + rw / 2, ry - 1, 1, 1).data;
  }
  else {
    console.log("TEST")

  }

}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!