Beginner's Guide to Game Programming Ep1 Part 8 Enumerations and Random Numbers
Uploader Comments (LusikkaMage)
Top Comments
-
hi (test)
-
Hey, could you make a tutorial on Allegro particles please please:)
All Comments (20)
-
can you please help me. When I add in the random function thingy instead of the stick picking a random area then staying there it jumps across the screen super fast and doesnt stop.
-
Old video, however, I see someone asked "Why use enums?" You correctly replied that they are pretty (aka readability). However, there's another reason that enums or constant globals are preferred to #define symbols. Good compilers can optimize for all variables stored in memory. #defines are replaced preprocessor and so, optimizations may not be applied.
-
"If you don't assign a value to each one(enum), it will be assigned an arbitrary number"
Actually, by default it starts with 0 for the first one and adds 1 for each following element.
-
first off, great job as always (i'm a true fan!)
but i suggest to delve deeper into "random" numbers generation via the % operator ... there's a problem with lower bits being far from random.
-
I'm having trouble with my coordinate generation function. The first time I use it, it generates a random number. After that, the coordinates go in a diagonal line until they hit the edge of the screen and then it appears at the opposite side of the screen. What could I be doing wrong?
-
Enumerations automatically initialize all the stuff they contain with an increasing value each time. So first will be one, second will be 2 and so on.
This is usefull when you just want any old intialized value.
-
WOW, they take up tons of RAM on your XT computer. :P
Why use enums?
don't they take up a bit of RAM and do the same thing as #define wich uses 0 RAM?
maybe i'm missing something :P
Farzher 2 years ago
Enums are pretty. :D
That's about it. I like making random datatypes for "Direction", "GameState", etc.
LusikkaMage 2 years ago
What does unsigned do?
I haven't found anything that covers it... ):
HomocidalCanineK9 2 years ago
Well there's a limit on what an integer can be; only so many bits can be stored in a computer, right? Normally this is -INTMAX to +INTMAX
If it's "unsigned", that means it's positive only, so it doubles how large it can be since it doesn't have an amount for the - numbers.
LusikkaMage 2 years ago
you are not getting very many view for how awesome this is. ah well, im contributing =P
SupLuiKir 2 years ago 2
Enumerations aren't popular. :(
LusikkaMage 2 years ago