Book Image

Kotlin Programming By Example

By : Iyanu Adelekan
Book Image

Kotlin Programming By Example

By: Iyanu Adelekan

Overview of this book

Kotlin greatly reduces the verbosity of source code. With Google having announced their support for Kotlin as a first-class language for writing Android apps, now's the time learn how to create apps from scratch with Kotlin Kotlin Programming By Example takes you through the building blocks of Kotlin, such as functions and classes. You’ll explore various features of Kotlin by building three applications of varying complexity. For a quick start to Android development, we look at building a classic game, Tetris, and elaborate on object-oriented programming in Kotlin. Our next application will be a messenger app, a level up in terms of complexity. Before moving onto the third app, we take a look at data persistent methods, helping us learn about the storage and retrieval of useful applications. Our final app is a place reviewer: a web application that will make use of the Google Maps API and Place Picker. By the end of this book, you will have gained experience of of creating and deploying Android applications using Kotlin.
Table of Contents (12 chapters)

Understanding Tetris

Before attempting to develop the Tetris game as an Android application, we need to understand the game, its rules, and its constraints.

Tetris is a matching puzzle video game that makes use of tiles. The name Tetris is derived from the words tetra – the Greek numerical prefix for four – and tennis. The tiles in Tetris combine to make up tetrominoes which are geometric shapes composed of four squares connected orthogonally:

Tetris tetrominoes

In Tetris, a random sequence of tetrominoes fall down upon a playing field. These tetrominoes can be manipulated by the player. A number of motions can be performed on each tetromino piece. Pieces can be moved to the left, to the right, and rotated. In addition, the speed of descent of each piece can be sped up. The objective of the game is to create an uninterrupted horizontal line of ten cells with the...