• Home
  • About
    • Bryce Newell photo

      Bryce Newell

      Here I will be writing my developer diary and will showcase some of the projects that i am working on.

    • Learn More
    • Github
  • Posts
    • All Posts
    • All Tags
  • Projects

Snake Game Update 5

03 Nov 2017

Reading time ~1 minute

Snake Update 5

The next logical step for me was to add a collectable class. This would need to have a random function so that it didn’t spawn in the same place each time but would also need to have a limit on where it could spawn. For ease of use, I decided that I would make the collectable spawn on one of the locations that the snake head could enter so that it would make collision easier, or should I say pseudo-collision.

Thinking back on last year, I remembered an easy function for creating random numbers and that was the rand() function which comes from c++. In order to get it to spawn in at uniform intervals, I would get the random function to create an integer in the range 1-9 then multiply that number by the scale of my play grid (in my case it was 100).



blogc++low level programmingLLP Share Tweet +1