Skip to content


Subversion checkout URL

You can clone with
Download ZIP
100644 234 lines (169 sloc) 10.168 kB
8c82f36 @kthakore Out line for CPAN added
kthakore authored
1 =head0 CPAN
18bc16f @kthakore Initial Commit
kthakore authored
56722d2 @kthakore Intro blurb for CPAN chapter
kthakore authored
3 The Comprehensive Perl Archive Network (CPAN) is the other part of the Perl language. By now most Perl developers should be aware of how to search and get modules from CPAN. This chapter will focus on why to use CPAN for games. Next we will take a look in what domain (Model, View or Controller) does a module solve a problem for. Moreover we would want to look at what is criteria to pick one module from another, using the many tools provided by CPAN.
18bc16f @kthakore Initial Commit
kthakore authored
283b985 @garu CPAN helper modules
garu authored
5 =head1 Modules
7 It is good to reuse code.
9 =head2 MVC Method
11 See where the module fits, Model, View or Controller
13 =head3 View
15 SDL will do most but helper module (Clipboard) are cool to have.
17 The I<SDLx::Widget> bundle comes separately, but is meant to provide
18 you with several common game elements such as menu, dialog boxes
19 and buttons, all seamlessly integrated with SDL.
22 =head3 Model
24 The logic and modelling behind most popular games is already on
25 CPAN, so you can easily plug them in to create a new game of
26 Chess, Checkers, Go, Life, Minesweeping, Cards, etc. There are
27 even classes for platform games (like I<Games::Nintendo::Mario>),
28 creating and solving mazes, generating random dungeon maps, you
29 name it.
31 If your game needs to store data, like objects and status for saved
32 games or checkpoints, you can use I<Storable> or any of the many
33 data serializers available.
35 In fact, speaking of data structures, it is common to keep game
36 data in standard formats such as JSON, YAML or XML, to make you
37 able to import/export them directly from third-party tools like
38 visual map makers or 3D modeling software. Perl provides very nice
39 modules to handle the most popular formats - and some pretty
40 unusual ones. Parsers vary in speed, size and thoroughness,
41 so make sure to check the possible candidates and use the one
42 that fits your needs for speed, size and accuracy.
46 =head3 Controller
49 If you need to roll a dice, you can use I<Games::Dice>, that even
50 lets you receive an array of rolled dice, and use RPG-like syntax
51 (e.g. "2d6+1" for 2 rolls of a 6-side die, adding 1 to the result).
53 You can also use I<Sub::Frequency> if you need to do something or
54 trigger a particular action or event only sometimes, or at a given
55 probability.
57 Your game may need you to mix words, find substrings or manipulate
58 word permutations in any way (like when playing scrabble), in which
59 case you might find the I<Games::Word> module useful.
8c82f36 @kthakore Out line for CPAN added
kthakore authored
62 =head1 Picking Modules
0b1aefe @garu CPAN chapter: finding the right module
garu authored
64 So, you thought of a nice game, identified your needs, typed some
65 keywords in L<>, and got tons of results. What now?
66 How to avoid vaporware and find the perfect solution for your needs?
68 =head2 Documentation
70 Once you find a potential module for your application, make sure you
71 will know how to use it. Take a look at the SYNOPSIS section of the
72 module, it should contain some code snippets showing you how to use
73 the module's main features. Are you comfortable with the usage syntax?
74 Does it seem to do what you expect it to? Will it fit nicely to whatever
75 it is you're coding?
77 Next, skim through the rest of the documentation. Is it solid enough
78 for you? Does it look complete enough for your needs, or is it
79 easily extendable?
81 =head2 License
83 It's useless to find a module you can't legally use. Most (if not all)
84 modules in L<CPAN|> are free and open source
85 software, but even so each needs a license telling developers what
86 they can and cannot do with it. A lot of CPAN modules are released
87 I<"under the same terms as Perl itself">, and this means you can
88 pick between the Artistic License or the GPL (version 1).
90 Below is a short and incomplete list of some popular license choices
91 by CPAN developers:
93 =over 4
95 =item * Artistic License - L<>
97 =item * GPL (all versions and variations) - L<>
99 =item * MIT License - L<>
101 =back
103 See L<> for a
104 comprehensive list with each license's full documentation.
106 You should be able to find the module's license by going to a
107 "LICENSE AND COPYRIGHT" section, usually available at the bottom of the
108 documentation, or by looking for a license file inside that distribution.
110 B<Note:> Some modules might even be released into CPAN as
111 I<< public domain >>, meaning they are not covered by intellectual
112 property rights at all, and you are free to use them as you see fit.
113 Even so, it's usually considered polite to mention authors as a courtesy,
114 you know, giving credit where credit is due.
117 =head2 Ratings
119 The CPAN Ratings is a service where developers rate modules they
120 used for their own projects, and is a great way to have some actual
121 feedback on how it was to use the code on a real application. The
122 ratings are compiled into a 1 to 5 grade, and displayed below the
123 module name on CPAN. You can click on the I<< "Reviews" >> link right
124 next to the rating stars to see any additional comments by the
125 reviewers, praising, criticizing or giving some additional comments
126 or the distribution and/or its competition.
8c82f36 @kthakore Out line for CPAN added
kthakore authored
129 =head2 Dependencies
0b1aefe @garu CPAN chapter: finding the right module
garu authored
131 Modules exist so you don't have to reinvent the wheel, and for that same
132 reason each usually depends on one or more modules itself. Don't worry
133 if a module depends on several others - code reusability is a good
134 thing.
136 You may, however, be interested in B<which> modules it depends on,
137 or, more practically, in the likelihood of a clean installation by your
138 users. For that, you can browse to L<> and
139 input the module's name on the search box.
141 The CPAN Testers is a collaborative matrix designed to help developers
142 test their modules in several different platforms, with over a hundred
143 testers each month making more than 3 million reports of CPAN modules.
144 This particular CPAN Testers service will show you a list of
145 dependencies and test results for each of them, calculating the average
146 chance of all tests passing (for any platform).
148 While seeing all the dependencies and test results of a couple of modules
149 that do the same thing might help you make your pick, it's important to
150 realize that the I<< "chance of all tests passing" >> information at
151 the bottom of the results means very little. This is because test
152 failures can rarely be considered independent events, and are usually
153 tied to not running on a specific type of operating system, to the perl
154 version, or even due to the tester running out of memory for reasons
155 that may not even concern the module being evaluated. If you don't care
156 about your application running on AIX or on perl 5.6.0, why would you
157 dismiss a module that only fails on those conditions?
8c82f36 @kthakore Out line for CPAN added
kthakore authored
0b1aefe @garu CPAN chapter: finding the right module
garu authored
160 =head2 CPAN Testers Charts
8c82f36 @kthakore Out line for CPAN added
kthakore authored
0b1aefe @garu CPAN chapter: finding the right module
garu authored
162 So, how do you know the actual test results for a module on the CPAN? How
163 can you tell if that module will run in your target machine according to
164 architecture, operating system and perl version?
166 The CPAN Testers website at L<> offers a direct
167 search for distributions by name or author. To see the results for the
168 SDL module, for instance, you can go to
169 L<>. You can also find a
170 test report summary directly on CPAN, by selecting the distribution
171 and looking at the I<< "CPAN Testers" >> line. If you click on the
172 I<< "View Reports" >> link, you'll be redirected to the proper CPAN
173 Testers page, like the one shown above.
175 The first chart is a PASS summary, containing information about the most
176 recent version of that module with at least one I<PASS> report submitted,
177 separated by platform and perl version.
179 Second is a list of selected reports, detailing all the submitted test
180 results for the latest version of the given module. If you see a
181 I<FAIL> or I<UNKNOWN> result that might concern you - usually at a
182 platform you expect your application to run - you can click on it to
183 see a verbose output of all the tests, to see why it failed.
185 Another interesting information displayed is the report summary on the
186 left sidebar, showing a small colored graph of PASS-UNKNOWN-FAIL
187 results for the latest versions of the chosen module. If you see a
188 released version with lots of FAIL results, it might be interesting to
189 dig deeper or simply require a greater version of that module in your
190 application.
8c82f36 @kthakore Out line for CPAN added
kthakore authored
193 =head3 Bug Reports
0b1aefe @garu CPAN chapter: finding the right module
garu authored
195 When picking a module to use, it is very important to check out its
196 bug reports. You can do that by either clicking on the
197 I<< "View/Report Bugs" >> link on the module's page on CPAN, or
198 on the I<< "CPAN RT" >> (for Request Tracker) box on the right side of
199 the documentation page.
201 Look for open bugs and their description - i.e. if it's a bug or a
202 whislist - and see if it concerns your planned usage for that module.
203 Some bug reports are simple notices about a typo on the documentation
204 or a very specific issue, so make sure you look around the ticket
205 description to see if it's something that blocks your usage, or if
206 you can live with it, at least until the author delivers an update.
208 It may also interest you to see how long the open bugs have been there.
209 Distributions with bugs dating for more than two years might indicate
210 that the author abandoned the module to pursue other projects, so you'll
211 likely be on your own if you find any bumps. Of course, being free
212 software, that doesn't mean you can't fix things yourself, and maybe even
213 ask the author for maintainance privileges so you can update your fixes
214 for other people to use.
217 =head2 Release Date
219 A old distribution might mean a solid and stable distribution, but it
220 can also mean that the author doesn't care much about it anymore. If
221 you find a module whose latest version is over 5 years old, make sure
222 to double check test results and bug reports, as explained above.
8c82f36 @kthakore Out line for CPAN added
kthakore authored
56722d2 @kthakore Intro blurb for CPAN chapter
kthakore authored
224 =head1 Conclusion
8c82f36 @kthakore Out line for CPAN added
kthakore authored
0b1aefe @garu CPAN chapter: finding the right module
garu authored
226 CPAN is an amazing repository filled with nice modules ready for you to
227 use in your games. More than often you'll find that 90% of your
228 application is already done on CPAN, and all you have to do to get that
229 awesome idea implemented is glue them together, worrying only about your
230 application's own logic instead of boring sidework. This means faster
231 development, and more fun!
18bc16f @kthakore Initial Commit
kthakore authored
233 =for vim: spell
Something went wrong with that request. Please try again.