Question #ec294

1 Answer
May 15, 2016

There is really no short answer. In general, sprites could interact in a variety of ways. The actual commands used would depend on the type of interaction, the programming language used and more.


The commands (or code) for sprite interaction will depend on a number of things including:

  1. Type of interaction (i.e. complexity, realism etc.)
  2. Languages or tools used for implementation
  3. Methods

Sprite interactions for game development and computer graphics animation can be as simple or complex as you want them to be as long as they reproduce the desired visual effect. On the other hand, since this question was posted on a physics forum, it may also be helpful to mention that more realistic interactions (e.g. required for high quality CGI Marvel hero movies) will incorporate more physics-based principles (i.e. equations) and computational power.

There are tools or frameworks like Game Salad and Unity 3D that allow you to do sprite interactions without having much or any knowledge of physics, math or commands (i.e. writing code). You would only need to memorize menus and drag and drop items.

But if you are looking for a more fundamental understanding for, say, the purpose of modifying or writing code from scratch, the basic idea would be to create an animation loop containing functions that carry out the following 3 tasks:

Update sprite positions
Detect overlap between sprites
Do something when sprites overlap

The video tutorial at the link below describes a simple sprite interaction code written in HTML5/Javascript (...but again, there are other languages and tools you can use).