GD Script Flashcards
What is a constant and it’s naming format
A constant is a value that cannot be changed
Write names in CAPS with _ beween words -
ie const DAVID_PILK
What is a dynamic variable and how does it apply to Godot
a dynamic variable means you do not have to name the variable type and the type can change in the program
What is a keyword
words reserved by GD script such as var or enum, cannot be used as identifiers
Types of numbers
Integer - a whole number,
float - a number with a decimal
constant - a number that doesn’t change
Define Enum
a list of constants
Variable name format
lower-case text, join words with underscores this_variable
types of variable
int, bool, float and string
static typing
where you declare what type a variable is - ie var name : string = “David”
Global scope vs local scope
determines where a variable is accessible from
Data type
An attribute which tells the computer how a programmer intends to use the data
What do data types do?
- Define the types of operations that can be done on the data
- How the values can be stored
- The meaning of the data
Literal value, alternate name and what it is
Literal
A value stored directly in the source code, without referencing something else
Null?
Represented by null in the code
Represents - No data type
When to use floats over integers
When more accuracy is needed
In Boolean values which is true and which is fakes, 0 or 1?
False = 0 True = 1
If you don’t assign a value to a variable what data type will it contain?
Null
What is a typed variable?
A variable where the data type is specified
Ie var name : string = “Sap”
Casting?
Changing a variable type to another variable type ie “10” to 10
What is the casting operator
As
ie. var amount : int = “10” as int
When to use a variable?
When you have a datatype that may change over the course of the game
ie var health : int = 100
Memory Life Cycle
Allocate
Use
Release
What system allocates memory
The OS
Operator
A symbol used to manipulate operands ie. + * etc
What is an Operand?
A number, Boolean or string
ie. 1 +2 - the operands are 1 and 2
Assignment operator
Assign a value to its left operand based on the value of its right operand
ie x = y
Remainder assignment
%=
Additional assignment?
+=
Subtraction assignment
-=
Multiplication assignment
*=
Devision assignment
/=
What are comparison operands
Compares two values and reruns a result based on if the answer is true
Equal operator
==
Not equal operator
!=
Greater than or equal to
> =
Less thank or equal to
<=
Not symbol
!
And symbol
&&
Or symbol
||
Can a constant have a null value?
No
Can you change a constants type? Ie string to int
No
Three benefits of using constants?
Readable code
Easier debugging
Save time when editing code
When to use constants?
When you have a value you don’t think will change for the lifecycle is the game
Naming conventions for constants vs variables
const NAME = var name =