Skip to content
blikoor edited this page May 9, 2020 · 2 revisions

Home>Notes>Part-3

Part-3: Making 2D Arrays

Best Practices & Naming Conventions

Some files needed to be renamed/moved in order to best conform to general naming conventions and best practices used by Godot itself. This is unfortunately still a learning process, that necessitates some changes along the way. The following is a summary of the guidelines followed:

Never include spaces in the filenames. Spaces can cause issues with command line tools, which can be used to automate tasks. Use lowercase for the folder names to distinguish them from the source code.

The top-level folders now include:

  • 'assets' used for shared files, this include images, sounds, music and text produced outside Godot. Name the assets using snake_case.

  • 'src' used for the source code of the game. It includes all scenes and GDScript files which are all part of the source. Use PascalCase for folder names in the src folder as they represent game systems or groups of systems. Scenes and script files also use PascalCase as they represent classes. This is also how Godot names them by default.

Deviations

Piece.gd ➨ Tile.gd

  1. Create and attach a new script to 'Tile.tscn' ('res://src/tiles/' folder), name it 'Tile.gd' and save the script in the 'res://src/tiles/' folder.

Grid.gd 2. Create and attach a new script to 'Game.tscn' ('ress//src/' folder), name it 'Grid.gd' and save the script in the 'ress://src/' folder.

  1. Declare an 2dArray called 'all_pieces' ➨ 'all_tiles'

Summary

Array
Arrays are used to store lists of various elements, such as numbers or objects. One dimensional arrays are more common, and multi-dimensional can be used for storing data related to grids or 3D space. Each element of the array is referenced by an integer index value starting from zero for the first element.

More information

Clone this wiki locally