本文整理汇总了Java中org.newdawn.slick.GameContainer类的典型用法代码示例。如果您正苦于以下问题:Java GameContainer类的具体用法?Java GameContainer怎么用?Java GameContainer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GameContainer类属于org.newdawn.slick包,在下文中一共展示了GameContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
import org.newdawn.slick.GameContainer; //导入依赖的package包/类
public void update(GameContainer container, int delta)
throws SlickException {
if (!paused) {
ypos += delta * 0.002 * systemMove;
if (ypos > 300) {
ypos = -300;
}
if (ypos < -300) {
ypos = 300;
}
for (int i = 0; i < emitters.size(); i++) {
((ConfigurableEmitter) emitters.get(i)).replayCheck();
}
for (int i = 0; i < delta; i++) {
system.update(1);
}
}
Display.sync(100);
}
示例2: init
import org.newdawn.slick.GameContainer; //导入依赖的package包/类
/**
* @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
*/
public void init(GameContainer container) throws SlickException {
this.container = container;
sheet = new PackedSpriteSheet("testdata/testpack.def", Image.FILTER_NEAREST);
rocket = sheet.getSprite("rocket");
SpriteSheet anim = sheet.getSpriteSheet("runner");
runner = new Animation();
for (int y=0;y<2;y++) {
for (int x=0;x<6;x++) {
runner.addFrame(anim.getSprite(x,y), 50);
}
}
}
示例3: render
import org.newdawn.slick.GameContainer; //导入依赖的package包/类
/**
* @see org.newdawn.slick.Game#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
*/
public void render(GameContainer container, Graphics g) {
g.setColor(Color.white);
String text = "This is UnicodeFont!\nIt rockz. Kerning: T,";
unicodeFont.drawString(10, 33, text);
// unicodeFont.drawString(10, 33, text, Color.red, 8, 19);
g.setColor(Color.red);
g.drawRect(10, 33, unicodeFont.getWidth(text), unicodeFont.getLineHeight());
g.setColor(Color.blue);
int yOffset = unicodeFont.getYOffset(text);
g.drawRect(10, 33 + yOffset, unicodeFont.getWidth(text), unicodeFont.getHeight(text) - yOffset);
// font.drawString(10, 73, "\u6880\u6881\u6882 (...) \u6883\u6884\u6885\u6886\u6887 hi?");
unicodeFont.addGlyphs("[email protected]!#!#$%___--");
// Cypriot Syllabary glyphs (Everson Mono font): \uD802\uDC02\uD802\uDC03\uD802\uDC12 == 0x10802, 0x10803, s0x10812
// g.drawLine(0, container.getHeight() - 512, container.getWidth(), container.getHeight() - 512);
}
示例4: render
import org.newdawn.slick.GameContainer; //导入依赖的package包/类
/**
* @see org.newdawn.slick.BasicGame#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
*/
public void render(GameContainer container, Graphics g) {
if (nextResource != null) {
g.drawString("Loading: "+nextResource.getDescription(), 100, 100);
}
int total = LoadingList.get().getTotalResources();
int loaded = LoadingList.get().getTotalResources() - LoadingList.get().getRemainingResources();
float bar = loaded / (float) total;
g.fillRect(100,150,loaded*40,20);
g.drawRect(100,150,total*40,20);
if (started) {
image.draw(100,200);
font.drawString(100,500,"LOADING COMPLETE");
}
}
示例5: render
import org.newdawn.slick.GameContainer; //导入依赖的package包/类
/**
* @see org.newdawn.slick.Game#render(org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
*/
public void render(GameContainer container, Graphics g) throws SlickException {
g.scale(zoom,zoom);
g.translate(x, y);
g.scale(0.3f,0.3f);
//renderer[0].render(g);
g.scale(1/0.3f,1/0.3f);
g.translate(400, 0);
//renderer[1].render(g);
g.translate(100, 300);
g.scale(0.7f,0.7f);
//renderer[2].render(g);
g.scale(1/0.7f,1/0.7f);
g.scale(0.5f,0.5f);
g.translate(-1100, -380);
renderer[3].render(g);
g.scale(1/0.5f,1/0.5f);
// g.translate(280, 100);
// g.scale(0.5f,0.5f);
// renderer[4].render(g);
g.resetTransform();
}
示例6: StateBasedGame
import org.newdawn.slick.GameContainer; //导入依赖的package包/类
/**
* Create a new state based game
*
* @param name The name of the game
*/
public StateBasedGame(String name) {
this.title = name;
currentState = new BasicGameState() {
public int getID() {
return -1;
}
public void init(GameContainer container, StateBasedGame game) throws SlickException {
}
public void render(StateBasedGame game, Graphics g) throws SlickException {
}
public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException {
}
public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException {
}
};
}
示例7: reset
import org.newdawn.slick.GameContainer; //导入依赖的package包/类
public void reset(GameContainer gc) throws SlickException{
time = 0L;
accu = 0L;
consoleTimer = 0L;
Globals.player.reset();
entities.clear();
entities.put("enemyController", new EnemyController());
gameStarted = false;
paused = false;
consoleOpen = false;
console = new Console(this, gc);
hud = new HUD();
}
示例8: init
import org.newdawn.slick.GameContainer; //导入依赖的package包/类
/**
* @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
*/
public void init(GameContainer container) throws SlickException {
this.container = container;
image = new Image("testdata/logo.tga", true);
Image temp = new Image("testdata/palette_tool.png");
container.setMouseCursor(temp, 0, 0);
container.setIcons(new String[] {"testdata/icon.tga"});
container.setTargetFrameRate(100);
poly = new Polygon();
float len = 100;
for (int x=0;x<360;x+=30) {
if (len == 100) {
len = 50;
} else {
len = 100;
}
poly.addPoint((float) FastTrig.cos(Math.toRadians(x)) * len,
(float) FastTrig.sin(Math.toRadians(x)) * len);
}
}
示例9: init
import org.newdawn.slick.GameContainer; //导入依赖的package包/类
public void init(GameContainer container) throws SlickException {
// detect what endian we have
if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) {
endian = "Big endian";
} else if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
endian = "Little endian";
} else
endian = "no idea";
redImageBuffer = new ImageBuffer(100,100);
fillImageBufferWithColor(redImageBuffer, Color.red, 100, 100);
blueImageBuffer = new ImageBuffer(100,100);
fillImageBufferWithColor(blueImageBuffer, Color.blue, 100, 100);
fromRed = redImageBuffer.getImage();
fromBlue = blueImageBuffer.getImage();
}
示例10: showPauseButton
import org.newdawn.slick.GameContainer; //导入依赖的package包/类
/**
* Draw Pause button
* @param gc GameContainer
* @param g Graphics
* @throws SlickException
*/
public static void showPauseButton(GameContainer gc, Graphics g) throws SlickException {
pauseButton.draw(pauseButtonPosX, pauseButtonPosY, pauseButtonWidth, pauseButtonHeight);
if (Controller.mouseInArea(pauseButtonPosX, pauseButtonPosY, pauseButtonPosX + pauseButtonHeight,
pauseButtonPosY + pauseButtonHeight)) {
pauseButton.draw(pauseButtonPosX, pauseButtonPosY, pauseButtonWidth, pauseButtonHeight, new Color(0, 0, 0, 50));
if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
gc.setPaused(!gc.isPaused());
try {
TimeUnit.MILLISECONDS.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
示例11: preRender
import org.newdawn.slick.GameContainer; //导入依赖的package包/类
/**
* @see org.newdawn.slick.state.transition.Transition#preRender(org.newdawn.slick.state.StateBasedGame, org.newdawn.slick.GameContainer, org.newdawn.slick.Graphics)
*/
public void preRender(StateBasedGame game, GameContainer container,
Graphics g) throws SlickException {
if (moveBackDone) {
g.translate(xp1,yp1);
g.scale(scale1, scale1);
g.setClip((int) xp1,(int) yp1,(int) (scale1*container.getWidth()),(int) (scale1*container.getHeight()));
prev.render(container, game, g);
g.resetTransform();
g.clearClip();
}
g.translate(xp2,yp2);
g.scale(scale2, scale2);
g.setClip((int) xp2,(int) yp2,(int) (scale2*container.getWidth()),(int) (scale2*container.getHeight()));
}
示例12: init
import org.newdawn.slick.GameContainer; //导入依赖的package包/类
/**
* @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
*/
public void init(GameContainer container) throws SlickException {
this.container = container;
try {
fire = ParticleIO.loadConfiguredSystem("testdata/system.xml");
} catch (IOException e) {
throw new SlickException("Failed to load particle systems", e);
}
copy = new Image(400,300);
String[] formats = ImageOut.getSupportedFormats();
message = "Formats supported: ";
for (int i=0;i<formats.length;i++) {
message += formats[i];
if (i < formats.length - 1) {
message += ",";
}
}
}
示例13: init
import org.newdawn.slick.GameContainer; //导入依赖的package包/类
/**
* @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
*/
public void init(GameContainer container) throws SlickException {
this.container = container;
SpriteSheet sheet = new SpriteSheet("testdata/homeranim.png", 36, 65);
animation = new Animation();
for (int i=0;i<8;i++) {
animation.addFrame(sheet.getSprite(i,0), 150);
}
limited = new Animation();
for (int i=0;i<8;i++) {
limited.addFrame(sheet.getSprite(i,0), 150);
}
limited.stopAt(7);
manual = new Animation(false);
for (int i=0;i<8;i++) {
manual.addFrame(sheet.getSprite(i,0), 150);
}
pingPong = new Animation(sheet, 0,0,7,0,true,150,true);
pingPong.setPingPong(true);
container.getGraphics().setBackground(new Color(0.4f,0.6f,0.6f));
}
示例14: init
import org.newdawn.slick.GameContainer; //导入依赖的package包/类
/**
* @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
*/
public void init(GameContainer container) throws SlickException {
SoundStore.get().setMaxSources(32);
myContainer = container;
sound = new Sound("testdata/restart.ogg");
charlie = new Sound("testdata/cbrown01.wav");
try {
engine = AudioLoader.getAudio("WAV", ResourceLoader.getResourceAsStream("testdata/engine.wav"));
} catch (IOException e) {
throw new SlickException("Failed to load engine", e);
}
music = musica = new Music("testdata/SMB-X.XM");
//music = musica = new Music("testdata/theme.ogg", true);
musicb = new Music("testdata/kirby.ogg", true);
burp = new Sound("testdata/burp.aif");
music.play();
}
示例15: init
import org.newdawn.slick.GameContainer; //导入依赖的package包/类
@Override
public void init(GameContainer container) throws SlickException {
this.container = container;
this.map = new TiledMap("/home/enzo/newmap.tmx");
SpriteSheet spriteSheet = new SpriteSheet("/home/enzo/SpriteSheetAnim.png", 64, 64);
this.animations[0] = loadAnimation(spriteSheet, 0, 1, 0);
this.animations[1] = loadAnimation(spriteSheet, 0, 1, 1);
this.animations[2] = loadAnimation(spriteSheet, 0, 1, 2);
this.animations[3] = loadAnimation(spriteSheet, 0, 1, 3);
this.animations[4] = loadAnimation(spriteSheet, 1, 9, 0);
this.animations[5] = loadAnimation(spriteSheet, 1, 9, 1);
this.animations[6] = loadAnimation(spriteSheet, 1, 9, 2);
this.animations[7] = loadAnimation(spriteSheet, 1, 9, 3);
Font font = new Font("Verdana", Font.BOLD, 20);
UnicodeFont uFont = new UnicodeFont(font, font.getSize(), font.isBold(), font.isItalic());
nameInput = new TextField(container, uFont, 150,20,500,35, new ComponentListener()
{
public void componentActivated(AbstractComponent source) {
message = "Entered1: "+nameInput.getText();
nameInput.setFocus(true);
}
});
// ComponentListener listener = new ComponentListener();
// TextField nameInput = new TextField(arg0, truetypefont, 150,20,500,35, listener);
//
// {
// public void componentActivated(AbstractComponent source) {
// System.out.println("Entered1: "+nameInput.getText());
// }
// });
}