Java Code Examples for com.badlogic.gdx.utils.TimeUtils.millis()

The following are Jave code examples for showing how to use millis() of the com.badlogic.gdx.utils.TimeUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: guitar-finger-trainer   File: TrainingScreen.java   Source Code and License Vote up 6 votes
TrainingScreen(GftGame game) {
    this.game = game;

    this.guiCam = new OrthographicCamera(800, 480);
    this.guiCam.position.set(800 / 2, 480 / 2, 0);

    this.backBounds = new Rectangle(7, 432, 48, 48);
    this.playPauseBounds = new Rectangle(7, 7, 48, 48);
    this.restartBounds = new Rectangle(62, 7, 48, 48);
    this.backFowardtBounds = new Rectangle(127, 7, 48, 48);
    this.soundBounds = new Rectangle(192, 7, 48, 48);
    this.minusBounds = new Rectangle(590, 7, 48, 48);
    this.plusBounds = new Rectangle(699, 7, 48, 48);

    this.touchPoint = new Vector3();

    this.grid = new Grid(this.game);
    this.grid.loadTraining();

    this.bottomBar = new BottomBar(this.game);

    this.firstRun = 3;
    this.lastUpdateTime = TimeUtils.millis();
    this.bpm = MINUTE_IN_MILLIS / SettingsUtil.bpm;
}
 
Example 2
Project: StarshipFighters   File: BasicAlien.java   Source Code and License Vote up 6 votes
private void init() {

		// Start Shooting
		bulletCooldown = TimeUtils.millis();
		enemyBulletSpeed = 5;
		randomAttackCooldown = MathUtils.random(200, 1000);
		
		// Drop Chance | 10% chance
		dropChance = MathUtils.random(0, 9);

		// Start Sprites
		allTexture = new Texture(Gdx.files.internal(pathName));
		TextureRegion[][] tmp = TextureRegion.split(allTexture, allTexture.getWidth() / 3, allTexture.getHeight() / 1);
		rolls = new TextureRegion[3];
		for (int i = 0; i < rolls.length; i++) {
			rolls[i] = tmp[0][i];
		}

		// Start rectangle
		collisionBounds = new Rectangle(x, y, allTexture.getWidth() / 3, allTexture.getHeight());
	}
 
Example 3
Project: school-game   File: SaveData.java   Source Code and License Vote up 6 votes
/**
 * Speichert die Daten in die Spieldatei.
 *
 * @param slot der Slot in den gespeichert werden soll. Wenn null, wird der letzte Slot verwendet
 *
 * @see SaveData#load()
 */
public void save(Slot slot)
{
    if (slot == null)
        slot = this.slot;
    else
        this.slot = slot;

    if (this.slot == null) return;

    playTime += TimeUtils.timeSinceMillis(startTime);

    prefs.putString(slot.name() + PLAYER_NAME, playerName);
    prefs.putBoolean(slot.name() + MALE, male);
    prefs.putLong(slot.name() + PLAY_TIME, playTime);
    prefs.putString(slot.name() + LEVEL_NAME, levelName);
    prefs.putString(slot.name() + LEVEL_ID, levelId);
    prefs.flush();

    startTime = TimeUtils.millis();

}
 
Example 4
Project: cykacommander   File: CykaSplashScreen.java   Source Code and License Vote up 6 votes
@Override
public void render(float delta) {
    Gdx.gl.glClearColor(0.845f, 0.845f, 0.845f, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    game.batch.begin();
    game.batch.draw(appLogo, viewport.getWorldWidth()/2 - 60, viewport.getWorldHeight()/2 - 60, 120, 120);
    Color color = game.batch.getColor();
    color.a = 0.4f;
    game.batch.setColor(color);
    game.batch.draw(samukiLogo, viewport.getWorldWidth()/2-32, 32, 64, 64);
    game.batch.draw(updateText, viewport.getWorldWidth()/2-198, viewport.getWorldHeight()-100, 396, 42);
    color.a = 1f;
    game.batch.setColor(color);
    game.batch.end();

    if (TimeUtils.millis()>(startTime+1250))
        game.setScreen(new MenuScreen(game));
    stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1/30f));
    stage.draw();
}
 
Example 5
Project: TheFreeBird   File: Bird.java   Source Code and License Vote up 6 votes
private void transformFoodToEnergyAndPoop() {
    if ((TimeUtils.timeSinceMillis(timeCounterFoodTransform) > BIRD_FOOD_DIGEST_TIME) && (food > 0))
    {
        if (energy < BIRD_ENERGY_MAX){
            energy += BIRD_ENERGY_ADD;
            if (energy > BIRD_ENERGY_MAX)
                energy = BIRD_ENERGY_MAX;
        }
        if (poop < BIRD_POOP_MAX)
            poop++;
        else
            dropPoop();
        timeCounterFoodTransform = TimeUtils.millis();
        food--;
    }
}
 
Example 6
Project: TheFreeBird   File: Cat.java   Source Code and License Vote up 6 votes
public Cat(ShapeRenderer renderer, Boolean facingRight) {

        super(renderer, new Vector2(), facingRight);

        if (facingRight) {
            position.set(CAT_START_X_LEFT, CAT_Y);

            velocity.set(CAT_SPEED_X, 0f);
        }
        else{
            position.set(CAT_START_X_RIGHT, CAT_Y);
            velocity.set(-CAT_SPEED_X, 0f);
        }

        catCreateMillis = TimeUtils.millis();
        circle = new Circle(0,0, CAT_HEAD_RADIUS);
        rectangle = new Rectangle(0,0, CAT_BODY_LENGTH, CAT_BODY_WIDTH);
        update(0);
    }
 
Example 7
Project: libgdxjam   File: GameScreen.java   Source Code and License Vote up 6 votes
@Override
public void render(float delta) {
	double newTime = TimeUtils.millis() / 1000.0;
	double frameTime = Math.min(newTime - currentTime, Env.MAX_STEP);
	float deltaTime = (float)frameTime;
	
	currentTime = newTime;
	accumulator += frameTime;
	
	while (accumulator >= Env.STEP) {
		engine.getSystem(PhysicsSystem.class).setAlpha(Env.STEP / (float)accumulator);
		engine.update(deltaTime);
		accumulator -= Env.STEP;
	}
	
	engine.getSystem(RenderingSystem.class).update(Env.STEP);
}
 
Example 8
Project: origin   File: ModelManager.java   Source Code and License Vote up 6 votes
public void loadModelList()
{
	File file = Gdx.files.internal("assets/objects.json").file();
	try
	{
		ModelDesc[] list = _gson.fromJson(new FileReader(file), ModelDesc[].class);
		for (ModelDesc item : list)
		{
			item._lastUsage = TimeUtils.millis();
			_modelList.put(item._typeId, item);
		}
	}
	catch (FileNotFoundException e)
	{
		_log.error("objects config not found", e);
		System.exit(-1);
	}
}
 
Example 9
Project: NoRiskNoFun   File: DiceRollScene.java   Source Code and License Vote up 5 votes
@Override
public void render(float delta) {

    // set hasBeenShaken to true once hasShaken() registered, so the if statement
    // continues to the animation/result even if device isn't moving anymore
    if ((hasShaken() || hasBeenShaken) && canRoll) {


        // only update if it hasn't been shaken in the last 2 seconds
        if (TimeUtils.millis() - lastShakeTime > 5000) {
            diceRoll();
            lastShakeTime = TimeUtils.millis();
            hasBeenShaken = true;
        }

        // randomize results for 2 seconds after a shake
        if (TimeUtils.millis() - lastShakeTime < 2000) {
            randomizeDice();
        } else {
            showRollResult();
            hasBeenShaken = false;
            canRoll = false;
        }
    }

    super.render(delta);
}
 
Example 10
Project: Klooni1010   File: MoneyBuyBand.java   Source Code and License Vote up 5 votes
@Override
public void draw(Batch batch, float parentAlpha) {
    long now = TimeUtils.millis();
    if (now > nextTextUpdate) {
        interpolateText();
        nextTextUpdate = TimeUtils.millis() + SHOW_ONE_CHARACTER_EVERY;
        if (now > nextTempRevertUpdate && showingTemp) {
            // We won't be showing temp anymore if the current money is shown
            showCurrentMoney();
        }
    }
    setColor(Klooni.theme.bandColor);
    infoLabel.setColor(Klooni.theme.textColor);
    super.draw(batch, parentAlpha);
}
 
Example 11
Project: StarshipFighters   File: PlayState.java   Source Code and License Vote up 5 votes
@Override
public void init() {

	// Start Game Objects
	shipBullets = new Array<PlayerBullets>();
	enemyBulletList = new Array<EnemyBullets>();
	player = new Player(300, 150, 0, 0, shipBullets, this);
	basicAliens = new Array<GameObjects>();
	explosionList = new Array<Explosion>();
	itemList = new Array<Item>();
	collisionHandling = new CollisionHandling(this);

	// Start Level
	levelLoader = new Level("data/levels/testmap.tmx", this);
	for (int i = 0; i < levelLoader.getEnemyArray().size; i++) {
		basicAliens.add(new BasicAlien(levelLoader.getEnemyArray().get(i).x, levelLoader.getEnemyArray().get(i).y, 0, -5, 1000L, -15, getEnemyBulletList(), -20, this));
	}

	// Start the HUD
	// 0 = Health Bar
	allHUDElements = new HUD[1];
	allHUDElements[0] = new HealthBar(10, 760, 200, 25, true);

	// Timers
	deathTimer = TimeUtils.millis();
	
	// Audio
	soundManager = getGSM().getGame().getSoundManager();
	musicManager = getGSM().getGame().getMusicManager();

}
 
Example 12
Project: StarshipFighters   File: Level1.java   Source Code and License Vote up 5 votes
public Level1(Array<GameObjects> enemyList, int levelNumber, PlayState playState) {
	super(enemyList, playState.getExplosionList(), playState.getEnemyBulletList(), levelNumber, playState);

	// Get lists
	this.enemyList = enemyList;
	this.levelNumber = levelNumber;
	this.playState = playState;

	// Start Background
	initializeBackground();

	// Update Timer
	timeSinceLevelBegan = TimeUtils.millis();
	waveTimer = TimeUtils.millis();

	// Initialize the switches
	gameplaySwitch = new boolean[20];
	for (int i = 0; i < gameplaySwitch.length; i++) {
		gameplaySwitch[i] = false;
	}
	gameplaySwitch[0] = true;
	switchCounter = 0;

	// Start Music
	startMusic();

}
 
Example 13
Project: guitar-finger-trainer   File: TrainingScreen.java   Source Code and License Vote up 5 votes
private void applyRules() {
    if (SettingsUtil.playEnabled) {
        if (this.firstRun > 0) {
            if (TimeUtils.timeSinceMillis(this.lastUpdateTime) >= 1000) {
                AssetsUtil.playSound(AssetsUtil.clickSound);
                this.firstRun--;
                this.lastUpdateTime = TimeUtils.millis();
            }
        } else if (TimeUtils.timeSinceMillis(this.lastUpdateTime) >= this.bpm) {
            AssetsUtil.playSound(AssetsUtil.clickSound);
            this.lastUpdateTime = TimeUtils.millis();

            if (this.grid.forward) {
                this.grid.currentPosition++;
            } else {
                this.grid.currentPosition--;
            }

            if (this.grid.currentPosition == this.grid.noteSequence.length) {
                if (!SettingsUtil.backForwardEnabled) {
                    this.grid.currentPosition = 0;
                    if (SettingsUtil.autoMoveToNext) {
                        this.firstRun = 3;
                        this.grid.loadNextTraining();
                    }
                } else {
                    this.grid.currentPosition--;
                    this.grid.forward = false;
                }
            } else if (!this.grid.forward && this.grid.currentPosition == 0) {
                this.grid.forward = true;
                if (SettingsUtil.autoMoveToNext) {
                    this.firstRun = 3;
                    this.grid.loadNextTraining();
                }
            }
        }
    }
}
 
Example 14
Project: StarshipFighters   File: Player.java   Source Code and License Vote up 5 votes
public Player(float x, float y, float dx, float dy, Array<PlayerBullets> listOfBullets, PlayState playState) {
	super(x, y, dx, dy);
	
	// GamePlay
	this.x = x;
	this.y = y;
	this.dx = dx;
	this.dy = dy;
	this.listOfBullets = listOfBullets;
	this.playState = playState;
	bulletcooldown = TimeUtils.millis();

	// Graphics
	pathname = "data/spaceships/ship1.png";
	animationFrameDuration = 1f/40f;
	
	// SFX
	this.playState = playState;
	soundManager = playState.getGSM().getGame().getSoundManager();
	bulletShotSoundPathName = "data/audio/sound/Basic Shot.wav";
	bulletShotSoundName = "Shoot1";

	// Limits
	maxSpeed = 4;
	//friction = 5;
	minimumSpeed = -4;
	bulletSpeed = 15;
	bulletShootSpeed = 200;

	// Start Player Loading
	init();
	
}
 
Example 15
Project: StarshipFighters   File: SamusShipBoss.java   Source Code and License Vote up 5 votes
private void shootBullets() {
	// Shoot Bullets
	// Right Wing
	if (!isRightWingDead && rightWingHealth > 0) {
		if (TimeUtils.timeSinceMillis(bulletCooldownRight) > randomAttackCooldownRight && x < Game.WIDTH && x > 0
				&& y < Game.HEIGHT && y > 0) {
			addBossBullets(175, 0);
			randomAttackCooldownRight = MathUtils.random(200, 1000);
			bulletCooldownRight = TimeUtils.millis();
		}
	}

	// Left Wing
	if (!isLeftWingDead && leftWingHealth > 0) {
		if (TimeUtils.timeSinceMillis(bulletCooldownLeft) > randomAttackCooldownLeft && x < Game.WIDTH && x > 0
				&& y < Game.HEIGHT && y > 0) {
			addBossBullets(20, 0);
			randomAttackCooldownLeft = MathUtils.random(200, 1000);
			bulletCooldownLeft = TimeUtils.millis();
		}
	}

	// Both Wings have died
	if (isLeftWingDead && isRightWingDead && getHP() > 0) {
		if (TimeUtils.timeSinceMillis(bulletCooldown) > randomAttackCooldown && x < Game.WIDTH && x > 0
				&& y < Game.HEIGHT && y > 0) {
			addBossBullets(98, 30);
			randomAttackCooldown = MathUtils.random(200, 800);
			bulletCooldown = TimeUtils.millis();
		}
	}
}
 
Example 16
Project: StarshipFighters   File: SamusShipBoss.java   Source Code and License Vote up 5 votes
private void checkWingStatus() {
	// Check if Wings are dead
	if (rightWingHealth <= 0 && !isRightWingDead) {
		if (TimeUtils.timeSinceMillis(rightWingExplosionTimer) > 200 && rightWingExplosionCounter < 10) {
			// Add delayed explosions
			explosionList.add(new Explosion((x + 148) + MathUtils.random(-48, 48), y, 48, height, playState));
			rightWingExplosionTimer = TimeUtils.millis();
			rightWingExplosionCounter++;
		}

		// Kill Right Wing
		if (rightWingExplosionCounter == 10) {
			setRightWingDead(true);
		}
	}

	if (leftWingHealth <= 0 && !isLeftWingDead) {
		if (TimeUtils.timeSinceMillis(leftWingExplosionTimer) > 200 && leftWingExplosionCounter < 10) {
			// Add delayed explosions
			explosionList.add(new Explosion(x + MathUtils.random(-48, 48), y, 48, height, playState));
			leftWingExplosionTimer = TimeUtils.millis();
			leftWingExplosionCounter++;
		}

		// Kill Left Wing
		if (leftWingExplosionCounter == 10) {
			setLeftWingDead(true);
		}
	}

	// If Both wings are dead, then set middle to be vulnerable
	if (isLeftWingDead && isRightWingDead && isMiddleInvincible) {
		isMiddleInvincible = false;
	}
}
 
Example 17
Project: StarshipFighters   File: SamusShipBoss.java   Source Code and License Vote up 5 votes
private void checkMiddleHP() {
	if (healthbar < 0) {
		dx = 0;
		dy = 0;
		if (TimeUtils.timeSinceMillis(bossDeathExplosionTimer) > 200 && bossDeathExplosionCounter < 15) {
			// Add delayed explosions
			explosionList.add(new Explosion(x + (0.5f * MathUtils.random(0, width)),
					(y + (0.5f * MathUtils.random(0, height))), width, height, playState));
			bossDeathExplosionTimer = TimeUtils.millis();
			bossDeathExplosionCounter++;
			isDead = true;
		}
	}
}
 
Example 18
Project: StarshipFighters   File: SamusShipBoss.java   Source Code and License Vote up 5 votes
private void spawnEnemies() {
	// Check if its been 5 seconds
	if (TimeUtils.timeSinceMillis(timeSinceBattleBegan) > 5000 && healthbar > 0) {
		listOfAliens.add(new BasicAlien(x + (width / 2), y + (height / 2), 3, 0, 1000L, -15, enemyBullets, -20, playState));
		listOfAliens.add(new BasicAlien(x + (width / 2), y + (height / 2), -3, 0, 1000L, -15, enemyBullets, -20, playState));
		timeSinceBattleBegan = TimeUtils.millis();
		soundManager.playSound(bossSpawnSoundName, 1f);
	}

}
 
Example 19
Project: school-game   File: SaveData.java   Source Code and License Vote up 5 votes
/**
 * Lädt die Daten aus der Speicherdatei.
 *
 * @see SaveData#save(Slot)
 */
public void load()
{
    startTime = TimeUtils.millis();

    if (this.slot == null) return;
    
    playerName = prefs.getString(slot.name() + PLAYER_NAME, "");
    male = prefs.getBoolean(slot.name() + MALE, false);
    playTime = prefs.getLong(slot.name() + PLAY_TIME, 0);
    levelName = prefs.getString(slot.name() + LEVEL_NAME, "");
    levelId = prefs.getString(slot.name() + LEVEL_ID, "");
}
 
Example 20
Project: school-game   File: Player.java   Source Code and License Vote up 5 votes
/**
 * Regiert auf das Drücken einer Taste.
 *
 * Startet eine Attacke oder führt eine Interaktion durch.
 *
 * @param keycode der Tastencode der Taste
 * @return true, wenn auf das Ereignis reagiert wurde
 */
public boolean keyDown(int keycode)
{
    InputManager.Action action = InputManager.checkGameAction(keycode);

    if (action == InputManager.Action.ATTACK && attackSword <= 0f)
    {
        // Attacke
        attackStart = TimeUtils.millis();
        return true;
    }
    else if (action == InputManager.Action.INTERACTION && attackStart == -1)
    {
        // Interaktion
        if (interactionCallback != null)
            interactionCallback.run();

        return true;
    }
    else if (cheatManager.isHealthControlled() && action == InputManager.Action.CHEAT_DAMAGE)
    {
        applyDamage(10);
        return true;
    }
    else if (cheatManager.isHealthControlled() && action == InputManager.Action.CHEAT_HEAL)
    {
        heal(15);
        return true;
    }

    return false;
}
 
Example 21
Project: cgc-game   File: TimerManager.java   Source Code and License Vote up 5 votes
public static void setPause(boolean b)
{
	paused = b;
	if (b)
	{
		myTimer.stop();
	}
	else
	{
		myTimer.start();
		milly = TimeUtils.millis();
	}
}
 
Example 22
Project: cykacommander   File: CykaSplashScreen.java   Source Code and License Vote up 5 votes
@Override
public void show() {
    //VIEWPORT
    viewport = new FitViewport(CykaGame.SCREEN_WIDTH, CykaGame.SCREEN_HEIGHT, game.camera);
    viewport.setScaling(Scaling.stretch);
    //STAGE
    stage = new Stage(viewport,game.batch);
    Gdx.input.setInputProcessor(stage);
    samukiLogo = new Texture("samuki_logo.png");
    updateText = new Texture("update_text.png");

    startTime = TimeUtils.millis();

    final int ANIMATION_COLS = 1;
    final int ANIMATION_ROWS = 5;
    appLogoAnimation = GameBasic.spriteCutting("splash_screen_logo.png",
                        ANIMATION_COLS, ANIMATION_ROWS);
    appLogo = appLogoAnimation.getKeyFrame(0);

    Timer timer = new Timer();
    timer.scheduleTask(new Timer.Task() {
                        int a = 0;
                            @Override
                            public void run() {
                                appLogo = appLogoAnimation.getKeyFrame(a);
                                a++;
                                if(a == 5)
                                    a = 0;
                            }
                        },
            0f,
            0.111f,
            8);

}
 
Example 23
Project: Undertailor   File: UIObject.java   Source Code and License Vote up 5 votes
@Override
public boolean process() {
    if (this.destroyed) {
        return false;
    }

    if (this.lifestart < 0) {
        this.lifestart = TimeUtils.millis();
    }

    if (this.isPastLifetime()) {
        this.destroy();
        return false;
    }

    Iterator<UIComponent> iter = this.compIterator.iterator();
    while (iter.hasNext()) {
        UIComponent next = iter.next();
        if (next.isDestroyed() || next.getParent() != this) {
            iter.remove();
        } else {
            next.process();
        }
    }

    return false;
}
 
Example 24
Project: Undertailor   File: Text.java   Source Code and License Vote up 5 votes
private Text() {
    this.components = new OrderedMap<>();

    this.instantiationTime = TimeUtils.millis();
    this.stringBounds = new Pair<>(0, 0);
    this.spaceTaken = new Pair<>(-1F, -1F);
    this.transform = new Transform();

    this.m_valuePair = new Pair<>();
    this.m_drawnTransform = new Transform();
}
 
Example 25
Project: Undertailor   File: PressData.java   Source Code and License Vote up 5 votes
/**
 * Internal method.
 * 
 * <p>Updates the data of this {@link PressData} in
 * response to its assigned key being released.</p>
 */
void up() {
    this.isPressed = false;
    this.holdTime = TimeUtils.timeSinceMillis(this.holdTime);
    this.lastReleaseTick = parent.currentTick + 1;
    this.lastReleaseTime = TimeUtils.millis();
}
 
Example 26
Project: Undertailor   File: PressData.java   Source Code and License Vote up 5 votes
/**
 * Internal method.
 * 
 * <p>Updates the data of this {@link PressData} in
 * response to its assigned key being pressed.</p>
 */
void down() {
    this.isPressed = true;
    this.holdTime = TimeUtils.millis();
    this.lastPressTick = parent.currentTick + 1;
    this.lastPressTime = TimeUtils.millis();
}
 
Example 27
Project: TheFreeBird   File: Bird.java   Source Code and License Vote up 5 votes
private void loseEnergyOrDie() {
    if(TimeUtils.timeSinceMillis(timeCounterEnergyLose) > BIRD_ENERGY_LOSE_TIME){
        if(energy>0) {
            energy--;
            timeCounterEnergyLose = TimeUtils.millis();
        }
        else
            death();
    }
}
 
Example 28
Project: joe   File: StatsCollector.java   Source Code and License Vote up 5 votes
@Override
public void onGameStateChange(Game.State oldEvent, Game.State newEvent) {
    if (isRunBegin(newEvent)) {
        runStartTime = TimeUtils.millis();
    }
    if (isRunEnd(oldEvent, newEvent) && runStartTime != null) {
        if (!isLevelEnd(newEvent)) {
            dao.increment(DAO.RUN_ID_KEY);
        }

        long duration = TimeUtils.timeSinceMillis(runStartTime);
        dao.add(DAO.TOTAL_TIME_KEY, duration);
        runStartTime = null;
    }
    if (isLevelFirstRun(oldEvent, newEvent)) {
        dao.remove(DAO.RUN_ID_KEY);
        dao.remove(DAO.TOTAL_TIME_KEY);
    }
    if (isLevelEnd(newEvent)) {
        int levelId = (int)dao.getLong(DAO.LEVEL_ID_KEY, 0);
        if (levelId >= Globals.NUM_LEVELS - 1) {
            dao.remove(DAO.LEVEL_ID_KEY);
            dao.increment(DAO.ITERATION_ID_KEY);
        } else {
            dao.increment(DAO.LEVEL_ID_KEY);
        }
    }
}
 
Example 29
Project: Freaking-Math   File: freakingMath.java   Source Code and License Vote up 5 votes
@Override
public void create () {
	//batch = new SpriteBatch();
	assets=new AssetManager();
	adsTimer=TimeUtils.millis();
	loading=new Loading(this);
	
	setScreen(loading);
}
 
Example 30
Project: Freaking-Math   File: MyGame.java   Source Code and License Vote up 5 votes
void makeGameOver()
{
	
	if(sound)
		fail.play();
	stop=true;
	data();
	

	hudOver.getHighL().setText(highScore+"");
	hudOver.getScoreL().setText(score+"");
	
	Gdx.input.setInputProcessor(hudOver.getStage());
	
    hudOver.getStage().addAction(moveTo(conf.width/2-hudOver.getGameOverI().getWidth()/2,conf.height/2, 0.5f));
    
    if(TimeUtils.millis()-fm2.adsTimer>1000*60 && fm2.adsController.isWifiConnected()){
    	fm2.adsTimer=TimeUtils.millis();
    	fm2.adsController.showInterstitialAd(new Runnable() {
			
			@Override
			public void run() {
				// TODO Auto-generated method stub
				Gdx.app.exit();
			}
		});

    }
}
 
Example 31
Project: Freaking-Math   File: MyGame.java   Source Code and License Vote up 5 votes
void makeTimeOut()
{
	if(sound)
		fail.play();
	stop=true;
	data();

	hudOver.getHighL().setText(highScore+"");
	hudOver.getScoreL().setText(score+"");

	Gdx.input.setInputProcessor(hudOver.getStage());
	
    hudOver.getStage().addAction(moveTo(conf.width/2-hudOver.getGameOverI().getWidth()/2,conf.height/2, 0.5f));
    
    if(TimeUtils.millis()-fm2.adsTimer>1000*60 && fm2.adsController.isWifiConnected()){
    	fm2.adsTimer=TimeUtils.millis();
    	fm2.adsController.showInterstitialAd(new Runnable() {
			
			@Override
			public void run() {
				// TODO Auto-generated method stub
				Gdx.app.exit();
			}
		});

    }
    
}
 
Example 32
Project: cachebox3.0   File: DoubleClickListener.java   Source Code and License Vote up 5 votes
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
    if (pressed) return false;
    if (pointer == 0 && this.button != -1 && button != this.button) return false;
    pressed = true;
    pressedPointer = pointer;
    pressedButton = button;
    touchDownX = x;
    touchDownY = y;
    visualPressedTime = TimeUtils.millis() + (long) (visualPressedDuration * 1000);
    return true;
}
 
Example 33
Project: cachebox3.0   File: DoubleClickListener.java   Source Code and License Vote up 5 votes
/**
 * Returns true if a touch is over the actor or within the tap square or has been very recently. This allows the UI to show a
 * press and release that was so fast it occurred within a single frame.
 */
public boolean isVisualPressed() {
    if (pressed) return true;
    if (visualPressedTime <= 0) return false;
    if (visualPressedTime > TimeUtils.millis()) return true;
    visualPressedTime = 0;
    return false;
}
 
Example 34
Project: inari-firefly-libGDX   File: GdxTimerImpl.java   Source Code and License Vote up 5 votes
@Override
public final void tick() {
    if ( lastUpdateTime == 0 ) {
        lastUpdateTime = TimeUtils.millis();
    } else {
        long currentTime = TimeUtils.millis();
        time += timeElapsed;
        timeElapsed = currentTime - lastUpdateTime;
        lastUpdateTime = currentTime;
    }
}
 
Example 35
Project: origin   File: ModelManager.java   Source Code and License Vote up 5 votes
private void load(ModelDesc desc)
{
	if (desc._modelData == null)
	{
		desc._modelData = new ModelData(desc._model);
		_log.debug("loaded model: " + desc._model);
	}

	desc._loaded = true;
	desc._lastUsage = TimeUtils.millis();
}
 
Example 36
Project: SpaceShooter   File: SplashScreen.java   Source Code and License Vote up 5 votes
@Override
public void show() {
    SpaceShooter.logger.logDebug("Loading Splash Screen");
    batch = new SpriteBatch();
    SpaceShooter.assetManager.load("splash/laststand.png", Texture.class);
    start = TimeUtils.millis();

    new Thread(() -> {
        registerHandlers();
        SpaceShooter.logger.logDebug("Enjoying the Splash Screen");
        while (TimeUtils.millis() < (start + 5000)) {}
        SpaceShooter.logger.logDebug("Done Enjoying the Splash Screen");
        continueToMainMenu = true;
    }).start();
}
 
Example 37
Project: DigBlock   File: Player.java   Source Code and License Vote up 5 votes
public void jumpCount() {
	if(jumpReady) {
		if(TimeUtils.timeSinceMillis(jumpCount)<600) {
			jump = true;
			jumpCount = 0;
		} else {
			jumpCount = TimeUtils.millis();
		}
		jumpReady = false;
	}
	jumpTouch = true;
}
 
Example 38
Project: TTmath   File: TTmath.java   Source Code and License Vote up 5 votes
@Override
	public void create() {
        camera = new OrthoCamera();
		camera.resize();
		sb = new SpriteBatch();
//		mainMenuScreen = new MenuScreen(this, camera, sb);
//		setScreen(mainMenuScreen);
        startTime = TimeUtils.millis();
        setScreen(new SplashScreen(this, camera, sb));
	}
 
Example 39
Project: TTmath   File: SplashScreen.java   Source Code and License Vote up 5 votes
@Override
    public void show() {
        texture = TextureManager.SPLASH;
        startTime = TimeUtils.millis();

//        TextureRegion region = new TextureRegion(texture, 0, 0,
//                WIDTH, HEIGHT);
        sprite = new Sprite(texture);

        sprite.setSize(WIDTH, HEIGHT);

    }
 
Example 40
Project: TTmath   File: SplashScreen.java   Source Code and License Vote up 5 votes
@Override
    public void render(float delta) {
//        sb.setProjectionMatrix(camera.combined);
        sb.begin();
        sprite.draw(sb);
        sb.end();

        if(TimeUtils.millis() > (startTime+1000)){
            game.setScreen(new MenuScreen(game, camera, sb));
        }

    }
 
Example 41
Project: ud405   File: OrthographicCameraExercise.java   Source Code and License Vote up 5 votes
@Override
public void create() {
    renderer = new ShapeRenderer();
    timeCreated = TimeUtils.millis();

    // TODO: Initialize the camera
    camera = new OrthographicCamera();

    // TODO: Set the camera's position to the center of the circle's movement (X_CENTER, Y_CENTER)
    camera.position.set(X_CENTER, Y_CENTER, 0);
}
 
Example 42
Project: Klooni1010   File: MoneyBuyBand.java   Source Code and License Vote up 4 votes
private void setText(String text) {
    infoText = text;
    showingTemp = false;
    nextTextUpdate = TimeUtils.millis() + SHOW_ONE_CHARACTER_EVERY;
}
 
Example 43
Project: Klooni1010   File: MoneyBuyBand.java   Source Code and License Vote up 4 votes
public void setTempText(String text) {
    setText(text);
    showingTemp = true;
    nextTempRevertUpdate = TimeUtils.millis() + TEMP_TEXT_DELAY;
}
 
Example 44
Project: StarshipFighters   File: Player.java   Source Code and License Vote up 4 votes
private void addBullets(int xOffset, int yOffset) {
	listOfBullets.add(new PlayerBullets(getX() + xOffset, getY() + yOffset, 0, bulletSpeed));
	bulletcooldown = TimeUtils.millis();
}
 
Example 45
Project: StarshipFighters   File: BasicAlien.java   Source Code and License Vote up 4 votes
private void addEnemyBullets(int xOffset, int yOffset) {
	listofEnemyBullets
			.add(new EnemyBullets(getX() + xOffset, getY() + yOffset, 0, enemyBulletSpeed, damageValue, playState));
	bulletCooldown = TimeUtils.millis();
}
 
Example 46
Project: StarshipFighters   File: SamusShipBoss.java   Source Code and License Vote up 4 votes
private void init() {
	
	// Music
	musicManager = playState.getGSM().getGame().getMusicManager();
	musicManager.addMusic(bossMusic, bossMusicName);
	
	// sound
	soundManager = playState.getGSM().getGame().getSoundManager();
	soundManager.addSound(bossSoundFilePath, bossSoundName);
	soundManager.addSound(bossSpawnSoundFilePath, bossSpawnSoundName);

	// Start Graphics
	filePath = "data/spaceships/samushipboss.png";
	frameLengthTime = 1f / 2f;
	enemyBossSprite = new Animator(3, 4, filePath, 3, 4, frameLengthTime);

	// Set Wing Booleans
	isLeftWingDead = false;
	isRightWingDead = false;
	isMiddleInvincible = true;
	isDead = false;
	bossBulletDamage = -20;
	randomAttackCooldown = MathUtils.random(200, 800);
	randomAttackCooldownLeft = MathUtils.random(400, 1000);
	randomAttackCooldownRight = MathUtils.random(400, 1000);

	// HP
	leftWingHealth = 1500;
	rightWingHealth = 1500;
	healthbar = 3000;

	// Dimension Size
	width = 196;
	height = 107;

	// Hit Boxes | 0 = left, 1 = center, 2 = right
	// We should probably store the values of these numbers in an array for the
	// extra dimensions next time so we can efficiently loop it
	// Might need to find a better algorithm for this
	bossHitBoxes = new Rectangle[3];
	bossHitBoxes[0] = new Rectangle(x, y, 48, height);
	bossHitBoxes[1] = new Rectangle(x + 49, y + 27, 98, 75);
	bossHitBoxes[2] = new Rectangle(x + 148, y, 48, height);

	// Start Timer
	timeSinceBattleBegan = TimeUtils.millis();
	bulletCooldownLeft = TimeUtils.millis();
	bulletCooldownRight = TimeUtils.millis();
	leftWingExplosionTimer = TimeUtils.millis();
	rightWingExplosionTimer = TimeUtils.millis();
	bossDeathExplosionTimer = TimeUtils.millis();

	// Graphics Explosion Counter
	rightWingExplosionCounter = 0;
	leftWingExplosionCounter = 0;
	bossDeathExplosionCounter = 0;

}
 
Example 47
Project: TheFreeBird   File: Bird.java   Source Code and License Vote up 4 votes
public Bird(Vector2 position, Level level) {
    super(level.renderer, position);
    this.level = level;

    alpha = 1;

    beakB = new Vector2();
    eyeL = new Vector2();
    eyeR = new Vector2();
    tailL = new Vector2();
    tailR = new Vector2();
    wingLL = new Vector2();
    wingLB = new Vector2();
    wingLT = new Vector2();
    wingRR = new Vector2();
    wingRB = new Vector2();
    wingRT = new Vector2();

    bodyRadius = BIRD_BODY_RADIUS;
    eyeRadius = 0.7f *BIRD_SCALE;

    flying = false;
    //glyding = false;
    inNest = true;
    recalculatePoints();
    bodyCircle = new Circle(position, bodyRadius);

    food = BIRD_FOOD_MAX;
    energy = BIRD_ENERGY_MAX;
    poop = 0;

    timeCounterFoodTransform = TimeUtils.millis(); // count in Millis
    timeCounterEnergyLose = timeCounterFoodTransform;

    timeStart = TimeUtils.millis();
    timeSinceStart = 0;
    poopedCatsCounter = 0;

    landCollider = (new Vector2(position)).sub(0, BIRD_COLLIDER_OFFSET_Y);

    movingX = false;
    flyingUp = false;
}
 
Example 48
Project: libgdx-inGameConsole   File: LogEntry.java   Source Code and License Vote up 4 votes
protected LogEntry (String msg, LogLevel level) {
	this.text = msg;
	this.level = level;
	timeStamp = TimeUtils.millis();
}
 
Example 49
Project: TTmath   File: TTmath.java   Source Code and License Vote up 4 votes
@Override
public void dispose() {
    super.dispose();
    endTime = TimeUtils.millis();
}
 
Example 50
Project: ns2-scc-profiler   File: DelayedEntitySystem.java   Source Code and License Vote up 4 votes
@Override
protected void processEntities(ImmutableBag<Entity> entities) {

	if (dirty) {
		if (!prerequisitesMet()) return;
		dirty = false;
		idle = false;
		jobs.clear();
		collectJobs(entities, jobs);
	}

	// run one or multiple times, until allotted time runs out.
	long start = TimeUtils.millis();
	long now = start;

	while (now <= start + maxDuration()) {

		Job runnable = !jobs.isEmpty() ? jobs.get(0) : null;
		if (runnable != null) {
			runnable.run();
			if (runnable.isCompleted()) {
				jobs.removeFirst();
				Gdx.app.debug("Performance", "Finished " + runnable.getClass().getSimpleName() + " remaining system jobs: " + jobs.size());
			}

			long duration = TimeUtils.millis() - now;
			if ( duration > maxDuration() && duration > 25 ) {
				Gdx.app.debug("Performance", "Slice of " + runnable.getClass().getSimpleName() + " took " + duration + "ms");
			}
		}

		if (jobs.isEmpty()) {
			if (!idle) {
				postJobs();
				idle = true;
			}
			break;
		}

		now = TimeUtils.millis();
	}
}
 
Example 51
Project: Freaking-Math   File: MyGame.java   Source Code and License Vote up 3 votes
@Override
public void render(float delta) {
	// TODO Auto-generated method stub
		Gdx.gl.glClearColor(conf.color1[colorId][0]/255, conf.color1[colorId][1]/255, conf.color1[colorId][2]/255, 1.0f);
	
	Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
	
	if(start && !stop)
		timer=conf.time-(TimeUtils.millis()-startTime);
	
	if(timer<=0 && !stop)
	{
		makeTimeOut();
	}
	
	hudGame.getStage().act(delta);
	hudGame.getStage().draw();
	
	hudGame.getLabelGroupe().act(delta);
	
	
	stage.act(delta);
	stage.draw();
	
	hudOver.getStage().act(delta);
	hudOver.getStage().draw();
	
	menu.getStage().act(delta);
	menu.getStage().draw();
	
	
	
}
 
Example 52
Project: ud405   File: OrthographicCameraExercise.java   Source Code and License Vote up 3 votes
@Override
public void create() {
    renderer = new ShapeRenderer();
    timeCreated = TimeUtils.millis();

    // TODO: Initialize the camera


    // TODO: Set the camera's position to the center of the circle's movement (X_CENTER, Y_CENTER)

}