-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
They could be declared like
enum enemytype
goomba
koopa
hammerbro
then an enum variable could be declared like that:
enemytype enemy_type
and would basically be equivalent of
ct U ENEMY_GOOMBA = 0
ct U ENEMY_KOOPA = 1
ct U ENEMY_HAMMER_BRO = 2
U enemy_type
Basically, it would make the code prettier and with less possibility of accidental bugs (you'd have to consciously add another enemy type to the enum instead of hamming up and putting it spawn_enemy(4) when you meant enemy 3. Because enums would be basically numbers under the hood, they would be usable in a switch statements, like this:
enum scene
main_menu
main_game
vars
scene current_scene = main_menu
switch current_scene
case main_menu
process_mainmenu()
break
case main_game
process_maingame()
break
default:
break
This would be great for state machines and would avoid the headache of having to define countless constants (also would spare the developer wondering why stuff breaks or doesn't work when wrong value was provided by accident).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels