Arcade
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events
GameAPI.BudgetBoy.Graphics Class Reference

Peripheral providing an interface with the BudgetBoy graphics hardware. More...

Inheritance diagram for GameAPI.BudgetBoy.Graphics:
GameAPI.GraphicsBase< TGame, TImplementation > GameAPI.Peripheral< TGame, TProvider, TImplementation > GameAPI.Peripheral

Public Member Functions

Vector2I WorldToScreen (Vector2F pos)
 Transforms a world position to a position on screen. More...
 
Vector2F ScreenToWorld (Vector2I pos)
 Transforms a position on screen to a world position. More...
 
void SetClearColor (SwatchIndex index)
 Sets the color the screen will be cleared to using the specified palette index. More...
 
Image GetImage (String location)
 Finds an image at the specified location. See RawImage for a description of supported formats. More...
 
Animation CreateAnimation< T > (Func< T, String > selector, params T[] frameIndices)
 Creates an animation from an array of frame indentifiers of type T and a selector function that converts each index into a frame location string. More...
 
Animation CreateAnimation< T > (Func< T, String > selector, IEnumerable< T > frameIndices)
 Creates an animation from a collection of frame indentifiers of type T and a selector function that converts each index into a frame location string. More...
 
Animation CreateAnimation (IEnumerable< String > frameLocations)
 Creates an animation from a collection of frame image location strings. More...
 
Animation CreateAnimation (params String[] frameLocations)
 Creates an animation from an array of frame image location strings. More...
 
void SetScissor (RectI bounds)
 Sets the clipping rectangle. While set, only content in this rect is drawn. More...
 
void ClearScissor ()
 Clears the scissor rect, if set. More...
 
void PopTransform ()
 Pops the current transformation, making the previous transformation active. More...
 
void ClearTransform ()
 Pops all transformations, making the identity transform active. More...
 
IDisposable PushTranslation (Vector2F translation)
 Pushes a translation transformation. More...
 
IDisposable PushRotation (float radians)
 Pushes a global rotation transformation. More...
 
IDisposable PushScale (float scale)
 Pushes a global scaling transformation. Value must be positive and less than 256. More...
 
IDisposable PushScale (Vector2F scale)
 Pushes a global scaling transformation. Both components must be positive values less than 256. More...
 
void DrawPoint (SwatchIndex swatchIndex, float size, Vector2F point)
 Draws a single point. More...
 
void DrawPoints (SwatchIndex swatchIndex, float size, params Vector2F[] points)
 Draws multiple points. More...
 
void DrawLine (SwatchIndex swatchIndex, float thickness, Vector2F start, Vector2F end)
 Draws a single line. More...
 
void DrawLines (SwatchIndex swatchIndex, float thickness, params Vector2F[] points)
 Draws multiple lines, with each point connecting to the next. More...
 
void DrawLines (SwatchIndex swatchIndex, float thickness, IList< Vector2F > points)
 Draws multiple lines, with each point connecting to the next. More...
 
void DrawRect (SwatchIndex swatchIndex, int thickness, Vector2F origin, Vector2F size)
 Draws the outline of a rectangle. More...
 
void DrawRect (SwatchIndex swatchIndex, int thickness, RectF rect)
 Draws the outline of a rectangle. More...
 
void FillRect (SwatchIndex swatchIndex, Vector2F origin, Vector2F size)
 Draws a filled rectangle. More...
 
void FillRect (SwatchIndex swatchIndex, RectF rect)
 Draws a filled rectangle. More...
 
void Render (Sprite sprite)
 Draw a given Sprite to the screen. More...
 
void Render (IRenderable renderable)
 Draw a given IRenderable to the screen. More...
 
void Render (IEnumerable< IRenderable > renderables)
 Draws a enumerator of IRenderables to the screen. More...
 
- Public Member Functions inherited from GameAPI.Peripheral< TGame, TProvider, TImplementation >
override void Dispose ()
 

Public Attributes

const int MinimumDisplayWidth = 1
 Smallest allowed horizontal display resolution. More...
 
const int MaximumDisplayWidth = 256
 Largest allowed horizontal display resolution. More...
 
const int MinimumDisplayHeight = 1
 Smallest allowed vertical display resolution. More...
 
const int MaximumDisplayHeight = 240
 Largest allowed vertical display resolution. More...
 
const int RenderPayloadLimit = 512
 Maximum number of bytes that may be streamed per frame. Currently unenforced. More...
 

Protected Member Functions

override void OnInitialize ()
 
override void OnRegisterResourceTypes (ResourceManager library)
 
override void OnLoadResources (Resources volume)
 
override void OnSerializeSetup (Stream stream)
 
override void OnCopyFrame (Stream frame)
 
override void OnSerializeFrame (Stream stream)
 
- Protected Member Functions inherited from GameAPI.GraphicsBase< TGame, TImplementation >
override void OnAttachImplementation ()
 
- Protected Member Functions inherited from GameAPI.Peripheral
void ClearFrameWriter ()
 
virtual void OnReset ()
 
virtual void OnDeserializeSetup (Stream stream)
 
virtual void OnStartControlling ()
 
virtual void OnStopControlling ()
 
virtual void OnDeserializeFrame (Stream stream)
 
virtual void OnUpdateFrame (double dt)
 

Properties

Palette Palette [get]
 A palette of color swatches used when drawing elements. More...
 
SwatchIndex ClearColorIndex [get]
 The background color. More...
 
Vector2F Center [get]
 Position of the middle of the screen in pixels. More...
 
RectI Scissor [get]
 Current clipping rectangle. Only accessible duing OnRender() calls. More...
 
RectF WorldScissorBounds [get]
 Gets the smallest bounding rectangle in world space that encloses the clipping rectangle. More...
 
Transform Transform [get]
 Current global transformation resulting from calls to PushTranslation(), PushRotation() and PushScale(). This is reset to the identity transformation each frame. Only accessible duing OnRender() calls. More...
 
Transform NoTranslationTransform [get]
 Current transform without a translation. Only accessible duing OnRender() calls. More...
 
Transform InverseTransform [get]
 Inverse of the current global transformation. Only accessible duing OnRender() calls. More...
 
- Properties inherited from GameAPI.GraphicsBase< TGame, TImplementation >
int Width [get]
 Horizontal resolution of the screen in pixels. More...
 
int Height [get]
 Vertical resolution of the screen in pixels. More...
 
int LastFrameSize [get]
 Number of bytes of graphical data drawn last frame. More...
 
Vector2I Size [get]
 Resolution of the screen in pixels. More...
 
float Aspect [get]
 Aspect ratio of the screen. More...
 
bool ShouldSerialize [get]
 
- Properties inherited from GameAPI.Peripheral< TGame, TProvider, TImplementation >
virtual bool ShouldUpdate [get]
 
- Properties inherited from GameAPI.Peripheral
BinaryWriter FrameWriter [get]
 

Detailed Description

Peripheral providing an interface with the BudgetBoy graphics hardware.

Member Function Documentation

void GameAPI.BudgetBoy.Graphics.ClearScissor ( )
inline

Clears the scissor rect, if set.

void GameAPI.BudgetBoy.Graphics.ClearTransform ( )
inline

Pops all transformations, making the identity transform active.

Animation GameAPI.BudgetBoy.Graphics.CreateAnimation ( IEnumerable< String >  frameLocations)
inline

Creates an animation from a collection of frame image location strings.

Parameters
frameLocationsCollection of frame image resource locations.

var anim = Graphics.CreateAnimation(Enumerable.Range(0, 8).Select(i => "images/player/jump_" + i));

Animation GameAPI.BudgetBoy.Graphics.CreateAnimation ( params String[]  frameLocations)
inline

Creates an animation from an array of frame image location strings.

Parameters
frameLocationsArray of frame image resource locations.

var anim = Graphics.CreateAnimation("images/player/hurt_0", "images/player/hurt_1", "images/player/hurt_2");

Animation GameAPI.BudgetBoy.Graphics.CreateAnimation< T > ( Func< T, String >  selector,
params T[]  frameIndices 
)
inline

Creates an animation from an array of frame indentifiers of type T and a selector function that converts each index into a frame location string.

Template Parameters
TFrame identifier type.
Parameters
selectorFunction to convert a frame identifier into a resource location string.
frameIndicesCollection of frame identifiers.

var anim = Graphics.CreateAnimation(i => "images/player/walk_" + i, 0, 1, 2, 3, 2, 1);

Animation GameAPI.BudgetBoy.Graphics.CreateAnimation< T > ( Func< T, String >  selector,
IEnumerable< T >  frameIndices 
)
inline

Creates an animation from a collection of frame indentifiers of type T and a selector function that converts each index into a frame location string.

Template Parameters
TFrame identifier type.
Parameters
selectorFunction to convert a frame identifier into a resource location string.
frameIndicesCollection of frame identifiers.

var anim = Graphics.CreateAnimation(i => "images/player/jump_" + i, Enumerable.Range(0, 8));

void GameAPI.BudgetBoy.Graphics.DrawLine ( SwatchIndex  swatchIndex,
float  thickness,
Vector2F  start,
Vector2F  end 
)
inline

Draws a single line.

Parameters
swatchIndexThe SwatchIndex used to color the line (only the first color is used).
thicknessThe thickness of the line in pixels.
startThe world position of the line's starting point.
endThe world position of the line's ending point.
void GameAPI.BudgetBoy.Graphics.DrawLines ( SwatchIndex  swatchIndex,
float  thickness,
params Vector2F[]  points 
)
inline

Draws multiple lines, with each point connecting to the next.

Parameters
swatchIndexThe SwatchIndex used to color the lines (only the first color is used).
thicknessThe thickness of the lines in pixels.
pointsThe world position of the lines' points.
void GameAPI.BudgetBoy.Graphics.DrawLines ( SwatchIndex  swatchIndex,
float  thickness,
IList< Vector2F points 
)
inline

Draws multiple lines, with each point connecting to the next.

Parameters
swatchIndexThe SwatchIndex used to color the lines (only the first color is used).
thicknessThe thickness of the lines in pixels.
pointsThe world position of the lines' points.
void GameAPI.BudgetBoy.Graphics.DrawPoint ( SwatchIndex  swatchIndex,
float  size,
Vector2F  point 
)
inline

Draws a single point.

Parameters
swatchIndexThe SwatchIndex used to color the point (only the first component color in the swatch is used).
sizeThe size of the point.
pointThe world position of the center of the point.
void GameAPI.BudgetBoy.Graphics.DrawPoints ( SwatchIndex  swatchIndex,
float  size,
params Vector2F[]  points 
)
inline

Draws multiple points.

Parameters
swatchIndexThe SwatchIndex used to color the points (only the first component color in the swatch is used).
sizeThe size of the points.
pointsThe world position of the center of each point.
void GameAPI.BudgetBoy.Graphics.DrawRect ( SwatchIndex  swatchIndex,
int  thickness,
Vector2F  origin,
Vector2F  size 
)
inline

Draws the outline of a rectangle.

Parameters
swatchIndexThe SwatchIndex used to color the rect (only the first component color in the swatch is used).
thicknessThe thickness in pixels of the outline.
originThe world position of the lower-left point of the rect.
sizeThe width/height of the rect in pixels.
void GameAPI.BudgetBoy.Graphics.DrawRect ( SwatchIndex  swatchIndex,
int  thickness,
RectF  rect 
)
inline

Draws the outline of a rectangle.

Parameters
swatchIndexThe SwatchIndex used to color the rect (only the first component color in the swatch is used).
thicknessThe thickness in pixels of the outline.
rectThe RectI to outline.
void GameAPI.BudgetBoy.Graphics.FillRect ( SwatchIndex  swatchIndex,
Vector2F  origin,
Vector2F  size 
)
inline

Draws a filled rectangle.

Parameters
swatchIndexThe SwatchIndex used to color the rect (only the first component color in the swatch is used).
originThe world position of the lower-left point of the rect.
sizeThe width/height of the rect in pixels.
void GameAPI.BudgetBoy.Graphics.FillRect ( SwatchIndex  swatchIndex,
RectF  rect 
)
inline

Draws a filled rectangle.

Parameters
swatchIndexThe SwatchIndex used to color the rect (only the first component color in the swatch is used).
rectThe RectI to fill.
Image GameAPI.BudgetBoy.Graphics.GetImage ( String  location)
inline

Finds an image at the specified location. See RawImage for a description of supported formats.

Parameters
locationFile location relative to your game's root folder, without an extension.

// Retrieves an image from "images/player.png" var img = GetImage("images/player");

override void GameAPI.BudgetBoy.Graphics.OnCopyFrame ( Stream  frame)
inlineprotectedvirtual

Reimplemented from GameAPI.Peripheral.

override void GameAPI.BudgetBoy.Graphics.OnInitialize ( )
inlineprotectedvirtual
override void GameAPI.BudgetBoy.Graphics.OnLoadResources ( Resources  volume)
inlineprotectedvirtual

Reimplemented from GameAPI.Peripheral.

override void GameAPI.BudgetBoy.Graphics.OnRegisterResourceTypes ( ResourceManager  library)
inlineprotectedvirtual

Reimplemented from GameAPI.Peripheral.

override void GameAPI.BudgetBoy.Graphics.OnSerializeFrame ( Stream  stream)
inlineprotectedvirtual

Reimplemented from GameAPI.Peripheral.

override void GameAPI.BudgetBoy.Graphics.OnSerializeSetup ( Stream  stream)
inlineprotectedvirtual

Reimplemented from GameAPI.Peripheral.

void GameAPI.BudgetBoy.Graphics.PopTransform ( )
inline

Pops the current transformation, making the previous transformation active.

IDisposable GameAPI.BudgetBoy.Graphics.PushRotation ( float  radians)
inline

Pushes a global rotation transformation.

Parameters
radiansRotation in radians.
IDisposable GameAPI.BudgetBoy.Graphics.PushScale ( float  scale)
inline

Pushes a global scaling transformation. Value must be positive and less than 256.

Parameters
scaleHorizontal and vertical scale.
IDisposable GameAPI.BudgetBoy.Graphics.PushScale ( Vector2F  scale)
inline

Pushes a global scaling transformation. Both components must be positive values less than 256.

Parameters
scaleHorizontal and vertical scale.
IDisposable GameAPI.BudgetBoy.Graphics.PushTranslation ( Vector2F  translation)
inline

Pushes a translation transformation.

Parameters
translationWorld space translation.
void GameAPI.BudgetBoy.Graphics.Render ( Sprite  sprite)
inline

Draw a given Sprite to the screen.

Parameters
spriteThe Sprite to draw
void GameAPI.BudgetBoy.Graphics.Render ( IRenderable  renderable)
inline

Draw a given IRenderable to the screen.

Parameters
renderableThe IRenderable to draw
void GameAPI.BudgetBoy.Graphics.Render ( IEnumerable< IRenderable renderables)
inline

Draws a enumerator of IRenderables to the screen.

Parameters
renderablesThe collection of IRenderables to draw (example: Stage)
Vector2F GameAPI.BudgetBoy.Graphics.ScreenToWorld ( Vector2I  pos)
inline

Transforms a position on screen to a world position.

Parameters
posScreen position.
void GameAPI.BudgetBoy.Graphics.SetClearColor ( SwatchIndex  index)
inline

Sets the color the screen will be cleared to using the specified palette index.

Parameters
indexSwatch index of the new clear color.
void GameAPI.BudgetBoy.Graphics.SetScissor ( RectI  bounds)
inline

Sets the clipping rectangle. While set, only content in this rect is drawn.

Parameters
boundsThe rect to limit drawing to.
Vector2I GameAPI.BudgetBoy.Graphics.WorldToScreen ( Vector2F  pos)
inline

Transforms a world position to a position on screen.

Parameters
posWorld position.

Member Data Documentation

const int GameAPI.BudgetBoy.Graphics.MaximumDisplayHeight = 240

Largest allowed vertical display resolution.

const int GameAPI.BudgetBoy.Graphics.MaximumDisplayWidth = 256

Largest allowed horizontal display resolution.

const int GameAPI.BudgetBoy.Graphics.MinimumDisplayHeight = 1

Smallest allowed vertical display resolution.

const int GameAPI.BudgetBoy.Graphics.MinimumDisplayWidth = 1

Smallest allowed horizontal display resolution.

const int GameAPI.BudgetBoy.Graphics.RenderPayloadLimit = 512

Maximum number of bytes that may be streamed per frame. Currently unenforced.

Property Documentation

Vector2F GameAPI.BudgetBoy.Graphics.Center
get

Position of the middle of the screen in pixels.

SwatchIndex GameAPI.BudgetBoy.Graphics.ClearColorIndex
get

The background color.

Transform GameAPI.BudgetBoy.Graphics.InverseTransform
get

Inverse of the current global transformation. Only accessible duing OnRender() calls.

Transform GameAPI.BudgetBoy.Graphics.NoTranslationTransform
get

Current transform without a translation. Only accessible duing OnRender() calls.

Palette GameAPI.BudgetBoy.Graphics.Palette
get

A palette of color swatches used when drawing elements.

RectI GameAPI.BudgetBoy.Graphics.Scissor
get

Current clipping rectangle. Only accessible duing OnRender() calls.

Transform GameAPI.BudgetBoy.Graphics.Transform
get

Current global transformation resulting from calls to PushTranslation(), PushRotation() and PushScale(). This is reset to the identity transformation each frame. Only accessible duing OnRender() calls.

RectF GameAPI.BudgetBoy.Graphics.WorldScissorBounds
get

Gets the smallest bounding rectangle in world space that encloses the clipping rectangle.