Android Open Source - game-api-android Strawberry Controler






From Project

Back to project page game-api-android.

License

The source code is released under:

MIT License

If you think the Android project game-api-android 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 com.android.vissenspel;
//www.j  av a2  s.  c  o m
import android.gameengine.icadroids.alarms.*;
import android.util.Log;

/**
 * A Controler that generates strawberries Vissenkom and puts them into the game
 * randomly. Is not physically present in the game, so does not extend
 * GameObject.
 * 
 * @author Paul Bergervoet
 */

public class StrawberryControler implements IAlarm {
    private Vissenkom mygame;
    private Alarm myAlarm;

    /**
     * Create a Controler and set the first Alarm
     * 
     * @param vk
     *            reference to the game, 
     */
    public StrawberryControler(Vissenkom vk) {
  mygame = vk;
  myAlarm = new Alarm(2, 1, this);
  myAlarm.startAlarm();
    }

    /**
     * When Alarm rings, create a strawberry and add it. 
     * Set Alarm for next strawberry.
     * 
     * @see android.gameengine.icadroids.alarms.IAlarm#triggerAlarm(int)
     */
    public void triggerAlarm(int id) { // aardbei maken
  //Log.d("StrawberryControler", "Alarm gaat af");
  Strawberry s = new Strawberry(mygame);
  // world size has not been fixed, put it in a block of 600*400 pixels
  int x = 10 + (int) (570 * Math.random());
  int y = 10 + (int) (370 * Math.random());
  mygame.addGameObject(s, x, y);
  myAlarm.setTime(10 + (int) (50 * Math.random()));
  myAlarm.restartAlarm();
    }

}




Java Source Code List

android.gameengine.icadroids.alarms.Alarm.java
android.gameengine.icadroids.alarms.IAlarm.java
android.gameengine.icadroids.dashboard.DashboardImageView.java
android.gameengine.icadroids.dashboard.DashboardTextView.java
android.gameengine.icadroids.engine.GameEngine.java
android.gameengine.icadroids.engine.GameFPSCounter.java
android.gameengine.icadroids.engine.GameThread.java
android.gameengine.icadroids.engine.GameView.java
android.gameengine.icadroids.engine.Viewport.java
android.gameengine.icadroids.forms.GameForm.java
android.gameengine.icadroids.forms.IFormInput.java
android.gameengine.icadroids.forms.ViewCreator.java
android.gameengine.icadroids.forms.ViewRemover.java
android.gameengine.icadroids.input.MotionSensor.java
android.gameengine.icadroids.input.OnScreenButton.java
android.gameengine.icadroids.input.OnScreenButtons.java
android.gameengine.icadroids.input.TouchInput.java
android.gameengine.icadroids.objects.GameObject.java
android.gameengine.icadroids.objects.MoveableGameObject.java
android.gameengine.icadroids.objects.collisions.CollidingObject.java
android.gameengine.icadroids.objects.collisions.ICollision.java
android.gameengine.icadroids.objects.collisions.TileCollision.java
android.gameengine.icadroids.objects.graphics.AnimatedSprite.java
android.gameengine.icadroids.objects.graphics.Sprite.java
android.gameengine.icadroids.persistence.GamePersistence.java
android.gameengine.icadroids.sound.GameSound.java
android.gameengine.icadroids.sound.MusicPlayer.java
android.gameengine.icadroids.tiles.GameTiles.java
android.gameengine.icadroids.tiles.Tile.java
com.android.vissenspel.Monster.java
com.android.vissenspel.StrawberryControler.java
com.android.vissenspel.Strawberry.java
com.android.vissenspel.Vis.java
com.android.vissenspel.Vissenkom.java
game.MyAndroidGame.java
testGames.AndroidCraft_demo.java
testGames.FormTest.java
testGames.Player.java
testGames.TestGameBas.java
testGames.TestGameLex.java
testGames.TestGameRoel.java
testGames.gameEngineTest.DebugEngine.java
testGames.gameEngineTest.GameEngineTestGame.java
testGames.gameEngineTest.TestGameObject.java
testGames.gameEngineTest.debugObject.java
testGames.gameEngineTest.randomObject.java
testGames.testGameObjectBas.java
testGames.testGame.java