public FlameMain () { super("Flame"); MathUtils.random = new RandomXS128(); particleSystem = ParticleSystem.get(); effect = new ParticleEffect(); particleSystem.add(effect); assetManager = new AssetManager(); assetManager.setErrorListener(this); assetManager.setLoader(ParticleEffect.class, new ParticleEffectLoader(new InternalFileHandleResolver())); controllersData = new Array<ControllerData>(); lwjglCanvas = new LwjglCanvas(renderer = new AppRenderer()); addWindowListener(new WindowAdapter() { public void windowClosed (WindowEvent event) { //System.exit(0); Gdx.app.exit(); } }); initializeComponents(); setSize(1280, 950); setLocationRelativeTo(null); setDefaultCloseOperation(DISPOSE_ON_CLOSE); setVisible(true); }
public CaveGenerator(int x, int z, SmoothWorld smoothWorld) { this.caveStartX = x; this.caveStartY = smoothWorld.getSurfaceHeight(x, z); this.caveStartZ = z; this.smoothWorld = smoothWorld; long l = x + z + (x * (x - 1)) + (z * (z + 1)) + (long) Math.pow(x, z > 0 ? z : (z < 0 ? -z : 1)); this.numbers = new RandomXS128(smoothWorld.baseSeed, murmurHash3(smoothWorld.baseSeed + murmurHash3(l))); this.intSet = new IntSet(roomNodesMax); }
public RandomNumbers(RandomXS128 generator) { this(new RandomNumberGenerator() { @Override public long next() { return generator.nextLong(); } @Override public void getSeed(long[] seed) { seed[0] = generator.getState(0); seed[1] = generator.getState(1); } }); }
public void update(ShapeRenderer renderer, float delta) { y -= 200f * delta; if(getY() <= 0) { RandomXS128 rand = new RandomXS128(); setY(GlobalVars.height); setX(rand.nextFloat() * GlobalVars.width); } renderer.setColor(1f, 1f, 1f, 1f); renderer.rect(x, y, 1, 1); }
@Override public void write(Kryo kryo, Output output, RandomXS128 random) { output.writeLong(random.getState(0)); output.writeLong(random.getState(1)); }
@Override public RandomXS128 read(Kryo kryo, Input input, Class<RandomXS128> type) { long seed0 = input.readLong(); long seed1 = input.readLong(); return new RandomXS128(seed0, seed1); }
@Override public RandomXS128 copy (Kryo kryo, RandomXS128 original) { return new RandomXS128(original.getState(0), original.getState(1)); }
public Level(PooledEngine engine) { this.engine = engine; this.rand = new RandomXS128(); }
public GameScreen(AssetManager manager) { super("Splash", manager); // Create buttons mainStage = new Stage(new StretchViewport(GlobalVars.width, GlobalVars.height)); buttonAtlas = manager.get("gfx/ui/buttons.pack", TextureAtlas.class); buttonSkin = new Skin(buttonAtlas); Gdx.input.setInputProcessor(mainStage); ImageButtonStyle imgBtnStyle = new ImageButtonStyle(); imgBtnStyle.imageUp = buttonSkin.getDrawable("ExitButton"); ImageButton exitButton = new ImageButton(imgBtnStyle); exitButton.setPosition(GlobalVars.width - (exitButton.getWidth() + 5f), GlobalVars.height - (exitButton.getHeight() + 5f)); mainStage.addActor(exitButton); exitButton.addListener(new ChangeListener() { public void changed(ChangeEvent e, Actor a) { setNextScreen("MainMenu"); setDone(true); } }); // Setup draw stuff camera = new OrthographicCamera(GlobalVars.width, GlobalVars.height); camera.position.set(GlobalVars.width / 2, GlobalVars.height / 2, 0f); camera.update(); batch = new SpriteBatch(); spaceshipAtlas = manager.get("gfx/sprites/spaceships.pack", TextureAtlas.class); bulletAtlas = manager.get("gfx/sprites/bullets.pack", TextureAtlas.class); pickupAtlas = manager.get("gfx/sprites/pickups.pack", TextureAtlas.class); font = new BitmapFont(); font.scale(0.01f); // Create ship if(GlobalVars.ship == 0) { player = new Player(spaceshipAtlas.findRegion("bluedestroyer"), 160, 50, 1, 1000, 250, 0.5f); } else if(GlobalVars.ship == 1) { player = new Player(spaceshipAtlas.findRegion("bluecarrier"), 160, 50, 0, 2000, 250, 0.5f); } else { player = new Player(spaceshipAtlas.findRegion("bluecruiser"), 160, 50, 0, 1000, 500, 0.5f); } // Setup enemies enemies = new Enemy[NUM_ENEMIES]; for(int i = 0; i < NUM_ENEMIES; i++) { enemies[i] = null; } currentMaxEnemies = 1; currentEnemies = 0; // Setup bullets bullets = new Bullet[NUM_BULLETS]; for(int i = 0; i < NUM_BULLETS; i++) { bullets[i] = null; } // Setup pickups pickup = null; pickupTimer = 0; rapidTimer = 0; speed = false; speedTimer = 0; invTimer = 0; // Setup Particle Effects ParticleEffect explosionEffect = new ParticleEffect(); explosionEffect.load(Gdx.files.internal("gfx/particles/Explosion.p"), Gdx.files.internal("gfx/particles/")); explosionEffectPool = new ParticleEffectPool(explosionEffect, 1, 2); // Setup stars stars = new Star[NUM_STARS]; for(int i = 0; i < NUM_STARS; i++) { RandomXS128 rand = new RandomXS128(); stars[i] = new Star(rand.nextFloat() * GlobalVars.width, rand.nextFloat() * GlobalVars.height); } shapeRenderer = new ShapeRenderer(); // Setup sound laserShot = Gdx.audio.newSound(Gdx.files.internal("sfx/laser5.mp3")); explode = Gdx.audio.newSound(Gdx.files.internal("sfx/explosion.mp3")); }
private void createEnemy(int n) { RandomXS128 rand = new RandomXS128(); float xPos = rand.nextFloat() * GlobalVars.width; float type = rand.nextFloat(); if(player.getScore() < 200) { enemies[n] = new Enemy(spaceshipAtlas.findRegion("F5S1"), xPos, 480, 0, 50, 175, 1.5f, "F51"); } else if(player.getScore() < 400) { if(type < 0.8f) { enemies[n] = new Enemy(spaceshipAtlas.findRegion("F5S1"), xPos, 480, 0, 50, 175, 1.5f, "F51"); } else { enemies[n] = new Enemy(spaceshipAtlas.findRegion("F5S2"), xPos, 480, 0, 100, 175, 1.0f, "F52"); } } else if(player.getScore() < 1000) { if(type < 0.5f) { enemies[n] = new Enemy(spaceshipAtlas.findRegion("F5S1"), xPos, 480, 0, 50, 175, 1.5f, "F51"); } else if(type < 0.75f) { enemies[n] = new Enemy(spaceshipAtlas.findRegion("F5S2"), xPos, 480, 0, 100, 175, 1.0f, "F52"); } else { enemies[n] = new Enemy(spaceshipAtlas.findRegion("F5S3"), xPos, 480, 1, 75, 200, 1.0f, "F53"); } } else { if(type < 0.5f) { enemies[n] = new Enemy(spaceshipAtlas.findRegion("F5S1"), xPos, 480, 0, 50, 175, 1.5f, "F51"); } else if(type < 0.7f) { enemies[n] = new Enemy(spaceshipAtlas.findRegion("F5S2"), xPos, 480, 0, 100, 175, 1.0f, "F52"); } else if(type < 0.9f) { enemies[n] = new Enemy(spaceshipAtlas.findRegion("F5S3"), xPos, 480, 1, 100, 200, 1.0f, "F53"); } else { enemies[n] = new Enemy(spaceshipAtlas.findRegion("F5S4"), xPos, 480, 1, 300, 200, 0.75f, "F54"); } } overlapLoop: for(int i = 0; i < NUM_ENEMIES; i++) { if(i != n && enemies[i] != null) { if(enemies[n].getBoundingRectangle().overlaps(enemies[i].getBoundingRectangle())) { enemies[n] = null; break overlapLoop; } } } if(enemies[n] != null) { enemies[n].setVelY(-enemies[n].getMaxVel()); enemies[n].setShootTimer(rand.nextFloat() * enemies[n].getShootTime()); } }