-
-
Save belak/1969010 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Override | |
| public void draw() { | |
| this.sprite.getTexture().bind(); | |
| //double w = this.width/32; | |
| //double h = this.height/32; // we should do the same for height. | |
| double row = this.sprite.getsY(); | |
| double col = this.sprite.getsX(); | |
| double h0 = 1.0 / 32 * row; | |
| double h1 = 1.0 / 32 * (row + 1); | |
| double w0 = 1.0 / 32 * col; | |
| double w1 = 1.0 / 32 * (col + 1); | |
| glColor4f(1.0f, 1.0f, 1.0f, 1.0f); | |
| glBegin(GL_QUADS); | |
| glTexCoord2d(w0, h0); // upper left | |
| glVertex2d(x, y); | |
| glTexCoord2d(w1, h0); // upper right | |
| glVertex2d(x + 32, y); | |
| glTexCoord2d(w1, h1); // bottom right | |
| glVertex2d(x + 32, y + 32); | |
| glTexCoord2d(w0, h1); // bottom left | |
| glVertex2d(x, y + 32); | |
| glEnd(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment