This repository was archived by the owner on Jan 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSprite.h
More file actions
97 lines (86 loc) · 2.36 KB
/
Sprite.h
File metadata and controls
97 lines (86 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#ifndef SPRITE_H
#define SPRITE_H
#include <GL/glx.h>
#include "functions.h"
#include "ppm.h"
//=====================================================================
//Sprite
//=====================================================================
//Note: This is used to hold the images of ppm files
// Example how to use:
// Sprite var1;
// ...
// In initOpengl(){ //When Initiaizing Stuff
// ...
// var1.insert("image.ppm", row, column);
// ...
// }
// //In Rendering Function
// ...
// var1.drawTile(x,y)
//
// // This will draw on a coordinates of the tile
// // make sure to use glTranslatef to change its coordinates
//
//For this to work properly, the image sheet must have sprite Evenly Split
//between each other
//---------------------------------------------------------------------
class Sprite{
//Global Access-------------------------------------------------------
private:
const char *imageName;
char save[40];
int column;
int row;
int imageHeight;
int imageWidth;
int clipHeight;
int clipWidth;
float clipX;
float clipY;
int index;
bool mirror;
bool background;
Ppmimage *image;
GLuint texture;
int tileAt;
int indexX, indexY;
int indexAt;
//Functions-----------------------------------------------------------
public:
//Setting Up
Sprite();
void insert(const char *filename, int x, int y);
void setFile(const char *filename);
void initSprite();
void reInitSprite();
void setClip(int x, int y);
void setSize(int x, int y);
//Outter Functions
void drawFont(int atSet);
void drawTile(int row, int column);
void drawTile(int row, int column, int w, int h);
void drawTile(int atSet);
void drawTile();
void drawSequence();
void replaceTexture(GLuint take);
GLuint textureBox();
int getClipHeight();
int getClipWidth();
int getIndex();
void setIndex(int ind);
int getIndexX();
int getIndexY();
int getIndexAt();
int getRow();
int getColumn();
void setMirror(bool reflect);
bool checkMirror();
void setBackground(bool back);
bool checkBackground();
void setIndexXY(int x, int y);
void setIndexAt(int ind);
//Function Aid
unsigned char *buildAlphaData2(Ppmimage *img);
};
#endif