package kku.cs.fgl.transition;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.StateBasedGame;
/**
* ����¹�ҾẺ���ҧ��ҡ�ء
*
* @author Wachirawut
*
*/
public class Chess extends TransitionBase {
private int w, h;
Image img3;
public Chess() {
}
public Chess(int duration) {
super(duration);
}
void init(StateBasedGame game, GameContainer container) {
w = container.getWidth();
h = container.getHeight();
if (img2 == null) {
try {
img3 = new Image(w, h);
} catch (SlickException e) {
}
} else {
img3 = img2;
}
}
public void updatex(StateBasedGame game, GameContainer container, int delta)
throws SlickException {
super.update(game, container, delta);
float t = (float) getTime() / getDuration();
float w1 = w / 16f;
float h1 = h / 16f;
float h2;
if (img3 != null) {
Graphics g = img1.getGraphics();
Graphics.setCurrent(g);
h2= h1 * t*2;
if(h2>h1)h2=h1;
for (int r = 0; r < 16; r++) {
for (int c = 0; c < 8; c++) {
float x = (w1) * (c * 2 + r % 2);
float y = (h1) * r;
g.drawImage(img3, x, y, x + w1, y + h2, x, y, x + w1, y
+ h2);
}
}
if (t > 0.5f){
h2= h1 * (t-0.5f)*2;
for (int r = 0; r < 16; r++) {
for (int c = 0; c < 8; c++) {
float x = (w1) * (c * 2 + (r+1)%2);
float y = (h1) * r;
g.drawImage(img3, x, y, x + w1, y + h2, x, y, x + w1, y
+ h2);
}
}
}
g.flush();
}
}
}