Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.badlogic.gdx.Gdx;
- import com.badlogic.gdx.graphics.g2d.SpriteBatch;
- import com.badlogic.gdx.graphics.g2d.TextureRegion;
- public class Peng extends GameObjekt {
- private TextureRegion bird;
- private float x, y;
- private boolean directionup = true;
- public float getX() {
- return x;
- }
- public float getY() {
- return y;
- }
- public Peng(TextureRegion region) {
- this.bird = region;
- }
- @Override
- public void load() {
- x = Gdx.graphics.getWidth()/2 - bird.getRegionWidth() /2;
- y = 0;
- }
- @Override
- public void update(float delta) {
- if (directionup){
- y = y + 60.0f*delta;
- if (y >= Gdx.graphics.getHeight()){
- directionup = false;
- }
- } else {
- y = y - 60.0f*delta;
- if (y <= 0){
- directionup = true;
- }
- }
- }
- @Override
- public void render(SpriteBatch batch) {
- batch.draw(bird, x, y);
- }
- @Override
- public void dispose() {
- this.dispose();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement