Added simple test character sprite to viewer application, and render

any involved sprites in IsoSceneView after each set of tiles is drawn.
Exit the viewer and editor applications on window close.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@133 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Walter Korman
2001-07-30 15:38:52 +00:00
parent c76ae0ccf5
commit 11800e8a43
6 changed files with 250 additions and 23 deletions
@@ -1,8 +1,11 @@
//
// $Id: SpriteManager.java,v 1.1 2001/07/28 01:50:07 shaper Exp $
// $Id: SpriteManager.java,v 1.2 2001/07/30 15:38:52 shaper Exp $
package com.threerings.miso.sprite;
import java.awt.Graphics2D;
import java.util.ArrayList;
/**
* The SpriteManager manages the sprites running about in the game.
*/
@@ -13,5 +16,45 @@ public class SpriteManager
*/
public SpriteManager ()
{
_sprites = new ArrayList();
}
/**
* Add a sprite to the set of sprites managed by this SpriteManager.
*
* @param sprite the sprite to add.
*/
public void addSprite (Sprite sprite)
{
_sprites.add(sprite);
}
/**
* Render the sprites residing within the specified pixel bounds
* to the given graphics context.
*
* @param gfx the graphics context.
* @param x the bounds x-position.
* @param y the bounds y-position.
* @param width the bounds width.
* @param height the bounds height.
*/
public void renderSprites (
Graphics2D gfx, int x, int y, int width, int height)
{
// TODO: optimize to store sprites based on quadrants they're
// in (or somesuch), and sorted, so that we can more quickly
// determine which sprites to draw.
int size = _sprites.size();
for (int ii = 0; ii < size; ii++) {
Sprite sprite = (Sprite)_sprites.get(ii);
if (sprite.inside(x, y, width, height)) {
sprite.paint(gfx);
}
}
}
/** The sprite objects we're managing. */
protected ArrayList _sprites;
}