DEV Community

Sam Shelly
Sam Shelly

Posted on

Making 2048 From Scratch

A little bit of background, I am currently taking a course through Code Academy learning how to code in python and this is my first free form project. Armed with my limited coding knowledge and the task to create something I hatched a plan. Code Academy suggested remaking a game like Blackjack or Tic-Tac-Toe but I wanted to do something different. So I decided to make a game that I have played but never beaten, and what I landed on is 2048. The game is simple enough but even then I ran into a few challenges.

some gameplay

The hardest part to code was pushing the all the numbers in every direction. To do this I programed pushing numbers to the left by appending all non zero numbers than adding zero to maintain 4 numbers in the list. To move to the right I reversed the list before I compacted then after to make it look normal. Movement up and down was a bit more complicated but I achieved this by creating a temporary list with the nth value in every list, pushing it left or right, then decoding it. Anyways here it is.

Terminal-2048-python-project

Code Academy Portfolio Project 1 This is a recreation of 2048 by Gabriele Cirulli for a coding challenge




I had a lot of fun coding this and not only did I test my coding abilities but I learned about uploading to GitHub and blogging on this website!

Top comments (1)

Collapse
 
mannu profile image
Mannu

Welcome to DEV community ! @samzombie