[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] learning pygame: what to focus for a board game?



massimo s. wrote:
Hi,

I have this fixed idea of writing a clone of Carcassonne (
http://en.wikipedia.org/wiki/Carcassonne_(board_game) ) with Python,
playable under Linux. Basically, it's made of square tiles that must
match together forming a map, and one gets points if manages to complete
cities, roads etc... Simple but fun, quite strategic.

I'm having a look at pygame for its development and it looks promising.
However most pygame tutorials etc. are aimed at arcade-like games, as
far as I can see. That's cool, but that's pretty far from my aims.
I think part of the reason a lot of arcade games are the focus of pygame tutorials is this unconscious desire that pygame developers have to prove that it's fast enough for even the most demanding games, like Raiden, that has hundreds of bullets and enemies flying around, etc. Honestly, would you be impressed if you found a game library and all the tutorials were how to make
turn-based strategy and board games?
Not to belittle these types of games. I just think that, when evaluating libraries, it's more impressive to see the speed at which Pygame still accomplishes these faster types of games. Also, I think it's easier to understand the intent of the game, and thus the logic and implementation of it, and since it's a tutorial, it's more clear how pygame is being used exactly to implement specific goals,
rather than getting ambiguous and lost in the complexity of rule sets.
For example, a chess game would have lots of chess logic contained in the movement code that's not really relevant to people who just want to learn how to move sprites around and blit them, and update the screen, that a simple Galaga-type game would teach them much more readily.
So I'd like to know:
- Should I learn sprites or can I just learn surfaces? I'd like to have
(or at least plan to support in the future) some (very simple)
animation, like the tile rotation when asked to rotate it, or a fast
movement of the tile into the board. Can I make it just with rectangles
or do I need sprites?
I'll preface this with "huh?"
what do you mean "the tile rotation when asked to rotate it?"
there are different kinds of rotation.
smooth rotation, rotation by fixed degrees, and rotation by increments of 90 degrees,
all behave differently.
rotation by 90 degrees is the simplest, because the size of the image doesn't change.
also, what does "fast movement of the tile into the board" mean?

Anyway, here's what I think about Rects vs. Sprite:
You can do anything you want using Rects.
The description of the Sprite class on pygame.org should give you an idea of why you wouldn't just use Rect:
"""
This module contains several simple classes to be used within games. There is the main Sprite class and several Group classes that contain Sprites. The use of these classes is entirely optional when using Pygame. The classes are fairly lightweight and only provide a starting place for the code that is common to most games.

The Sprite class is intended to be used as a base class for the different types of objects in the game. There is also a base Group class that simply stores sprites. A game could create new types of Group classes that operate on specially customized Sprite instances they contain.

The basic Sprite class can draw the Sprites it contains to a Surface. The Group.draw - blit the Sprite images method requires that each Sprite have a Surface.image attribute and a Surface.rect. The Group.clear - draw a background over the Sprites method requires these same attributes, and can be used to erase all the Sprites with background. There are also more advanced Groups: pygame.sprite.RenderUpdates - Group class that tracks dirty updates and pygame.sprite.OrderedUpdates - RenderUpdates class that draws Sprites in order of addition.

Lastly, this module contains several collision functions. These help find sprites inside multiple groups that have intersecting bounding rectangles. To find the collisions, the Sprites are required to have a Surface.rect attribute assigned.
"""

in other words, in most cases, using Sprite will help you simplify things.
For example, I haven't read the description for your board game, but if you were making, say, chess, you could have a sprite group containing all the pieces, then whenever you needed to move a piece, you could use the collision methods to check if it were moving onto another piece, and if so, delete that other piece... and then use the draw method to blit all the pieces to the screen again. whereas with rects, depending on how you're storing them, it may be more complicated, or may not.

To be completely honest, I haven't used the sprite class very much,
but it appears like it expects you to subclass Sprite and override the update method, wherein you could add code that keeps track of what frame of an animation you're on, for example.
- Where are the "widgets" needed for a configuration panel and/or a
menu? Things like tick box, menus etc.?
pygame is meant to be low-level and as efficient as possible, so that the game developer is not restricted in any way. as such, you're expected to either implement such things yourself (which really isn't as hard as it sounds) or use OcempGUI, Phil's PGU, etc, etc. In other words, go to the Pygame GUI page and find out which
third-party library does what you need.
- Any other basic advice in building a board game with pygame?
I have specific advice for this game:
if you don't already have artwork for the tiles,
DON'T DRAW IT NOW!
trust me, I've done this before.
I tried to write Noteability, a board game where one player plays a tune and the other tries to guess it, and I typed in all the data for the cards beforehand (200 cards with 3 songs each!) and after a few days of data entry, I was so tired of the game I just gave up and didn't program anything
except a simple tune generator.
I would suggest you make placeholder art, and when the game gets further into completion,
add pieces gradually.
This will keep you from stressing yourself out, and also, if the game is already playable, you'll have much more gratification when adding the pieces than if you did them all upfront.

point #2: You may not want to call your game carcassonne. Since Microsoft is making a clone of it for the x360 arcade, you might get some hostility from them if you release a free version of a game they're charging people for!

This game looks like a lot of fun! let me know how you progress.

Some general advice, if you're new to game development:
get a gmail account, so that you can register your project with google code.
This will provide you with an online SVN server.
Then get TortoiseSVN if you're on Windows (if you're on Linux or Mac I assume you already have a subversion client.)
then, register for a www.blogger.com blog (affiliated with Google)
and you can keep a log of your progress on it.
Get a photobucket or imageshack account so you can upload game screenshots
easily for inclusion on your blog.

HTH,
-Luke