Skip to content

Instantly share code, notes, and snippets.

@ahmnouira
Last active November 28, 2019 23:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahmnouira/368378510d0d809f65f1ee94b982f0c7 to your computer and use it in GitHub Desktop.
Save ahmnouira/368378510d0d809f65f1ee94b982f0c7 to your computer and use it in GitHub Desktop.
qwirkle-game
/*
* @author: ahmnouira
* @find me: https://github.com/ahmnouira
*/
#include <stdio.h>
typedef struct
{
char *name;
int RGB[3]; // a represenation of a color
} Color;
typedef struct
{
/* data */
char *form;
Color c;
}Tuile;
int main(int argc, char const *argv[])
{
/******************* create colors ************************/
//example simple : create c1 Color
Color c1 = {"c1", .RGB[0]=255, .RGB[1]=123, .RGB[2]=38};
// tabe of colors
Color colors[6] = {
{"red", .RGB[0]=255}, // red
{"orange", .RGB[0]=255, .RGB[1]=124}, // orange
{"yellow", .RGB[0]=255,.RGB[1]=255}, // yellow
{"green", .RGB[1]=255}, // green
{"blue", .RGB[2]=255}, // blue
{"violet", .RGB[0]=255, .RGB[2]=125} // violet
};
/******************** create liste of forms ****************/
// circle, careé, losange ...
char *forms[6] = {"cercle", "star" ,"diamond", "square", "sun", "plus"};
// 3D matrix of tuiles (row, col) * 3
Tuile tuiles[6][6][3];
for(int iteration = 0; iteration < 3; iteration ++ ) {
for(int row=0; row < 6; row ++) {
for(int col=0; col <6; col++) {
tuiles[row][col][iteration].form = forms[col];
tuiles[row][col][iteration].c = colors[row];
printf("|%s:%s| ",tuiles[row][col][iteration].c.name, tuiles[row][col][iteration].form);
}
printf("\n");
}
}
printf("\a**finish**\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment