You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
The text was updated successfully, but these errors were encountered:
They could be declared like
then an enum variable could be declared like that:
and would basically be equivalent of
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:
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).
The text was updated successfully, but these errors were encountered: