37

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.

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

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

enter image description here

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}

enter image description here

  • 5
    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
  • 1
    @Sebastiano, you are welcome. – Sigur Oct 7 at 12:14
90

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:

enter image description here

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}%
  \endgroup\advance\thecol 1 \ignorespaces}
\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
  \def^^M{\advance\therow-1 \thecol 0 }%
  \rulesize\unitlength
  \advance\rulesize 0.1pt
  \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
  • 1
    Unbelievable!!!! Did you already known this solution, right? Or did you create this just now? – Sigur Oct 2 at 23:33
  • 4
    @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
  • 1
    Ow, I was asking the second. Amazing how fast you wrote the code. Congs. – Sigur Oct 2 at 23:37
  • 6
    @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
  • 1
    @Sebastiano Thanks, glad you liked. However my answer already received far too many votes. Could you please accept one of the other answers? – Phelype Oleinik Oct 6 at 19:20
26

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}
 \marmot[whiskers,teeth,3D,shadow]
 \fill[top color=blue!70,bottom color=blue,shading angle=-30] 
 (-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}

enter image description here

  • 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
11

With ducksay package:

\documentclass{article}
\usepackage{ducksay}

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

\begin{document}

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

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.