Android Open Source - ConnectedSpace Star






From Project

Back to project page ConnectedSpace.

License

The source code is released under:

Copyright (c) 2015, Shreyas Raman <skraman1999@gmail.com>.

If you think the Android project ConnectedSpace listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package me.shreyasr.connected.entities;
//w  w  w . ja v  a 2 s .c  o  m
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

public class Star {

    Sprite sprite;
    double x = 0;
    double y = -1;
    double z = 0;

    public Star() {
        sprite = new Sprite(new Texture("star.png"));
        y = 2*Math.random()*Gdx.graphics.getHeight();
        x = Math.random()*Gdx.graphics.getWidth();
        z = -(int)(4+Math.random()*5);
    }

    public void render(SpriteBatch batch) {
        y += z;
        if (y < 0) {
            x = Math.random()*Gdx.graphics.getWidth();
            z = -(int)(4+Math.random()*5);
            y = (Math.random()+1)*Gdx.graphics.getHeight();
        }
        sprite.setPosition((float)x, (float)y);
        sprite.draw(batch);
    }
}




Java Source Code List

me.shreyasr.connected.ConnectedSpace.java
me.shreyasr.connected.android.AndroidLauncher.java
me.shreyasr.connected.android.activity.ClientListAdapter.java
me.shreyasr.connected.android.activity.LobbyActivity.java
me.shreyasr.connected.android.networking.BroadcastListenerThread.java
me.shreyasr.connected.android.networking.ConnectionThread.java
me.shreyasr.connected.android.networking.HeartbeatThread.java
me.shreyasr.connected.android.networking.LobbyManager.java
me.shreyasr.connected.android.networking.ServerSocketThread.java
me.shreyasr.connected.android.util.AndroidAddressUtils.java
me.shreyasr.connected.android.util.Client.java
me.shreyasr.connected.desktop.DesktopLauncher.java
me.shreyasr.connected.entities.Laser.java
me.shreyasr.connected.entities.Star.java
me.shreyasr.connected.network.NetworkHandler.java
me.shreyasr.connected.util.MathHelper.java
me.shreyasr.connected.util.SpriteSheet.java