gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > Mode 7 Sprites

#16291 - GunterPete - Wed Feb 11, 2004 9:23 pm

Hi there,

Does anyone have any advice, or a pointer to a tutorial on displaying 3D sprites in a Mode 7 engine? I'm using code based on the Mode 7 tutorial on the Pern Project, and trying to implement a game like the jetpack game from Pilotwings on the SNES.

Any advice would be greatly appreciated.

-Pete Gunter

#16292 - poslundc - Wed Feb 11, 2004 9:38 pm

If you know the distance from the camera to the sprite, then you can figure it out pretty easily.

First use a simple rotation matrix to rotate your sprite's coordinates to match the rotation of your camera (ie. y' = y cos A + x sin A; x' = x cos A - y sin A).

Then divide both your x and y coordinates by the distance to the camera.

Then just use that distance as your scale value for the sprite (correct it so that the "standard" focal length yields a value of (1 << 8)).

Dan.