\documentclass{article}
\usepackage{common}

\begin{document}
\begin{framed}

\pagehead{Sprite collision class}

In a game you might have the following rules:

\begin{itemize}
\item when the player touches an enemy bomb, the player dies
\item when a player's missile touches an enemy, that enemy dies.
\end{itemize}

and here is a typical in-game situation:

\begin{tikzpicture}
\draw (0,0) node [circle, draw=orange!90, fill=orange!30, minimum width=3cm] {
\begin{tabular}{c}
player \\
00 (J)
\end{tabular}
};

\draw (4.8,0.8) node [circle, draw=orange!90, fill=orange!30, minimum width=0.5cm] {
\begin{tabular}{c}
missile \\
01 (J)
\end{tabular}
};

\draw (7,1) node [circle, draw=green!90, fill=green!30, minimum width=3cm] {
\begin{tabular}{c}
enemy \\
02 (K)
\end{tabular}
};

\draw (2.7,1.7) node [circle, draw=green!90, fill=green!30, minimum width=0.5cm] {
\begin{tabular}{c}
bomb \\
03 (K)
\end{tabular}
};

\draw (1,1.5) node [circle, draw=green!90, fill=green!30, minimum width=0.5cm] {
\begin{tabular}{c}
bomb \\
04 (K)
\end{tabular}
};

\end{tikzpicture}

Notice that bomb 04 covers both bomb 03 and player 00.  In this situation
we're much more interested that bomb 04 is covering player 00.  For this reason,
the hardware has a mode
\texttt{JK\_MODE}
where it ignores 'friendly' collisions.
In this mode,
each sprite belongs a \textbf{collision class} J or K.  Collision notifications
only happen when a J sprite covers up a K sprite, or when a K sprite
covers up a J sprite.

\begin{tabular}{|c|c|l|}
\hline
\textbf{address} & \textbf{value} & \textbf{meaning} \\
\hline
0x2900 & FF & sprite 00 no collision \\
\hline
0x2901 & FF & sprite 01 no collision \\
\hline
0x2902 & 01 & sprite 02 covers some pixels from sprite 01 \\
\hline
0x2903 & FF & sprite 03 no collision \\
\hline
0x2904 & 00 & sprite 04 covers some pixels from sprite 00 \\
\hline
\end{tabular}

In typical use, player sprites are class J and enemy sprites are class K.

\sample{jkcollision}

\end{framed}
\end{document}
