I tried to find error, but eclipse didn't show anything unusual.
I tried running it in both debug mode, and regular mode, and it just does the same thing. In debug mode when there is an error, it pauses the program, and tells me there is error in my program, but in this situation nothing happens, just closes the program.
Here's the whole class I wrote :
Code:
package javagame;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;
public class Test extends BasicGameState {
Image col;
int x, y, stepSize, filter;
Input input;
Color color;
int sMil;
double timer = 0, time;
float Red, Green, Blue;
public Test(int state) {
}
public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
gc.setVSync(true);
col = new Image("res/collision_img.png");
stepSize = 1;
}
public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {
g.setColor(color);
g.fillRect(100, 100, 50, 50);
g.drawString("Red: " + Red + "\nGreen: " + Green + "\nBlue: " + Blue, 500, 10);
}
public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException {
input = gc.getInput();
if (input.isKeyDown(Input.KEY_LEFT)) {
Red += 1;
if (Red >= 255)
Red = 255;
}
if (input.isKeyDown(Input.KEY_RIGHT)) {
Green += 1;
if (Green >= 255)
Green = 255;
}
if (input.isKeyDown(Input.KEY_UP)) {
}
if (input.isKeyDown(Input.KEY_DOWN)) {
}
if (input.isKeyPressed(Input.KEY_ESCAPE))
gc.exit();
}
public int getID() {
return 3;
}
}
I hope you'll be able to find the error, and educate me, also, earlier I posted my programs and someone told me something about states in init method, can you also explain me more about that ?