I've finished the first book. It's been
as good as I remembered. It's been a hard week. I'm having many
assignments at college and I think I'll have to slower the pace.
Anyway, let's get started.
Platforms
Last week I
posted the source code of platforms, the adventures of a green square
in a dungeon. I've finished the game and the old green square has
evolved: now it's a raccoon.
If you look at
the source code, you can see that the raccoon is composed of several
images. Each image represents an action. One image represents
standing, another for jumping and, finally, four for walking. I've
experienced the following challenges:
- Making the raccoon walk at the proper pace. At first, the raccoon images alternated to fast in comparison with the distance than it actually walked. This is because I made the images change every frame. I changed it to one image every four frames.
- Making the raccoon “look” at the right direction. This is easily achieved through a Pygame built-in function: “pygame.transform.flip”. Although this is very easy, I had to be very careful storing directions in variables for the raccoon to remember where was looking at after walking.
- Making the raccoon “fit” in the old square. Well, this is not the actual challenge, the thing is that my old green square was 20x20 pixels large. The raccoon looked so small in it... Well, I ended up changing the player square size to 50x50. This was tedious, because I had to change the entire level for the player to fit in the space between the first platform and the staircase... Lesson learnt the hard way.
I enjoyed the
part of searching files for my game. It's amazing the amount of open
resources available on the Internet.
Windows executables
This
part took me a lot of time. The author of the book teaches us how to
use a script to convert Python scripts into Windows executables. It
hasn't work with my Pygame applications. In fact, it doesn't work
with the author's scripts. In the past I used the book's
method and I didn't encounter any of these problems. Something has
changed either in py2exe or in Pygame. Apparently the problem is
related with the font and mixer modules.
Gladly,
someone else found this problem first and posted a solution. Check
the link: http://www.pygame.org/wiki/Pygame2exe.
I decided to use my own font file instead of the default. It works.
Honestly, I
would like to hide every file that there's in the distribution but
the exe file. This would keep things simple for the user. There must
be a way to do this.
I
got to understand a little about distributing applications in this
pdf: http://cs.iupui.edu/~aharris/pygame/Appendix_C.pdf.
However, I feel quite intimidated about the distutils Python module.
My old C and Ada compilers output the executable with a single
command. Having to write a setup script is quite strange for me.
Perhaps I'll need to take a look at it in the future.
No comments:
Post a Comment