mirror of
https://github.com/AquaMorph/Droplets.git
synced 2025-04-30 01:35:34 +00:00
Documentation for graphics
This commit is contained in:
parent
a349a0d793
commit
8abc2532bc
@ -19,15 +19,15 @@ Sprite::~Sprite() {
|
|||||||
delete[] sprite;
|
delete[] sprite;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sprite::AddPixel(int x, int y, bool solid) {
|
void Sprite::AddPixel(int x, int y, bool on) {
|
||||||
sprite[x][height-y-1] = solid;
|
sprite[x][height-y-1] = on;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sprite::AddLine(int x1,
|
void Sprite::AddLine(int x1,
|
||||||
int y1,
|
int y1,
|
||||||
int x2,
|
int x2,
|
||||||
int y2,
|
int y2,
|
||||||
bool solid) {
|
bool on) {
|
||||||
uint8_t deltaX = abs(x2 - x1);
|
uint8_t deltaX = abs(x2 - x1);
|
||||||
uint8_t deltaY = abs(y2 - y1);
|
uint8_t deltaY = abs(y2 - y1);
|
||||||
int8_t signX = ((x1 < x2) ? 1 : -1);
|
int8_t signX = ((x1 < x2) ? 1 : -1);
|
||||||
@ -35,9 +35,9 @@ void Sprite::AddLine(int x1,
|
|||||||
int16_t error = deltaX - deltaY;
|
int16_t error = deltaX - deltaY;
|
||||||
int16_t error2;
|
int16_t error2;
|
||||||
|
|
||||||
AddPixel(x2, y2, solid);
|
AddPixel(x2, y2, on);
|
||||||
while((x1 != x2) || (y1 != y2)) {
|
while((x1 != x2) || (y1 != y2)) {
|
||||||
AddPixel(x1, y1, solid);
|
AddPixel(x1, y1, on);
|
||||||
error2 = error * 2;
|
error2 = error * 2;
|
||||||
if(error2 > -deltaY) {
|
if(error2 > -deltaY) {
|
||||||
error -= deltaY;
|
error -= deltaY;
|
||||||
|
@ -13,24 +13,154 @@ class Sprite {
|
|||||||
bool** sprite;
|
bool** sprite;
|
||||||
int x_shift = 0;
|
int x_shift = 0;
|
||||||
int y_shift = 0;
|
int y_shift = 0;
|
||||||
int GetShiftArray(int, int, int);
|
|
||||||
int GetShiftArrayX(int);
|
/*
|
||||||
int GetShiftArrayY(int);
|
* Converts a graphic pixel location to a new one based on
|
||||||
|
* a given shift.
|
||||||
|
*
|
||||||
|
* @param pos pixel position
|
||||||
|
* @param shift shift amount
|
||||||
|
* @param array_size max length of dimension
|
||||||
|
* return new pixel position
|
||||||
|
*/
|
||||||
|
int GetShiftArray(int pos,
|
||||||
|
int shift,
|
||||||
|
int array_size);
|
||||||
|
/*
|
||||||
|
* Converts a x axis position based upon the sprites shift.
|
||||||
|
*
|
||||||
|
* @param pos x axis position
|
||||||
|
* @return new x axis position
|
||||||
|
*/
|
||||||
|
int GetShiftArrayX(int pos);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Converts a y axis position based upon the sprites shift.
|
||||||
|
*
|
||||||
|
* @param pos y axis position
|
||||||
|
* @return new y axis position
|
||||||
|
*/
|
||||||
|
int GetShiftArrayY(int pos);
|
||||||
public:
|
public:
|
||||||
Sprite(int, int);
|
/*
|
||||||
|
* Contsturctor for sprite.
|
||||||
|
*
|
||||||
|
* @param m_width width
|
||||||
|
* @param m_height height
|
||||||
|
*/
|
||||||
|
Sprite(int m_width,
|
||||||
|
int m_height);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Destructor for sprite.
|
||||||
|
*/
|
||||||
~Sprite();
|
~Sprite();
|
||||||
void AddPixel(int, int, bool);
|
|
||||||
void AddLine(int, int, int, int, bool);
|
/*
|
||||||
|
* Sets a pixel on the sprite.
|
||||||
|
*
|
||||||
|
* @param x pixel x coordinate
|
||||||
|
* @param y pixel y coordinate
|
||||||
|
* @param on pixel on or off
|
||||||
|
*/
|
||||||
|
void AddPixel(int x,
|
||||||
|
int y,
|
||||||
|
bool on);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Adds a line to the sprite.
|
||||||
|
*
|
||||||
|
* @param x1 x coordinate of the first point
|
||||||
|
* @param y1 y coordinate of the first point
|
||||||
|
* @param x2 x coordinate of the second point
|
||||||
|
* @param y2 y coordinate of the second point
|
||||||
|
* @param on line display on or off
|
||||||
|
*/
|
||||||
|
void AddLine(int x1,
|
||||||
|
int y1,
|
||||||
|
int x2,
|
||||||
|
int y2,
|
||||||
|
bool on);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns the height of the sprite.
|
||||||
|
*
|
||||||
|
* @return sprite height
|
||||||
|
*/
|
||||||
int GetHeight();
|
int GetHeight();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns the width of the sprite.
|
||||||
|
*
|
||||||
|
* @return sprite width
|
||||||
|
*/
|
||||||
int GetWidth();
|
int GetWidth();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns 2d array of booleans representing pixel state of sprite.
|
||||||
|
*
|
||||||
|
* @return sprite graphic
|
||||||
|
*/
|
||||||
bool** GetSprite();
|
bool** GetSprite();
|
||||||
void Draw(DaisyPatch, int, int);
|
|
||||||
void DrawTile(DaisyPatch, int, int, int, int);
|
/*
|
||||||
|
* Draws sprite on display.
|
||||||
|
*
|
||||||
|
* @param patch daisy patch board
|
||||||
|
* @param x starting x coordinate of sprite
|
||||||
|
* @param y starting y coordinate of sprite
|
||||||
|
*/
|
||||||
|
void Draw(DaisyPatch patch,
|
||||||
|
int x,
|
||||||
|
int y);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Draws the sprite on the display where the sprite will form
|
||||||
|
* a tile pattern when drawn on a canvus larger than the sprite.
|
||||||
|
*
|
||||||
|
* @param patch daisy patch board
|
||||||
|
* @param x1 x coordinate of the first point
|
||||||
|
* @param y1 y coordinate of the first point
|
||||||
|
* @param x2 x coordinate of the second point
|
||||||
|
* @param y2 y coordinate of the second point
|
||||||
|
*/
|
||||||
|
void DrawTile(DaisyPatch patch,
|
||||||
|
int x1,
|
||||||
|
int y1,
|
||||||
|
int x2,
|
||||||
|
int y2);
|
||||||
|
/*
|
||||||
|
* Sets sprite pixels to off.
|
||||||
|
*/
|
||||||
void SetBlank();
|
void SetBlank();
|
||||||
void SetXShift(int);
|
|
||||||
void SetYShift(int);
|
/*
|
||||||
void AdjustXShift(int);
|
* Sets the x axis shift.
|
||||||
void AdjustYShift(int);
|
*
|
||||||
|
* @param x shift value for the x axis
|
||||||
|
*/
|
||||||
|
void SetXShift(int x);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sets the y axis shift.
|
||||||
|
*
|
||||||
|
* @param y shift value for the x axis
|
||||||
|
*/
|
||||||
|
void SetYShift(int y);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Adjusts x axis shift by the given amount.
|
||||||
|
*
|
||||||
|
* @param x shift of x axis
|
||||||
|
*/
|
||||||
|
void AdjustXShift(int x);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Adjusts y axis shift by the given amount.
|
||||||
|
*
|
||||||
|
* @param y shift of x axis
|
||||||
|
*/
|
||||||
|
void AdjustYShift(int y);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CASCADE_GRAPHICS_SPRITE_H_
|
#endif // CASCADE_GRAPHICS_SPRITE_H_
|
||||||
|
@ -11,10 +11,29 @@ class Wave: public Sprite {
|
|||||||
private:
|
private:
|
||||||
WaveShape wave;
|
WaveShape wave;
|
||||||
const double pi = std::acos(-1);
|
const double pi = std::acos(-1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Changes pixels of the graphic based on the set wave shape.
|
||||||
|
*/
|
||||||
void DrawShape();
|
void DrawShape();
|
||||||
public:
|
public:
|
||||||
Wave(WaveShape, int, int);
|
/*
|
||||||
void SetWaveShape(WaveShape);
|
* Contstructor for wave shape sprite.
|
||||||
|
*
|
||||||
|
* @param m_wave wave shape
|
||||||
|
* @param width sprite width
|
||||||
|
* @param height sprite height
|
||||||
|
*/
|
||||||
|
Wave(WaveShape m_wave,
|
||||||
|
int width,
|
||||||
|
int height);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sets the sprites wave shape.
|
||||||
|
*
|
||||||
|
* @param m_wave wave shape
|
||||||
|
*/
|
||||||
|
void SetWaveShape(WaveShape m_wave);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user