What coding conventions does Gamefroot use?

Coding conventions are style guidelines for programming.

They typically cover:

  • Naming and declaration rules for variables and functions
  • Rules for the use of spacing and comments
  • Programming practices and principles

Coding conventions 

  • secure quality
  • Improve code readability
  • Makes code maintenance easier

NAMING CONVENTIONS

When making games in Gamefroot, we should follow widespread JavaScript naming conventions. These allow us to distinguish variables, classes, and constants, so we can more easily see what code is supposed to do.

VARIABLES

Variables are places to store changeable data. Name them in Camel Case. Start by making all capital letters lowercase. Then capitalise the first letter after each space. Finally, take out all the spaces. For example starting position x becomes startingPositionX.

CLASSES and UNIQUE IDENTIFIERS

A class is a specific kind of object that can be distinguished from other objects, like a name or type. For example, two obstacles have the same class. Name them in Pascal Case. This is just like Camel Case, but the first letter is capitalised too. For example, you win becomes YouWin

CONSTANTS


Constants are places to store data that never changes. Name them in Screaming Snake Case. Start by making all letters capitals. Then replace all spaces with underscores. For example, starting position x becomes STARTING_POSITION_X. Constants look distinctive, so you can quickly tell if an item is supposed to change. 

CODE FORMATTING

To tidy code in Gamefroot, right-click on the Script Stage and click Clean up Blocks. This makes it much easier to find code in a large script. 


Leave a Reply