Добавил вторую главу занимательного программирования
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
|
||||
|
||||
sourceSets.main.java.srcDirs = [ "src/" ]
|
||||
|
||||
eclipse.project.name = appName + "-core"
|
||||
@@ -0,0 +1,49 @@
|
||||
package net.caraus.curtain;
|
||||
|
||||
import com.badlogic.gdx.ApplicationAdapter;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.utils.ScreenUtils;
|
||||
|
||||
public class Curtain extends ApplicationAdapter {
|
||||
SpriteBatch batch;
|
||||
Texture background;
|
||||
Texture foreground;
|
||||
TextureRegion leftRegion;
|
||||
TextureRegion rightRegion;
|
||||
int delta = 0;
|
||||
|
||||
@Override
|
||||
public void create () {
|
||||
batch = new SpriteBatch();
|
||||
background = new Texture("badlogic.bmp");
|
||||
foreground = new Texture("background2.bmp");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render () {
|
||||
ScreenUtils.clear(1, 0, 0, 1);
|
||||
|
||||
leftRegion = new TextureRegion(foreground, 128 - delta, 256);
|
||||
rightRegion = new TextureRegion(foreground, 128, 0, 128 - delta, 256);
|
||||
|
||||
batch.begin();
|
||||
batch.draw(background, 0, 0);
|
||||
|
||||
if (delta < 128) {
|
||||
batch.draw(leftRegion, 0 - delta, 0);
|
||||
batch.draw(rightRegion, 128 + delta, 0);
|
||||
}
|
||||
batch.end();
|
||||
|
||||
++delta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose () {
|
||||
batch.dispose();
|
||||
background.dispose();
|
||||
foreground.dispose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user