How to Make a Prototype of a Cards Game From a Csv File Using Free Softwares

by Leon_Reboul in Living > Toys & Games

116 Views, 0 Favorites, 0 Comments

How to Make a Prototype of a Cards Game From a Csv File Using Free Softwares

mainCardsADEME.jpg
mainPicProtoV1.jpg
jeuExtremeDefi.png

In this Instructables I will share the steps I used to create a prototype of a cards game from scratch!

Steps of the Instructable:

  1. Context.
  2. Gather relevant data and organize it in a csv file.
  3. Gather relevant pictures and edit them using Inkscape.
  4. Automatically generate a pdf from the csv files and the pictures using Overleaf.
  5. Print the pdf.
  6. Cut and put in sleeves.

Supplies

Materials:

  1. A4 paper
  2. A standard cheap deck of card
  3. A bunch of sleeves

Machines:

  1. A 2D printer

Software:

  1. Overleaf: an online editor (principally use to create scientific documents: articles, thesis, reports,...) where you type code to generate a pdf file.
  2. Inkscape: free 2D CAD software
  3. Libre Office calc (but you can use Google Sheets or Microsoft excel as long as you export the file in a csv format)

Context

jeuExtremeDefi.png

I am making a card game in collaboration with RFFLabs (french Fab Lab Network) and LUZ'IN (Fab Lab in La Tour du Pin) for the Extrem Mobility Challenge an extreme innovation course in competition whose objective is to create new travel solutions to replace the car in everyday travel in peri-urban and rural areas. We should call it "XD" in the remaining of this post.

I was looking for a way to automatically generate a deck of cards from a csv (comma-separated values) file. I found several projects doing so:

  1. Dextrous (great but you need to pay)
  2. Nandeck (free but for windows)
  3. cardlatex (free but for windows)

I am using Linux and I wanted a free tool that I can modify to fit my need. I have already used Overleaf and I know a bit of TikZ (more on that later in step 4). So I decided to start from the code shared by user "Arvid" in this tread and remake it to fit my needs.

Gathering the Relevant Data and Organize It in a Csv File

WikiADEME_Explorer.png
FicheVhelio.png
TechnicalDataVhelio.png

I used the wiki of the XD to gather data on the vehicles and the team that designed and make them. I them put all the data in a csv file using Libre Office calc.

I use the first raw of the csv file to put the titles of the column, this will be important for the Overleaf step.

Gather Relevant Pictures and Edit Them Using Inkscape

imageFromAdemeWiki.png
inkscapeSetClip.png
InkscapeResizeDocument.png
InkscapeCenterRectangle.png
InkscapeResizeAndCenterImage.png
InkscapeExportPng.png
evig.png
hvr.png
u1.png
karbikesPro.png
kairos.png
tiny.png
carreto2x2.png
soraya.png
laPlateau.png
laBagnole.png
inga.png
movR3.png
bct.png
facteur10.png
leFlorhyan.png
carreto4x4.png
cyclospace.png
roza.png
citroenAmi.png
greenAndBike.png
charette.png
carver.png
aeroStar.png
noCar.png
fourCycles.png
veMoo.png
ceb.png
plateformeCarbikes.png
bob.png
cycleKart.png
segmobyl.png
cyclesMidi.png
slappy.png
euclH2.png
libellule.png
cobraneX.png
ikarhus.png
acticycle.png
alounga.png
midipile.png
gfg101.png
jdmSLE.png
soletta.png
urbaner.png
sliikone.png
veemoSE.png
edi.png
tinkercad.png
pumba.png
ouiCycle.png
eva.png
gfg201.png
toot.png
eGoCAR.png
cargoLab.png
SurbX.png
laBarquette.png
eRoeFlash.png
db1.png
woodyBus.png
eliZero.png
capitole.png
tZer.png
noPicture.png
extremeDefiLogo.png
silex.png
kiwiMobility.png
caminade.png
cylure.png
sulCity.png
weez.png
ptiteZalye.png
pelicanTrain.png
moduleo.png
tripalette2.png
autocycletteRemorque.png
grossomodow.png
quadryfox.png
triviak.png
snakeBike.png
scouter.png
cyclauto.png
triporteurFlorianBikes.png
bugE.png
sMouv.png
biro.png
bimboum.png
helixx.png
camel.png
cargoxhytan.png
cGo.png
colibri.png
golo.png
scaramobile.png
quike.png
oxpecker.png
cargomobile.png
intelectra.png
qbxSorean.png
circle.png
camiGO.png
veloce.png
grozalye.png
azurite.png
mob4.png
upt.png
karbikes.png
IoTwoOne.png
sulCountry.png
cargo3E.png
TricyclePallette.png
supercycletteVhelio.png
autocyclettePickUp.png
BuggE.png
unikle.png
bikloowRecycle.png
tcr.png
eSpider.png
twoSeater.png
jetbike.png
troisRoy.png
solarBoost.png
scorpio.png
kBine.png
ketchCleenElectrique.png
half.png
vhéliOriginal.png
biporteurMidi.png
veloBus.png
lokka.png
MoskitOS.png
kRyole.png
proxity.png
eGokART.png
avatar.png
bakerPrax.png
autocycletteTaxi.png
velbou.png
jva2.png
solarCommuter.png
ownDrive.jpeg.png
scoobicMouse.png
vheliotech.png

I used the wiki to download the pictures of the vehicles. If you know what you are doing and the website is well coded you can use a web scrapper program to automatically download all images of a website.

I remove the background of the image using the removebg website.

For the few images where the background wasn't perfectly removed I used Inkscape and follow the steps:

  1. draw a line around the part I want to keep using the Pen Tool
  2. select both the image and the line (shift + left mouse button)
  3. go to object menu
  4. Clip
  5. Set clip

For all the images I formatted them so that they will fit nicely in the cards and look the same, here are the steps to do it in Inkscape:

  1. Resize the document size to 60mm by 60mm (ctrl + shift + D),
  2. draw a 40 by 25mm rectangle and center (ctrl + shift + A and relative to the page),
  3. resize and place the image centered in the rectangle (as big as possible inside the rectangle)
  4. delete the rectangle
  5. export the image in a png file (ctrl + shift + E, export the whole page)

Note: if you know what you are doing you can use the "mogrify" command to process several images at the same time. I do recommend that you first make a copy of the folder with all the image first, as a mistake in the command line could erase all the pictures in the file.

Automatically Generate a Pdf From the Csv Files and the Pictures Using Overleaf

overleafFrontAndBackCards.png
ademeVehiculesOccupationExampleCards.png
OverleafExampleCaffeineLib.png
OverleafLayoutExample.png

Disclaimer:

Cons of Overleaf:

  1. Overleaf is originally used to make scientific papers/write phd thesis. It is not beginner nor user friendly, you type code on the left part to generate a pdf on the right. If something goes wrong you have to debug by yourself.
  2. The learning curve is steep for people not use to programming and reading technical documentation (for example the documentation of the TikZ and PGF package is 1321 pages).

Pros of Overleaf:

  1. LaTeX is completely free to use.
  2. You can reuse a lot of templates (already made code), so if you know where to look, it is simply putting your text at the right place.
  3. It work really well (as one could guess) for science diagram: you can make cool chemical formulas if you want to as shown in the illustration of cafeine (from overleaf website).
  4. You can use a lot of libraries to make your work easier
  5. You have all the control regarding everything on the pdf page size, position of the card, style of the cards and so on...
  6. There is a lot of documentation available.

My process:

I used the "datatool" package to modify a code from the thread: Creating playing cards using Tikz from StackExchange.

The datatool documentation is available on this page, under the section documentation: User guide .

The tex files:

  1. cards.tex this is the main file that will call the others files,
  2. colors.tex this the file to define the colors,
  3. libs.tex this is the file to import all the libraries that we need in the project,
  4. tikzcards.tex this is the file to define the commands that make the cards.

The csv files:

  1. allDataFrench.csv this is the main file containing all the data in french on the vehicles
  2. testDataFrench.csv this is a smaller file containing a subset of the data of allData.csv use for testing (smaller so it run faster)

The code is commented to give you an understanding of the what does what in the file.

Note:

  1. You must have the cards.tex selected to compile the project otherwise you will get a compilation error and no pdf
  2. Before making modification I sugest that you make a copy of the source code that work
  3. In the overleaf menu button (top left with overleaf logo) be sure to have "LuaLaTex" selected in the Compiler setting (otherwise you won't be able to display emoji from the empoji package).
  4. Check overleaf tutorials to get to know the editors
  5. Coming soon: I will try to submit the files to the overleaf gallery so you can download all the files and pictures in one go!

Codes:

cards.tex:

% MAIN FILE

% ---------------------------------------


% Context:

% Please note that this project is a tweaked version from source files shared by Arvid user on the StackExchange thread "Creating playing Cards using Tikz. The source code should still be available here:

% https://tex.stackexchange.com/questions/47924/creating-playing-cards-using-tikz


% My process:

% I translated and added comments in english to the file.

% I used the DTLforeach command to read and print data from a csv file to the cards.

% This allows to make changes in the csv files (using google sheets for example) and to apply


% Notes:

% testData.csv is a smaller data set

% allData.csv is the bigger data set containing information


% This line specify the documents class.

\documentclass[a4paper]{article}


% The lines bellows inputs the others files in this cards file.

\input{libs.tex}

\input{colors.tex}

\input{tikzcards}


% This line load the csv file, the name must match the csv you use and have uplaoded.

% You can use several csv files for different languages.

% I recommand that you use a smaller set of the data to make the test, it will compile faster.

\DTLloaddb{cardlist}{allDataFrench.csv}


% This commande allows to not have

\pagestyle{empty}


% Starting the document

\begin{document}

% Starting a table on multiple pages with two centered columns and a central line. This line is used after cutting when folding the card to put it in a sleeve.

\noindent\begin{longtable}[c]{c | c}

% For command to read trough each line of the csv file.

\DTLforeach{cardlist}{

% Map each column header in the .csv file (case sensitive) and it has to match the first row of csv.

\Name=Name,%

\CardType=CardType,

\Maker=Maker,

\Images=Images,

\Level =Level,

\Type=Type,

\Category=Category,

\Peoples=Peoples,

\Mass=Mass,

\Autonomy=Autonomy,

\Power=Power,

\Speed=Speed,

\Copies=Copies

}{

% Fronts of the cards, put in a TikZ picture environment, flipped 90 degrees

\begin{tikzpicture}[node distance = 2cm,rotate=90,transform shape]

% Put the image on the card, note the paths and mames must match the one in your Picture folder

\cardbackground{Pictures/ADEME_XD/\Images}

% Give the card the name from the csv Name column

\cardtitle{\Name}

% Apply color to the card depending on the CardType column in the csv file

\cardcolortype{\CardType}

% Add content to the cards using emojis as icons

\cardcontent{\emoji{hammer-and-wrench}: \Maker}{\emoji{gear}: \Level \\ \emoji{clipboard}: \Type \\ \emoji{balance-scale}: \Category \\ \emoji{busts-in-silhouette}: \Peoples \\ \emoji{elephant}: \Mass (kg) \\ \emoji{battery}: \Autonomy (km) \\ \emoji{high-voltage}: \Power W \\ \emoji{stopwatch}: \Speed (km/h)}

% Add card price to the card

\cardprice{1}

% Draw card border

\cardborder

\end{tikzpicture}

& % this is the column separator for the longtable

% Backs of the card put in a TikZ picture environment, flipped -90 degrees

\begin{tikzpicture}[node distance = 2cm,rotate=-90,transform shape]

% Commands for the background of the cards go here

\cardbackground{Pictures/ADEME_XD/extremeDefiLogo.png}

\end{tikzpicture}

\\ % end of the line in the longtable

}% end of the DTLforeach

\end{longtable} % end of the longtable

\end{document}


colors.tex:


% COLOURS OF THE ELEMENTS/COMPONENTS OF THE CARDS

% -----------------------------------------


% Background color for the title box

\definecolor{titlebg}{RGB}{30,30,30}


% Colors of the "strips" to identify the different card types

\definecolor{viColor}{RGB}{0,100,200} % Red Green Blue encoding

\definecolor{abilitybg}{RGB}{80,180,0}

\definecolor{itembg}{RGB}{200,50,50}

\definecolor{factoryColor}{RGB}{180,50,150}


% Color of the "strip" indicating the price of the cards

\definecolor{pricebg}{RGB}{230,180,0}


% Background color for the text area

\definecolor{contentbg}{RGB}{255,255,255}


libs.tex:


% REQUIRED LIBS

% ------------------


% Adjust document margins

\usepackage[margin=6mm,top=5mm]{geometry}


% Font of the texts used on the cards

\usepackage{anttor}


% UTF-8 encoding of the TeX files

\usepackage[utf8]{inputenc}


% Multilingual support

\usepackage[german]{babel}


% Micro-typographic adjustments

\usepackage{microtype}


% Embedding graphics

\usepackage{graphicx}


% Defining and using colors

\usepackage{color}


% TikZ for "painting" graphics, in this case for the cards

\usepackage{tikz}

\usetikzlibrary{patterns}

\usetikzlibrary{shadows}


% Packages to loads symbols to use as icons for the cards

\usepackage{pifont}

\usepackage{fourier-orns}

\usepackage{marvosym}

\usepackage{emoji}


% Extended conditional commands

\usepackage{xifthen}


% Tools to load and manipulate data, in our case the csv file

\usepackage{datatool}


% Used to realise algebraic operations

\usepackage{calculator}


% Used to have table that can span several pages

\usepackage{longtable}


% Used to include svgs for our icons in the cards

\usepackage{svg}


tikzcards.tex:

% COMMANDS FOR ASSEMBLING THE CARDS

% ---------------------------------------


% TikZ/PGF Settings for the cards

\pgfmathsetmacro{\cardwidth}{6.35}

\pgfmathsetmacro{\cardheight}{8.8}

\pgfmathsetmacro{\imagewidth}{\cardwidth}

\pgfmathsetmacro{\imageheight}{0.75*\cardheight}

\pgfmathsetmacro{\stripwidth}{0.7}

\pgfmathsetmacro{\strippadding}{0.2}

\pgfmathsetmacro{\textpadding}{0.1}

\pgfmathsetmacro{\titley}{\cardheight-\strippadding-1.5*\textpadding-0.5*\stripwidth}



% Shapes of the individual map elements/components

% This command defines the shape of the card

\def\shapeCard{(0,0) rectangle (\cardwidth,\cardheight)}


% This command defines the shape of the long strip on the left of the card with the card type text on it

\def\shapeLeftStripLong{(\strippadding,-0.2) rectangle (\strippadding+\stripwidth,\cardheight-\strippadding-\strippadding-1)}


% This command defines the shape of the small strip on the top left of the card with the card type logo on it

\def\shapeLeftStripShort{(\strippadding,\cardheight-\strippadding-1) rectangle (\strippadding+\stripwidth,\cardheight+0.2)}


% This command defines the shape of strip for the cost of the card

\def\shapeRightStripShort{(\cardwidth-\stripwidth-\strippadding,\cardheight-\strippadding-1) rectangle (\cardwidth-\strippadding,\cardheight+0.2)}


% This command defines the shape of the strip for the title of the card

\def\shapeTitleArea{(2*\strippadding+\stripwidth,\cardheight-\strippadding) rectangle (\cardwidth-2*\strippadding-\stripwidth,\cardheight-2*\stripwidth)}


% This command defines the shape of the strip for the content of the card

\def\shapeContentArea{(2*\strippadding+\stripwidth,0.5*\cardheight) rectangle (\cardwidth+0.2,-0.2)}



% Define styling for the elements

\tikzset{

% Round corners for the cards

cardcorners/.style={

rounded corners=0.2cm

},

% round corners for the "flags"

elementcorners/.style={

rounded corners=0.1cm

},

% Drop shadow for the "flags"

stripshadow/.style={

drop shadow={

opacity=.5,

shadow,

color=black

}

},

% Style for the "flags"

strip/.style={

elementcorners,

stripshadow

},

% Image for the card motif

cardimage/.style={

path picture={

\node[below=-1.5mm] at (0.5*\cardwidth,\cardheight) {

\includegraphics[width=\imagewidth cm,heigth=\imageheight cm]{#1}

};

}

},

}


% TikZ-Raster

\newcommand{\carddebug}{

\draw [step=1,help lines] (0,0) grid (\cardwidth,\cardheight);

}


% Frame of the map

\newcommand{\cardborder}{

\draw[lightgray,cardcorners] \shapeCard;

}


% Background of the map

\newcommand{\cardbackground}[1]{

\draw[cardcorners, cardimage=#1] \shapeCard;

}


% Category of the card

\newcommand{\cardtype}[3]{

% First we fill the intersecting area

% The \clip command does not allow options, therefore

% we have to use a scope to set the even odd rule.

\begin{scope}[even odd rule]

% Define a clipping path. All paths outside shapeCard will

% be cut because the even odd rule is set.

\clip[cardcorners] \shapeCard;

% Fill shapeLeftStripLong and shapeLeftStripShort.

% Since the even odd rule is set, only the card will be filled.

\fill[strip,#1] \shapeLeftStripLong node[rotate=90,above left=0.9mm,font=\normalsize] {

\color{white}\uppercase{#2}

};

\fill[strip,#1] \shapeLeftStripShort;

\end{scope}


\node at (\strippadding+\stripwidth-0.28,\cardheight-\strippadding-\strippadding-0.37) {\color{white}#3};

}


\newcommand{\ifequals}[3]{\ifthenelse{\equal{#1}{#2}}{#3}{}}

\newcommand{\case}[2]{#1 #2} % Dummy, so \renewcommand has something to overwrite...

\newenvironment{switch}[1]{\renewcommand{\case}{\ifequals{#1}}}{}


\newcommand{\cardcolortype}[1]{

\begin{switch}{#1}

\case{1}{\cardtype{viColor}{Véhicule Intermédiare}{\hspace{-1mm}\Large\Bicycle}}

\case{2}{\cardtype{abilitybg}{Véhicule ancien}{\hspace{-1mm}\Large\floweroneright}}

\case{3}{\cardtype{itembg}{Véhicule polluant}{\hspace{-1mm}\LARGE\emoji{oil-drum}}}

\case{4}{\cardtype{factoryColor}{Usine Distribuée }{\hspace{-1.4mm}\huge\ding{78}}}

\end{switch}

}


\newcommand{\cardtypeVehicule}{\cardtype{itembg}{Véhicule Intermédiare}{\hspace{-1mm}\Bicycle}}

\newcommand{\cardtypeAbility}{\cardtype{abilitybg}{Véhicule ancien}{\hspace{-1mm}\Large\floweroneright}}

\newcommand{\cardtypeItem}{\cardtype{itembg}{Gegenstand}{\hspace{-1mm}\LARGE\bomb}}

\newcommand{\cardtypeTest}{\cardtype{testbg}{Testkarte}{\hspace{-1.4mm}\huge\ding{78}}}


% Title of the card

\newcommand{\cardtitle}[1]{

%\draw[pattern=soft crosshatch,rounded corners=0.1cm] \shapeTitleArea;

\fill[elementcorners,titlebg,opacity=.85] \shapeTitleArea;

\node[text width=3.75cm] at (0.5*\cardwidth,\titley) {

\begin{center}

\color{white}\uppercase{\normalsize #1}

\end{center}

};

}


% Contents of the card

\newcommand{\cardcontent}[2]{

\begin{scope}[even odd rule]

\clip[cardcorners] \shapeCard;

\fill[elementcorners,contentbg] \shapeContentArea;

\end{scope}

\node[below right, text width=(\cardwidth-2*\strippadding-\stripwidth-2*\textpadding-0.3)*1cm] at (2*\strippadding+\stripwidth+\textpadding,0.5*\cardheight-\textpadding) {

\textit{\normalsize #1}

};

\node[below right, text width=(\cardwidth-2*\strippadding-\stripwidth-2*\textpadding-0.3)*1cm] at (2*\strippadding+\stripwidth+\textpadding,3) {

% \vrule width \textwidth height 2pt \\[-2pt]

% \vspace{-0.2cm}

{\scriptsize #2}

};

}


% Price of the cars

\newcommand{\cardprice}[1]{

\begin{scope}[even odd rule]

\clip[cardcorners] \shapeCard;

\fill[strip,pricebg] \shapeRightStripShort;

\end{scope}

\node at (\cardwidth-0.5*\stripwidth-\strippadding,\titley-0.1) {\color{black}#1};

}


Print the Pdf

Easy step, print your pdf on your 2D printer!

But I strongly recommend that you first print only the first page, cut it and check that it fits your sleeve (see step bellow) before printing the full pdf!

Cut and Put in Sleeves

mainPicProtoV1.jpg
cutting_folding_Cards.jpg

I follow this process:

  1. cut the card front and back,
  2. fold along the line,
  3. put a card from the cheap standard deck of card (it has to be the same dimension) between the front and the back,
  4. put them all in the sleeve!

Notes:

  1. this allows to easily remove the card from the sleeve to make adjustment,
  2. you can reuse the standard deck of card for another prototype,
  3. it look a bit nice already,
  4. you can playtest the game way easily them with just paper cards,
  5. if you want to create nicer cards check out this video by the Dining Table Print & Play.