Skip to content

HTTPS clone URL

Subversion checkout URL

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