Support and General Use > Plugins/Viewers
Rockbox games
cool_walking_:
1) random_int = (rb->rand() % 5) + 1;
5 is the range. 1 is the lowest possible number. % means modulus (remainder of integer division e.g. 15 % 4 = 3). rb->rand() returns a random number from 0 to some defined really big number.
2) There is a "goto" statement, however it's use is mostly frowned upon because it can lead to "spaghetti code". It's generally better to use functions.
3) Use "return PLUGIN_OK;" in the plugin_start block.
Strife89:
--- Quote from: cool_walking_ on February 28, 2008, 08:53:33 PM ---2) There is a "goto" statement, however it's use is mostly frowned upon because it can lead to "spaghetti code". It's generally better to use functions.
--- End quote ---
Thank you for the reply. :) Little problem with answer #2 - I'm still a complete novice and have no idea how to implement functions yet. I'll try to learn how to use it; but until then, can you give me the exact syntax for the goto command? (I'd mostly like to use it to test functionality when the "first draft" is completed.)
Llorean:
This forum is hardly the place to learn C. Why not find a good online tutorial on C?
Strife89:
I have. And I'm trying to code as I go, but I skimmed through the whole thing and couldn't find the command I want. As mentioned in the linked post, there are oodles of tutorials out there, and it'll simply take WAY too much time to seek out what I need. (I'm a high school senior at the moment, and my main concern right now are the three research projects I have due this month.) I do what I can in my spare time, but it's so limited lately....
Besides, it's not like I'm asking for a lot of help, just a few tips here and there.... :)
cool_walking_:
I didn't mean "there's so many tutorials out there it's hard to wade through the crap ones", more like "there's so much (good) information out there, google will answer any question you could possibly have".
http://en.wikibooks.org/wiki/C_Programming/Control#One_last_thing:_goto
If for whatever reason google doesn't help you, you could join a programming forum. Although I appreciate it might be hard to tell if something is C related or Rockbox related, so maybe they'll let you ask in the #rockbox or #rockbox-community IRC channels. If you're extremely desperate you could PM me, though I'm probably the worst "programmer" I've ever seen in my life.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version