Learn JavaScript with p5.js by Engin Arslan

Learn JavaScript with p5.js by Engin Arslan
If you are looking for a book that covers both p5.js and JavaScript together, the book entitled Learn JavaScript with p5.js, Coding for Visual Learners by Engin Arslan is for you. The author starts out with small steps and by the end of the book you are coding an interactive game.

For those new to coding, Arslan begins with a discussion of the difference and similarities between coding and programming. Next, he introduces a few basics of both JavaScript and p5.js. After setting up the coding environment, he covers the console.log(), function calls, variables, data types, shape functions and the coordinate system.

Color in p5.js is the next big subject. Arslan concentrates on the RGB color system and how to pass color information to color functions. He discusses parameters, arguments and how to color shapes with functions.

Moving on, Arslan discusses operators, variables and scope. He discusses some of the built-in p5.js variables. He also covers how to control a program with JavaScript conditional statements, booleans and comparison operators. He has his readers displaying text in the console and to the screen.

Next, Arslan introduces interaction, concentrating on mouse related variables and events. He has his readers drawing shapes to the screen with the click of a mouse. He also introduces more ways to control the program with loops, nested loops and random and noise functions.

The next chapter is all about functions. Arslan starts with the function syntax and, by the end of the chapter, his readers know how to write custom functions and how to use the return keyword.

Next Arslan discusses the similarities and differences between the JavaScript objects and arrays data structures. He covers push and pop, remainder operators, index number and length properties. He demonstrates how to use arrays to control text written to the screen. He also covers how to use an array to control the color format for the text.

Events and interactivity is next to be discussed. Arslan uses mouse events to capture user input. He discusses global variables again in relation to events. He also discusses several ways in JavaScript to convert numbers from one data type to another. Next, he demonstrates how to use the translate and rotate functions, and includes the difference between radians and degrees for the angleMode function. He also discusses how to use the push and pop functions again to control individual sections of your program.

Finally, you are ready for the final project, which is an interactive, typing speed game in p5.js that requires you to demonstrate all that you have learn throughout the book. It also demonstrates how to maintain the user's score throughout the duration of the game.

Supporting source code and other materials are available on the book's product page at Apress.com.

Engin Arslan is a web developer, works at Seneca Collage and has coures on Linkedin and Pluralsight.





RSS
Related Articles
Editor's Picks Articles
Top Ten Articles
Previous Features
Site Map





Content copyright © 2023 by Diane Cipollo. All rights reserved.
This content was written by Diane Cipollo. If you wish to use this content in any manner, you need written permission. Contact Diane Cipollo for details.