feature(foxy) Персонаж умеет бегать
This commit is contained in:
@@ -6,6 +6,7 @@ public class Foxy {
|
||||
private Sprite tex_idle, tex_run;
|
||||
private Sprite current_texture;
|
||||
private int x, y;
|
||||
private int state;
|
||||
private boolean inverse = false;
|
||||
|
||||
public Foxy(){
|
||||
@@ -19,22 +20,48 @@ public class Foxy {
|
||||
inverse = value;
|
||||
}
|
||||
|
||||
public boolean getInverse(){
|
||||
return inverse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Состояние персонажа.<br/>
|
||||
* 0 - idle - стоит на месте
|
||||
* 1 - run - бежит
|
||||
*/
|
||||
public void setState(int value){
|
||||
state = value;
|
||||
if(value == 0){
|
||||
current_texture = tex_idle;
|
||||
} else if(value == 1){
|
||||
current_texture = tex_run;
|
||||
}
|
||||
current_texture.setFrame(0);
|
||||
}
|
||||
|
||||
public void setX(int value){
|
||||
x = value;
|
||||
}
|
||||
|
||||
public int getX(){
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setY(int value){
|
||||
y = value;
|
||||
}
|
||||
|
||||
public int getY(){
|
||||
return y;
|
||||
}
|
||||
|
||||
public int getState(){
|
||||
return state;
|
||||
}
|
||||
|
||||
public void render(){
|
||||
Sprite.Coords frame = current_texture.getFrame();
|
||||
final int K = 2;
|
||||
final int K = 4;
|
||||
|
||||
GL11.glColor3f(1f, 1f, 1f);
|
||||
current_texture.bind();
|
||||
@@ -43,28 +70,28 @@ public class Foxy {
|
||||
|
||||
if(inverse){
|
||||
GL11.glTexCoord2f(current_texture.floatX(frame.x2), current_texture.floatY(frame.y1));
|
||||
GL11.glVertex2f(0, 0);
|
||||
GL11.glVertex2f(x, 0);
|
||||
|
||||
GL11.glTexCoord2f(current_texture.floatX(frame.x1), current_texture.floatY(frame.y1));
|
||||
GL11.glVertex2f(current_texture.getWidthSprite()*K, 0);
|
||||
GL11.glVertex2f(x + current_texture.getWidthSprite()*K, 0);
|
||||
|
||||
GL11.glTexCoord2f(current_texture.floatX(frame.x1), current_texture.floatY(frame.y2));
|
||||
GL11.glVertex2f(current_texture.getWidthSprite()*K, current_texture.getHeightSprite()*K);
|
||||
GL11.glVertex2f(x + current_texture.getWidthSprite()*K, current_texture.getHeightSprite()*K);
|
||||
|
||||
GL11.glTexCoord2f(current_texture.floatX(frame.x2), current_texture.floatY(frame.y2));
|
||||
GL11.glVertex2f(0, current_texture.getHeightSprite()*K);
|
||||
GL11.glVertex2f(x, current_texture.getHeightSprite()*K);
|
||||
} else {
|
||||
GL11.glTexCoord2f(current_texture.floatX(frame.x1), current_texture.floatY(frame.y1));
|
||||
GL11.glVertex2f(0, 0);
|
||||
GL11.glVertex2f(x, 0);
|
||||
|
||||
GL11.glTexCoord2f(current_texture.floatX(frame.x2), current_texture.floatY(frame.y1));
|
||||
GL11.glVertex2f(current_texture.getWidthSprite()*K, 0);
|
||||
GL11.glVertex2f(x + current_texture.getWidthSprite()*K, 0);
|
||||
|
||||
GL11.glTexCoord2f(current_texture.floatX(frame.x2), current_texture.floatY(frame.y2));
|
||||
GL11.glVertex2f(current_texture.getWidthSprite()*K, current_texture.getHeightSprite()*K);
|
||||
GL11.glVertex2f(x + current_texture.getWidthSprite()*K, current_texture.getHeightSprite()*K);
|
||||
|
||||
GL11.glTexCoord2f(current_texture.floatX(frame.x1), current_texture.floatY(frame.y2));
|
||||
GL11.glVertex2f(0, current_texture.getHeightSprite()*K);
|
||||
GL11.glVertex2f(x, current_texture.getHeightSprite()*K);
|
||||
}
|
||||
|
||||
GL11.glEnd();
|
||||
|
||||
Reference in New Issue
Block a user