Help with ideas, best ways etc... 
Author Message
 Help with ideas, best ways etc...

Hi all;

I wish to write a Domino game, but can not think of a way to control
the handling of the pieces on the board.

My problem is when the user selects a piece how do I control how the
piece is placed on the board. ie if at start there is a double 6 on
the board at x,y and the user selects a piece, say 6-3. How should I
figure out which side the piece should go and in which direction. ie
possible ways are;

1>           5-6:6-6

2>           5
                |
                6
                6-6

3>           6-6
                6
                |
                5

4>           6-6
                   6
                    |
                   5

5>              5
                    |
                              6
                6-6

6>           6-6:6-5

And how should I structure the data.

Currently I have figured out the following;

avilable_pieces[6][6]=piece#
 player[3][9]=piece#

initialise available_pieces to 1 to 49
Shuffle available_pieces

load player with piece#
replace available_pieces=piece# to 0

The remaining available_pieces not 0 belong to the bank.

Can anyone help with advise, please
Regards :           David. E. Goble

                  http://www.*-*-*.com/ ~goble
    Po Box 648 Kingscote Kangaroo Island South Australia 5223



Thu, 18 Jan 2001 03:00:00 GMT  
 Help with ideas, best ways etc...

Quote:

> My problem is when the user selects a piece how do I control how the

> piece is placed on the board. ie if at start there is a double 6 on
> the board at x,y and the user selects a piece, say 6-3. How should I

> figure out which side the piece should go and in which direction. ie

> possible ways are;

[snip]Since it's a kind of a visual game, why not make the player able
to turn the piece the way (s)he wants? You can, by default, just stick
the piece somehow, clockwise might not be a bad idea (left->right,
up->down, right->left, down->up, depending if there's room or not).
You might use a struct to store the info:

    typedef enum {
        up, down, right, left
    } DIR;
    struct piece {
        int    value1, value2;
        DIR    direction;
    };

Perhaps you want to make this a double linked list. That way you can
easily redraw the pieces if the system needs it, for example, or you
can backtrack them if you later decide to add an 'oops...' feature.

    AriL
--
Seen on comp.lang.c:
Q: What does 'context' mean?
A: Depends on the context.



Fri, 19 Jan 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Good ways to obfuscate/mangle strings?

2. are there better ways to read config file?

3. Any good ways to trace memory leaks?

4. Is this a good Idea??

5. Sorting multi column ListView -code-Any better ideas?

6. link libraries to libraries a good idea?

7. Vivianne has a good idea

8. Is this a good idea?

9. Is this a good idea? (cont)

10. Bad trick or good idea?

11. Good program ideas?

 

 
Powered by phpBB® Forum Software