Drawing Super Mario Bros…in LaTeX

There are several questions about TeX.SE. that concern designs for recurrences such as fireworks, lunar calendar, the pi-greek, and into my mind I'm remembering a protagonist of an old video game: Super Mario Bros.

But is it possible to make detailed drawings of the protagonists of video games with LaTeX?

I'm just curious to see only how the users build Super Mario Bros. Thank you everyone.

• Why would you do that in TeX? – cfr Oct 2 at 23:01
• @cfr cwac! Miss you! – Paulo Cereda Oct 3 at 13:02
• @PauloCereda Cwac! – cfr Oct 3 at 16:32
• As you Know my answer is here. – vi pa Oct 4 at 8:53
• I need to think of questions like these to get my reputation boosted.... – jvriesem Oct 5 at 17:05

What if Mario and Luigi are going to a party? Somebody said that they love ducks!!

From The TikZducks package

MWE

\documentclass[border=2mm]{standalone}
\usepackage{xcolor}
\usepackage{tikzducks}

\newcommand{\superstripes}{\stripes[color=blue!80!black,width=3,height=1.0,rotate=5] \stripes[color=blue!80!black,width=0.1,rotate=0,distance=0.7,initialx=-1.1,height=2]}

\begin{document}

\begin{tikzpicture}
\duck[tshirt=red!80!black,peakedcap=red!80!black,stripes={\superstripes}]
\fill[white] (0.8,2) circle (0.13);
\node[red!80!black,rotate=-25] at (0.8,2) {\scalebox
{0.6}{\textsf{M}}};
\end{tikzpicture}
\begin{tikzpicture}
\duck[tshirt=green!70!black,peakedcap=green!70!black,
stripes={\superstripes}]
\fill[white] (0.8,2) circle (0.13);
\node[green!70!black,rotate=-25] at (0.8,2) {\scalebox
{0.6}{\textsf{L}}};
\end{tikzpicture}
\end{document}


• Seeing the question, I felt confident that tikzducks would be rolled out. You did not disappoint. – Steven B. Segletes Oct 3 at 1:24
• Thank you for your invaluable cooperation and your collaboration. – Sebastiano Oct 6 at 19:16
• @Sebastiano, you are welcome. – Sigur Oct 7 at 12:14

As everyone knows, the game was released in 1985, and at that time LaTeX was just making it out into the world and there was no such thing as pdfTeX, let alone TikZ and other fancy systems, so what Nintendo had to make the pictures was Knuth's TeX only.

They needed an efficient way to make the pictures, so they obviously didn't have the time to write all those coordinates, so they resorted to a syntax which was easy to draw each frame of the game, like this:

\beginmario
..=====....
.=========.
.---@@-@...
-@-@@@-@@@.
-@--@@@-@@@
--@@@@----.
..@@@@@@@..
.==+===....
===+==+===.
===++++====
@=+@++@+=@@
@@++++++@@@
@++++++++@@
.+++..+++..
---....---.
---....----
\endmario


to produce:

So they used something like this:

\input color.tex
\newtoks\marioactives
\def\newmariocolor#1#2#3{%
\definecolor{M#2}{rgb}{#3}%
\expandafter\def\csname MarioSquare#1\endcsname
{\begingroup\color{M#2}\MarioBox}%
\marioactives\expandafter{\the\marioactives\mkactive{#1}}}
\newdimen\unitlength
\newdimen\rulesize
\newcount\therow
\newcount\thecol
\def\MarioBox{\leavevmode\raise\therow\unitlength
\hbox to 0pt{\kern\thecol\unitlength\DrawBox\hss}%
\def\DrawBox{\leavevmode\hbox{\vrule width\rulesize height\rulesize}}
\def\mkactive#1{%
\catcode#1=13\relax
\begingroup\lccode~=#1\lowercase{\endgroup
\expandafter\let\expandafter~}\csname MarioSquare#1\endcsname}
{\catcode\^^M=13
\gdef\beginmario{%
\begingroup
\catcode\ =9
\catcode\^^M=13
\rulesize\unitlength
\the\marioactives}%
\gdef\endmario{\endgroup}%
}

\newmariocolor{=}{red}{1,0,0}
\newmariocolor{+}{blue}{0,0.15,1}
\newmariocolor{@}{yellow}{1,0.65,0}
\newmariocolor{-}{brown}{0.5,0.1,0}
\newmariocolor{.}{white}{1,1,1}
\unitlength=5pt

\beginmario
..=====....
.=========.
.---@@-@...
-@-@@@-@@@.
-@--@@@-@@@
--@@@@----.
..@@@@@@@..
.==+===....
===+==+===.
===++++====
@=+@++@+=@@
@@++++++@@@
@++++++++@@
.+++..+++..
---....---.
---....----
\endmario

\bye

• Unbelievable!!!! Did you already known this solution, right? Or did you create this just now? – Sigur Oct 2 at 23:33
• @Sigur I never worked for Nintendo, if that's what you're asking ;-) (yes, I wrote it now :-) – Phelype Oleinik Oct 2 at 23:35
• Ow, I was asking the second. Amazing how fast you wrote the code. Congs. – Sigur Oct 2 at 23:37
• @Sigur Actually the \MarioBox above is a modified version of LaTeX's \put, and \DrawBox is almost the same as \rule. The rest are funny catcode settings to obfuscate the code ;-) – Phelype Oleinik Oct 2 at 23:39

Like Sigur, I am also convinced this is an XY question. Probably Italian autocorrection replaced marmot my Mario, right? ;-)

\documentclass[border={1cm 3.14mm 1cm 3.14mm}]{standalone}
\usepackage{tikzlings} % https://ctan.org/pkg/tikzlings
\begin{document}
\begin{tikzpicture}
(-0.56,1.35) to[out=-10,in=190] (0.56,1.35)
to[out=-80,in=85] (0.58,0.6) to[out=-175,in=-5] (-0.58,0.6)
to[out=95,in=-100] cycle;
\shade[ball color=brown!50!black,rotate around={70:(0.385,0.93)}] (0.385,0.93) ellipse (0.24 and 0.13);
\shade[ball color=brown!50!black,rotate around={-70:(-0.385,0.93)}] (-0.385,0.93) ellipse (0.24 and 0.13);
\draw[red,thick,fill=yellow] (-0.1,1.2) -- (-0.25,1.05) -- (0,0.7) -- (0.25,1.05) --
(0.1,1.2) -- cycle;
\node[font=\sffamily\bfseries,text=red] at (0,1) {S};
\end{tikzpicture}
\end{document}


• Actually I expected reply from you....and you fulfilled....Great.... – MadyYuvi Oct 4 at 12:32
• Put a raccoon tail on it and it might look like Mario in the tanuki suit as seen in Super Mario Bros. 3. – Renan Oct 4 at 14:22

With ducksay package:

\documentclass{article}
\usepackage{ducksay}

{
,-"-.
/     :
'   ,- |
|  | L|---.
.   ,'     |
|   / _  _  |
,|  /."_ "."/
| ' :  ( || |
\  |b  D| b|.-.
,--8b     "   )
| _     d._ -'
'.     YCGMMP
""\    " |"
\    /
|__|
}

\begin{document}

\ducksay[animal=luigi]{I'm luigi}

\end{document}