Initial version of mostly-placeholder sprite-related classes.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@132 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Walter Korman
2001-07-28 01:50:07 +00:00
parent f39087cfc3
commit c76ae0ccf5
3 changed files with 105 additions and 0 deletions
@@ -0,0 +1,50 @@
//
// $Id: AnimationManager.java,v 1.1 2001/07/28 01:50:07 shaper Exp $
package com.threerings.miso.sprite;
import java.awt.Component;
import com.samskivert.util.Interval;
import com.samskivert.util.IntervalManager;
/**
* The AnimationManager handles the regular refreshing of the scene
* view to allow for animation. It also may someday manage special
* scene-wide animations, such as rain, fog, or earthquakes.
*/
public class AnimationManager
{
/**
* Construct and initialize the animation manager with a sprite
* manager and the panel that animations will take place within.
*/
public AnimationManager (SpriteManager spritemgr, Component target)
{
_spritemgr = spritemgr;
_target = target;
// create the interval for refreshing the display
Interval refresher = new Interval() {
public void intervalExpired (int id, Object arg)
{
_target.repaint();
}
};
// register ourselves with the interval mgr
IntervalManager.register(refresher, REFRESH_INTERVAL, null, true);
}
/** The desired number of refresh operations per second. */
protected static final int FRAME_RATE = 60;
/** The milliseconds to sleep to obtain desired frame rate. */
protected static final long REFRESH_INTERVAL = 1000 / FRAME_RATE;
/** The sprite manager. */
protected SpriteManager _spritemgr;
/** The component to refresh. */
protected Component _target;
}
@@ -0,0 +1,38 @@
//
// $Id: Sprite.java,v 1.1 2001/07/28 01:50:07 shaper Exp $
package com.threerings.miso.sprite;
import com.threerings.miso.tile.Tile;
/**
* The Sprite class represents a single moveable object within a
* scene. A sprite has a position within the scene, and a set of
* tiles used to render it (perhaps multiple frames for animation).
*/
public class Sprite
{
/** The sprite's x-position in pixel coordinates. */
public int x;
/** The sprite's y-position in pixel coordinates. */
public int y;
/**
* Construct and initialize a Sprite object.
*/
public Sprite (int x, int y, Tile[] tiles)
{
this.x = x;
this.y = y;
_tiles = tiles;
_curframe = 0;
}
/** The tiles that comprise the sprite. */
protected Tile[] _tiles;
/** The current tile frame to render. */
protected int _curframe;
}
@@ -0,0 +1,17 @@
//
// $Id: SpriteManager.java,v 1.1 2001/07/28 01:50:07 shaper Exp $
package com.threerings.miso.sprite;
/**
* The SpriteManager manages the sprites running about in the game.
*/
public class SpriteManager
{
/**
* Construct and initialize the SpriteManager object.
*/
public SpriteManager ()
{
}
}