Thread: making bejeweled

  1. #1
    Registered User
    Join Date
    Apr 2004
    Posts
    25

    making bejeweled

    this is a project i have to do for uni

    but i'm not sure if i have to use structs?

    i have to create a board with ACSII characters and use 4 jewels as character symbols. i don't see where i have to use structs? but my friend has in his report

    i've only learnt stuff like
    file i/o
    strings
    pointers
    scanf and printf
    while, if, for.
    arrays
    functions
    recursion

    so just in case i future questions about the project. in case i'm having trouble with the code.

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218
    I suppose this is C and not C++ (since you are using printf and scanf). Well if all you are going to do is print a board with a specified size and using jewels as markers I think you can about with an array (2D for simplicity).

  3. #3
    Registered User
    Join Date
    Apr 2004
    Posts
    25
    could i add borders in an an array for the board? it'll be a 6x6 board

  4. #4
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218
    Either add borders in the array or create a special routine to draw the borders.

  5. #5
    Registered User
    Join Date
    Apr 2004
    Posts
    25
    hhmm i'll try..

  6. #6
    Registered User
    Join Date
    Mar 2003
    Posts
    580
    If you need to use structs as part of the requirement for the assignment then adding that to your program should be easy. Just make a struct to hold all of the data for a character, then create an instance for each of your characters.

    EDIT:
    Do you know what it means to create an instance of something? If not I'll gladly explain better.
    See you in 13

  7. #7
    Arggggh DeepFyre's Avatar
    Join Date
    Sep 2004
    Posts
    227
    i dont...
    Keyboard Not Found! Press any key to continue. . .

  8. #8
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    This might get you started. I will use the non-object oriented approach though it will be hard for me.

    Code:
    #define SQUARE  0x0001
    #define CIRCLE   0x0002
    #define TRIANGLE 0x0003
    #define DIAMOND 0x0004
    
    void DrawBoard(void)
    {
      char *txt=NULL;
      for (int i=-1;i<7;i++)
      {
        for (int j=-1;j<7;j++)
        {
           if (i==-1 || i==7 || j==-1 || j==7)
           {
              int ch=177;
              printf("%c",ch);
            }
            else
            {
              switch GameBoard[i,j]
              {
                 case SQUARE:
                   //txt="<jewel_character>"
                   break;
                 case CIRCLE:
                   break;
                 case TRIANGLE:
                   break;
                 case DIAMOND:
                   break;
              }
              printf("%s",txt);
            }
            printf("\n");
          }
       }
    }
    There is a much better way to do things but I tried to keep it simple. Using structs would be a much better approach and better yet using C++ classes would be even better. But I leave that to you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. making sprites
    By DavidP in forum Game Programming
    Replies: 9
    Last Post: 02-20-2010, 07:00 AM
  2. Making great graphics
    By MadCow257 in forum Game Programming
    Replies: 1
    Last Post: 02-20-2006, 11:59 PM
  3. Making control...
    By Finchie_88 in forum C++ Programming
    Replies: 2
    Last Post: 09-07-2004, 01:42 PM
  4. Replies: 2
    Last Post: 01-13-2003, 01:28 PM
  5. About Unix Programming - Making a career desision
    By null in forum C Programming
    Replies: 0
    Last Post: 10-14-2001, 07:37 AM