pandanicur
Untitled
7 posts
Don't wanna be here? Send us removal request.
pandanicur · 5 years ago
Link
1 note · View note
pandanicur · 5 years ago
Link
0 notes
pandanicur · 7 years ago
Text
Snakes
segmentation
I did not invent Snake. Neither did Google, or Neave, or Nokia. I’m not even sure who it was. But it’s such a simple game that I recently coded my own.
Tumblr media
If you’re somehow not familiar with Snake, basically, you control a uh… snake, slithering around eating apples while avoiding the walls (and yourself!). That means each grid cell is one of four things: snake, apple, collision, or empty.
Tumblr media
In programming, there’s a concept I’m probably getting wrong called “control flow,” which essentially describes the path your code follows as it executes. I’ve found that separating stuff into standalone functions with descriptive names makes it easy to follow that control flow.
Tumblr media
For example, every time the snake advances into the next grid cell, the code executes a function called isCollision(x, y) that checks if the cell at those coordinates is outside the grid… or already contains the snake.
Tumblr media
Once I defined that function, I realized it could be put to work in another spot. After the snake eats an apple, a new one is generated, but this also can’t be placed outside the grid or in a snake cell. So isCollision(x, y) becomes the condition of a do{} while() loop that randomly generates the new apple’s coordinates.
Tumblr media
So even without comments, it’s clear what both of these functions do. Just like the snake itself, this segmentation is great for scaling.
tl;dr: split Javascript code into short functions with descriptive names and variables; be clear and consistent with CSS classes
project: snakeSnacker
131 notes · View notes
pandanicur · 7 years ago
Text
The moment I intend to break up with her but still need to rehearse
Tumblr media
0 notes
pandanicur · 7 years ago
Quote
live life like you are going to leave earth ASAP
PANDA
0 notes
pandanicur · 7 years ago
Photo
Tumblr media Tumblr media Tumblr media Tumblr media Tumblr media Tumblr media Tumblr media Tumblr media
a self proclaimed bad boy
15K notes · View notes
pandanicur · 7 years ago
Photo
Tumblr media
A Revolutionary Platform of IT SERVICES Is Releasing Soon!
268 notes · View notes