Alert icon
We're changing our privacy policy. This stuff matters.  Learn more  Dismiss

Beginner's Guide to Game Programming Ep1 Part 8 Enumerations and Random Numbers

Loading...

Sign in or sign up now!
6,187
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Jul 24, 2009

The Beginner's Guide to Game Programming:
A Problem Solving Approach
Episode 1: Makin' Pickin' Sticks
Part 8: Enumerations and Random Numbers

Displaying sprites off a sprite sheet with Enumerations

Generating Random Numbers

This is a written and video tutorial created to teach the basics of Allegro and SDL as well as game programming in general, while encouraging the newbie to code it out themselves.

Vimeo page:
http://vimeo.com/moosader

GameTrailers page (having some trouble uploading):
http://www.gametrailers.com/users/lusikkamage/gamepad/index.php?action=fanmovs

You can get the written version and other things at my site:
http://www.moosader.com

Playlist link:
http://www.youtube.com/view_play_list?p=B9C8BC6F495BD17E

  • likes, 0 dislikes

Link to this comment:

Share to:

Uploader Comments (LusikkaMage)

  • 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

  • Enums are pretty. :D

    That's about it. I like making random datatypes for "Direction", "GameState", etc.

  • What does unsigned do?

    I haven't found anything that covers it... ):

  • 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.

  • you are not getting very many view for how awesome this is. ah well, im contributing =P

  • Enumerations aren't popular. :(

Top Comments

  • hi (test)

  • Hey, could you make a tutorial on Allegro particles please please:)

see all

All Comments (20)

Sign In or Sign Up now to post a comment!
  • 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

Loading...

0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more