Skip to content

Instantly share code, notes, and snippets.

@txrun
txrun / snake-levels.md
Last active August 4, 2016 22:39
Levels in Snake

As I begin to write this I have a Snake game which has a 'snake' moving across the 2-D space of the canvas with which the game is implemented. The snake, capable of moving at right angles at any time relative to its direction, goes around consuming food that materialises at a random location. A tab is kept on the number of food items consumed by the snake which is displayed as the score. The game comes to an end when the snake collides into itself. This is hardly a challenge as the canvas space is big and the snake has enough room to move around easily avoiding collision into itself. Some possible ways to make the game more challenging include the following :

  • Increasing the speed of the snake at each level of the game - this means the player will have to be more alert as the game progresses. As the levels increase the speed of the snake increases and thus the probablity of the snake colliding into itself.
  • Inserting mazes into the game - Another not so novel way to challenge the player is to introduce o
@txrun
txrun / initialIssuesJS.md
Last active August 9, 2016 11:06
Issue log /checklist

Starting to hack in a new language can be daunting; especially with the bad practices that I have been accustomed to in me earlier during college days when I started learning to code. These practices manifested the moment the arena changed to a professional setting and I was given a problem to be solved in JavaScript. I am listing out a bunch of stumbling blocks that I encountered while I was headed down that path -

  • Not using functions generously - One of the many things that I was used to is writing simple pieces of code without using functions. which almost always meant one long piece of code.When the number of lines increased the program began to look like one giant monolith that had only minumum readability and hard to comprehend.
  • Naming variables and functions - The name should be self descriptive at the same time be as minimal as possible. For example, a function to check if an input numnber is in range is can simply be called isNumberInRange() or a variable to store the length of the input value