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

Re: [pygame] board game



Gameplay wise, you might want to give the other play a turn whether or not the first one got the answer right or wrong. Otherwise Player One has a bug advantage if they know the answers to a few of the questions (Or just know a lot).
Have the question/answer come up in a popup. Trust me, it's a lot easier.
As for the distances, this is a bit clunky, but it should work:

#Assume that each square is 10 pixels wide
def square_dist(self)
#You'll need to import 'random' for this bit
dice_num = random.randint(1, 6)
move_dist = 10 * dice_num + 1
print ("You can move %s squares.") % dice_num
square = self.function_where_player_chooses_a_square_and_the_square_is_returned()
if square.rect.x > player.rect.x and < player.rect.x + move_dist:
 if square.rect.y > player.rect.y and < player.rect.y + move_dist:
   player.rect = pygame.rect.Rect((square.rect))
 elif square.rect.y < player.rect.y and > player.rect.y - move_dist:
   player.rect = pygame.rect.Rect((square.rect))

And then the same thing again, but switching all the 'y's for 'x's and vice versa. There really ought to be a function in pygame to do this, and in fact there might be, I just don't know about it.
Hope that helps.

marta wrote:
A further description about this game:
you have a board, with 3 types of tile/squares, the normal ones that
have between 2 and 6 diferent colours -dependig on the configuration you
want to have- each colour belongs to a subject (maths, science, history,
animals,..), then you have special tiles, that gives you points and then
there are the "rethrow the dice".

 It is necesary to be at least 2 players.At the begining both are in the
central square, one player throw the dice,ie- number 3 is shown, and the
player can select any square that is  3 squares from you, there's no a
only one way to pass through al the board as it is no necessary. When a
player has put its counter into the square of its election, a question,
-of the area belonging to the colour  of the square- selected from a
file full of questions, is shown -don't know right know if it is better
to show it in a popup or in the same window that the board -in one part
of the same window, I mean-.
If the square is a normal one, and the answer is OK, the player can
throw again the dice, and repeat the same. If the answer is failed, the
other player gets the turn to play. If the tile is a special one and the
answer is OK, the player gets a point -you need one point per area to
win the game- and continues playing.

That's the whole game more or less..

Another problem I found is how to know if the square the player has
chosen, can be selected, I mean it that tile is X tiles from the one
that the player is in. I thought about a list of pointers...




El mié, 19-09-2007 a las 09:50 +0200, Lionel Barret De Nazaris escribió:
marta sanz wrote:
Hi!

I'm a newbie in game programming. I am programming -well, trying to do it.. :D- a board game like Trivial, a board game of questions and answers. In this game, you have a board with many squares, and each one have one question to be answered by the player, there are 6 types of squares, and depending on the type, the question is about sciences, maths, history,etc.

The problem I find is to know how to draw that board, don't know if it's better to draw the entire board with a paint program (inkscape, gimp..) and then load it with pygame, or draw each individual squares and the load them one by one making the board, or what. The board has an hexagonal shape.

Any idea?

Regards and Thanks for all.

Marta.

You need to go a little further describing your game.

For example, if the tile are static (i.e not animated), you can draw the
whole board and calculate which tile is clicked on from the mouse
position. This is much simpler and I advise you to do that..
The alternatives is to design each tile and then join them with you
program. This has the advantage to allow animated tiles but it is much
harder (more concepts and more code involved).

Beside, except if it is a core mecanism of the game, forget the
hexagonal shape, at least for now : it will add complexity to your code
with little benefits but visuals.
Once you have done a first version of the complete game, you can redo
this particular part of the code. This is a good way to progress.

But even if you take the first path, more generally you need to specify
you game. What happen when one clik on one tile ? A popup appears ? Is
it another window or is it within the pygame window, etc...