From 7e4fd00267d234607901822b7e75ba68d14011fc Mon Sep 17 00:00:00 2001 From: OddlyTimbot Date: Mon, 11 Aug 2025 16:04:21 -0400 Subject: [PATCH] updated instructions week2 enumerators --- week2/codeprimer.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/week2/codeprimer.md b/week2/codeprimer.md index a6c3bd0..1522253 100644 --- a/week2/codeprimer.md +++ b/week2/codeprimer.md @@ -97,6 +97,18 @@ var dollars : float : This simple set of formatters convert the “dollars” value to store them in memory as cents. +### Enumerators + +Enumerators are a collection that allows you to list out valid values for a property with a descriptive name. + +For example, if you were making a 2D Platform game you might list out the directions your player character can be facing, like this: + +```enum FaceDirection{LEFT, RIGHT}``` + +You could then use this enumerator to ensure a variable keeping track of your direction could no be assigned an invalid value like UP or DOWN. + +```var facing:FaceDirection = FaceDirection.LEFT``` + ### Decorators In Godot decorators can be used to control when a variable will be assigned. This is a convenience outside of placing the variable assignment in a function.