1629821568
Build Tetris in Javascript React with Typescript. This is version 2 of my popular course where I added in Typescript and optimized some stuff.
This tutorial is considered advanced React so therefore I recommend having basic knowledge in Javascript and React.
Project files: https://github.com/weibenfalk/react-tetris-with-typescript/
00:00 - Introduction
00:36 - Starter Files
08:58 - Create Components
28:54 - Custom Hooks - usePlayer and useStage
51:56 - Stage update and player movement
1:06:21 - Collision detection
1:17:04 - Player rotation
1:25:46 - Clear rows
1:33:00 - Finish the game - useGameStatus
#react #javascript #typescript #gamedev
1598839687
If you are undertaking a mobile app development for your start-up or enterprise, you are likely wondering whether to use React Native. As a popular development framework, React Native helps you to develop near-native mobile apps. However, you are probably also wondering how close you can get to a native app by using React Native. How native is React Native?
In the article, we discuss the similarities between native mobile development and development using React Native. We also touch upon where they differ and how to bridge the gaps. Read on.
Let’s briefly set the context first. We will briefly touch upon what React Native is and how it differs from earlier hybrid frameworks.
React Native is a popular JavaScript framework that Facebook has created. You can use this open-source framework to code natively rendering Android and iOS mobile apps. You can use it to develop web apps too.
Facebook has developed React Native based on React, its JavaScript library. The first release of React Native came in March 2015. At the time of writing this article, the latest stable release of React Native is 0.62.0, and it was released in March 2020.
Although relatively new, React Native has acquired a high degree of popularity. The “Stack Overflow Developer Survey 2019” report identifies it as the 8th most loved framework. Facebook, Walmart, and Bloomberg are some of the top companies that use React Native.
The popularity of React Native comes from its advantages. Some of its advantages are as follows:
Are you wondering whether React Native is just another of those hybrid frameworks like Ionic or Cordova? It’s not! React Native is fundamentally different from these earlier hybrid frameworks.
React Native is very close to native. Consider the following aspects as described on the React Native website:
Due to these factors, React Native offers many more advantages compared to those earlier hybrid frameworks. We now review them.
#android app #frontend #ios app #mobile app development #benefits of react native #is react native good for mobile app development #native vs #pros and cons of react native #react mobile development #react native development #react native experience #react native framework #react native ios vs android #react native pros and cons #react native vs android #react native vs native #react native vs native performance #react vs native #why react native #why use react native
1598015898
Work on real-time JavaScript Snake game project and become a pro
Snake game is an interesting JavaScript project for beginners. Snake game is a single-player game, which we’ve been playing for a very long time. The game mainly consists of two components – snake and fruit. And we just need to take our snake to the food so that it can eat and grow faster and as the number of fruits eaten increases, the length of snake increases which makes the game more interesting. While moving if the snake eats its own body, then the snake dies and the game ends. Now let’s see how we can create this.
To implement the snake game in JavaScript you should have basic knowledge of:
1. Basic concepts of JavaScript
2. HTML
3. CSS
Before proceeding ahead please download source code of Snake Game: Snake Game in JavaScript
HTML builds the basic structure. This file contains some basic HTML tags like div, h1, title, etc. also we’ve used bootstrap (CDN is already included).
index.html:
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DataFlair Snake game</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<link rel="stylesheet" href="static/style.css">
</head>
<body>
<div class="container">
<div class ="Jumbotron">
<h1>DataFlair Snake game using vanilla JavaScript</h1>
<h2 class="btn btn-info">
Score: 0
</h2>
<div class="containerCanvas">
<canvas id="canvas" width="500" height="500" class="canvasmain"> </canvas>
</div>
</div>
</div>
<script src="static/fruit.js"></script>
<script src="static/snake.js"></script>
<script src="static/draw.js"></script>
</body>
</html>
We have used simple HTML tags except
#javascript tutorial #javascript project #javascript snake game #simple snake game #javascript
1629821568
Build Tetris in Javascript React with Typescript. This is version 2 of my popular course where I added in Typescript and optimized some stuff.
This tutorial is considered advanced React so therefore I recommend having basic knowledge in Javascript and React.
Project files: https://github.com/weibenfalk/react-tetris-with-typescript/
00:00 - Introduction
00:36 - Starter Files
08:58 - Create Components
28:54 - Custom Hooks - usePlayer and useStage
51:56 - Stage update and player movement
1:06:21 - Collision detection
1:17:04 - Player rotation
1:25:46 - Clear rows
1:33:00 - Finish the game - useGameStatus
#react #javascript #typescript #gamedev
1614915153
undefined
#javascript #react #typescript #typescript-tutorial #react-tutorial #react-applications #programming #api-development
1603855523
Playing games is fun. What’s better, and also more beneficial, is creating your own games. Why? It is a great way to learn new skills, or get better. In this tutorial, you will learn how to write your own Tetris game with React, JavaScript and TypeScript. Have fun and work on your programming skills at the same time!
The first step is putting setting up the files you need for our Tetris game. You can do this quickly with the help of create-react-app package. This package can generate starting template for us. There are two ways to get this done. You can install the package globally on your computer, with your favorite dependency manager. This is the first way.
The second way is using it via npx. You don’t have to install any package if you want to use it. Not even if you want to use it more often. If you have stable internet connection, you can use npx. It will temporarily download the package, let you use it, and then delete it. It is almost like using npm except that you don’t bloat your disk.
One thing before you proceed to generating the template. This tutorial will use TypeScript. This means that you have to include --typescript
flag when you use create-react-app. So, if you prefer the first way, use npm create-react-app react-tetris-ts --typescript
or yarn create-react-app react-tetris-ts --typescript
.
If you want to use npx just replace npm, or yarn, with npm. The rest will be the same: npx create-react-app react-tetris-ts --typescript
. After npm, yarn or npx do its job, you are ready to start building our Tetris game. You don’t need to add any other dependencies, unless you want to. If so, go ahead. Otherwise, you are good to go.
// package.json
{
"name": "react-tetris-ts",
"version": "0.1.0",
"private": true,
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"dependencies": {
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-scripts": "3.0.1",
"typescript": "3.5.1"
},
"devDependencies": {
"@types/jest": "24.0.13",
"@types/node": "12.0.7",
"@types/react": "16.8.19",
"@types/react-dom": "16.8.4"
}
}
When you are done, this will be the structure for this project:
react-tetris-ts/
├─node_modules
├─public
│ ├─favicon.ico
│ ├─index.html
│ └─manifest.json
├─src
│ ├─components
│ │ └─tetris-board.tsx
│ │ └─tetris.tsx
│ ├─styles
│ │ └─styles.css
│ ├─index.tsx
│ └─react-app-env.d.ts
│ └─serviceWorker.ts
└─ package.json
└─ tsconfig.json
Side note: If you want to prevent webpack from automatically opening the browser every time you start the project, do the following. In the root of your project, create _.env.development_
file. Inside this file, add _BROWSER=none_
and save it. From now on, webpack will no longer open the browser when you launch the _start_
npm script.
#typescript #react #javascript #programming #design development