• Stars
    star
    202
  • Rank 193,691 (Top 4 %)
  • Language
    JavaScript
  • Created over 5 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A vanilla javascript game

Tetris

A vanilla javascript game

Watch my tutorial here

I have kept the styling at a bare miniumum for you to go wild and make it your own. Please tag me as I would LOVE to see your game!!!

Tetris is a tile-matching puzzle game from the 80’s. Try to get your personal high score by moving each of the 5 randomly selected Tetromino shapes sideways and/or rotating by quarter-turns, so that they form a solid horizontal line without gaps. When such a line is formed, it disappears and any blocks above it fall down to fill the space. For each line you will receive 10 points.

This was my first project from General Assembly's Software Engineering Immersive Course. It was also my first time building a project with JavaScript.

Tetris

Brief

  • The game should stop if a Tetrimino fills the highest row of the game board
  • The player should be able to rotate each Tetrimino about its own axis
  • If a line is completed it should be removed and the pieces above should take its place
  • Render a grid-based game in the browser
  • Include separate HTML / CSS / JavaScript files
  • Use Javascript for DOM manipulation
  • Deploy your game online, using Github Pages, where the rest of the world can access it
  • Use semantic markup for HTML and CSS (adhere to best practices)

Technologies Used

  • HTML5
  • CSS3
  • JavaScript
  • Git
  • GitHub
  • Google Fonts

Features piece of code no.1

//freeze the shape
  function freeze() {
    // if block has settled
    if(current.some(index => squares[currentPosition + index + width].classList.contains('block3') || squares[currentPosition + index + width].classList.contains('block2'))) {
      // make it block2
      current.forEach(index => squares[index + currentPosition].classList.add('block2'))
      // start a new tetromino falling
      random = nextRandom
      nextRandom = Math.floor(Math.random() * theTetrominoes.length)
      current = theTetrominoes[random][currentRotation]
      currentPosition = 4
      draw()
      displayShape()
      addScore()
      gameOver()
    }
  }
  freeze()

Features piece of code no.2

  //Add score
  function addScore() {
    for (currentIndex = 0; currentIndex < 199;currentIndex += width) {
      const row = [currentIndex,currentIndex+1,currentIndex+2,currentIndex+3,currentIndex+4,currentIndex+5,currentIndex+6,currentIndex+7,currentIndex+8,currentIndex+9]
      if(row.every(index => squares[index].classList.contains('block2'))) {
        score += 10
        lines +=1
        scoreDisplay.innerHTML = score
        linesDisplay.innerHTML = lines
        row.forEach(index => {
          squares[index].style.backgroundImage = 'none'
          squares[index].classList.remove('block2') || squares[index].classList.remove('block')

        })

MIT Licence

Copyright (c) 2020 Ania Kubow

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

*Translation: Ofcourse you can use this for you project! Just make sure to say where you got this from :)

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

memory-game

JavaScript, HTML and CSS grid-based game
JavaScript
396
star
2

Tetris-Basic

This is a simple no nonsense version of Tetris that has no styling
JavaScript
262
star
3

mario

A game of Mario using JavaScript and Kaboom.js
JavaScript
252
star
4

candy-crush

A vanilla JavaScript Game inspired by Candy Crush
JavaScript
171
star
5

Nokia3310-Snake

A vanilla JavaScript game with tutorial
JavaScript
164
star
6

climate-change-live-api

A Demo to show how to build your own API and host in on RapidAPI
JavaScript
163
star
7

space-invaders

A vanilla JavaScript game with HTML and CSS
JavaScript
160
star
8

battleships

javaScript HTML and CSS
JavaScript
138
star
9

nodejs-webscraper

Demo for showing how to get backend data to the frontend
JavaScript
129
star
10

minesweeper

A simplified game of minesweeper using vanilla JavaScript
JavaScript
121
star
11

burger-api

My Burger Api
JavaScript
119
star
12

netflix-clone-graphql-datastax

A Netflix Clone built using React GraphQL and DataStax, exploring Pagination and Slicing
JavaScript
115
star
13

flappy-bird

A game of Flappy Bird made in pure JavaScript, HTML and CSS
JavaScript
110
star
14

whac-a-mole

Vanilla JavaScript game
JavaScript
110
star
15

pac-man

Vanilla javaScript Game with HTML and CSS
JavaScript
107
star
16

connect-four

A Pure JavaScript grid-based game
JavaScript
106
star
17

candy-crush-reactjs

A minimal game of Candy Crush in React
JavaScript
97
star
18

portfolio-website

Portfolio website
JavaScript
93
star
19

Frogger

A retro grid-based game in vanilla JavaScript, HTML and CSS
JavaScript
90
star
20

stargate-tik-tok

JavaScript
85
star
21

Doodle-Jump

Doodle Jump clone in JavaScript, HTML and CSS
JavaScript
83
star
22

airbnb-sanity-backend

The backend for our Airbnb App, built using Sanity.io.
JavaScript
80
star
23

tinder-clone

A Tinder Clone for educational purposes
JavaScript
76
star
24

zelda

A game of Zelda in JavaScript using Kaboom.js
JavaScript
73
star
25

responsive-portfolio

HTML
72
star
26

wordle-javascript

A Game of Wordle with the benefit of 2x API from RapidAPI
JavaScript
65
star
27

rock-paper-scissors-x3

3 ways to code Rock Paper Scissors in JavaScript
JavaScript
63
star
28

airbnb-sanity-frontend

This is the frontend for my AirBnb Project built using Next.js and Sanity.io
JavaScript
63
star
29

2048

A game of 2048 in vanilla javaScript, HTML and CSS
JavaScript
58
star
30

chrome-trex-game

A game made in pure javaScript HTML and CSS
JavaScript
54
star
31

disney-clone-graphcms

A demo to show how to use graphcms
JavaScript
54
star
32

flappy-birds-react-native

A game of flappy birds in react native
JavaScript
51
star
33

crypto-dashboard-react

A Crypto Dashboard built in React and Nodejs using RapidAPI
JavaScript
49
star
34

breakout

A game of breakout in HTML, CSS and JavaScript
JavaScript
48
star
35

portfolio-with-animations

A Portfolio with Animations in JavaScript
JavaScript
48
star
36

monday-crm-clone

A Clone of the Monday CRM System for tutorial purposes
JavaScript
47
star
37

light-dark-mode-portfolio

A light and dark theme portfolio in HTML, CSS and JS
CSS
40
star
38

Project-04

Business Bank Account Dashboard using React and Django
JavaScript
39
star
39

typewriter

typewriter effect in JavaScript
JavaScript
38
star
40

graphQL-federation-crypto

A Crypto App built to pracitse GraphQL Federation
JavaScript
36
star
41

distance-matrix-routing-with-tom-tom-api

Distance Matrix Routing App with Tom Tom API
JavaScript
31
star
42

javascript-playing-piano

A Playing Piano built in JavaScript
HTML
30
star
43

flight-widget-vanilla-javascript

A Flight widget made in vanilla JavaScript just for fun!
JavaScript
29
star
44

google-translate-clone

A Google Translate Clone built for tutorial purposes
JavaScript
28
star
45

tic-tac-toe

Introduction to JavaScript with Tic-Tac-Toe
JavaScript
27
star
46

deployed-todo-app

JavaScript
27
star
47

trivia-app

A trivia App built in vanilla JavaScript
JavaScript
26
star
48

twitch-messenger-clone

A Messenger App built in React and Node.js using getStream.io
JavaScript
26
star
49

regex-openai

The Code for the iframe
HTML
25
star
50

Advanced-React-and-Redux-2019

Detailed project on advanced React and Redux concepts - Authentication, Testing, Middlewares, HOC's, and Deployment
JavaScript
25
star
51

foundation-app-subgraph

Supporting Code for Querying Data on the Blockchain Tutorial
TypeScript
24
star
52

linktree-clone-css-js

Build a Linktree Clone! (super simple!) HTML + CSS (+ JS optional)
HTML
23
star
53

mocha-test

Boilerplate for Mocha tests
HTML
23
star
54

Predictive-Text-Search-Bar

JavaScript
23
star
55

pacman-AI-live

live game of pacman
JavaScript
22
star
56

birthday-countdown

A Birtday countdown in JavaScript
JavaScript
21
star
57

candy-crush-reactjs-with-game-state

A game of Candy Crush in React where you can save game state
JavaScript
21
star
58

opentelemetry-movies-microservices

JavaScript
19
star
59

rock-paper-scissors-react

Rock Paper Scissors in React
JavaScript
19
star
60

financial-article-classifier-ai-model

19
star
61

moving-wave-portfolio

A Portfolio built in HTML and CSS with a moving wave SVG and working submit from
HTML
19
star
62

responsive-gallery-website

HTML
18
star
63

Google-Home-Chatbot

Voice and Chatbot for Google Home
JavaScript
18
star
64

jeopardy-javascript

A game of Jeopardy in javaScript
HTML
18
star
65

opentelemetry-tracing

Introduction to Tracing
JavaScript
18
star
66

sudoku-solver

A project to learn hw to use APIs in JavaScript and NodeJS
JavaScript
17
star
67

javascriptgames

HTML
16
star
68

hashing-passwords-template-app

A React form that will hash your passwords and send them to a database
JavaScript
16
star
69

zip-food-delivery-app

16
star
70

whack-a-mole-react-native

We build Whack-a-mole in react native
JavaScript
15
star
71

zelda-inventory

A Project to practise Database use
JavaScript
15
star
72

hotel-app

A Project to Demo using a GraphQL API with Serverless Functions
JavaScript
15
star
73

react-nodejs-database-flight-widget

JavaScript
14
star
74

buzzfeed-clone-typescript-database

Build a Buzzfeed Clone in TypeScript + REST API Database + Node.js!
TypeScript
14
star
75

serverless-database

How to use a serverless database with DataStax and Netlify Functions
JavaScript
14
star
76

word-association-game

A React Project built using RapidAPI
JavaScript
13
star
77

pacman-with-voice-AI-final

Final code for tutorial pacan-with-voice-AI
JavaScript
13
star
78

jump-slide

A simple function for jumping and sliding in games
JavaScript
13
star
79

word-association-vanilla-javascript

A Word Association Game made in vanilla JavaScript just for fun!
JavaScript
13
star
80

web-monetization-demo

A demo to show users how to use web monetization on their websites
HTML
13
star
81

my-javascript-action

JavaScript
12
star
82

travel-blog

A travel blog built using React and Sanity.io
JavaScript
12
star
83

communications-dashboard

12
star
84

pac-man-move-closer-logic

Making Blinky chase PacMan wherever he is on the board in vanilla javaScript
JavaScript
12
star
85

show-more-feature

Show More Feature in Vanilla JavaScript, HTML and CSS
HTML
11
star
86

space-invaders-kaboom.js

A game of Space Invaders using Kaboom.js
JavaScript
10
star
87

pacman-with-voice-AI

pacman in JS for voice AI tutorial
JavaScript
10
star
88

zelda-kaboom.js

Zelda using Kaboom.js
JavaScript
10
star
89

buzzfeed-clone-react

Build Buzzfeed quiz in React + JSON Server!
JavaScript
10
star
90

React-app-setup

Packages and code for setting up a React App
JavaScript
10
star
91

beer-generator-javascript

Random beer Generator using vanilla JavaScript API fetch
CSS
9
star
92

next-landing-page

CSS
8
star
93

mobee-psql-data

Demo data for the Mobee App
8
star
94

to-do-app

JavaScript
8
star
95

wdi-fundamentals-memorygame

Pre-course prep work using HTML, CSS and JS
CSS
8
star
96

burger-app

For a Document API and ExpressJS Demo
JavaScript
7
star
97

video-app-frontend

A demo to show how to use Structured Content
JavaScript
7
star
98

javascript-nodejs-api-flight-widget

JavaScript
7
star
99

eslintrc-example

AN example of a .eslintrc file
7
star
100

video-app-backend

A Demo of how to use Structured Content
JavaScript
6
star