Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (707)
Games in Android Showcase (206)
games submitted by our members
Games in WIP (781)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
  JavaGaming.org - Pastebin



Author: 0AndrewShepherd0 (posted 2016-12-16 03:58:39, viewed 856 times)

1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   24   25   26   27   28   29   30   31   32   33   34   35   36   37   38   39   40   41   42   43   44   45   46   47   48   49   50   51   52   53   54   55   56   57   58   59   60   61   62   63   64   65   66   67   68   69   70   71   72   73   74   75   76   77   78   79   80   81  
package com.brovenge.junkman.object;

import java.util.Random;

import com.brovenge.junkman.Game;
import com.brovenge.junkman.HUD;
import com.brovenge.junkman.object.good.BrokenElectronics;
import com.brovenge.junkman.object.good.CandyWrapper;
import com.brovenge.junkman.object.good.Cardboard;
import com.brovenge.junkman.object.good.Paper;
import com.brovenge.junkman.object.good.WaterBottle;
import com.brovenge.junkman.object.good.Wood;

public class Spawner {

   private Handler handler;
   private HUD hud;
   private Random random = new Random();

   private boolean spawn = true;
   private boolean hasSpawned = false;
   private long startTime;
   private long endTime;

   private int scoreKeep = 0;

   public Spawner(Handler handler, HUD hud) {
      this.handler = handler;
      this.hud = hud;
   }

   public void update() {
      endTime = System.currentTimeMillis();

      scoreKeep++;

      if (scoreKeep >= 1000) {
         scoreKeep = 0;
         hud.setLevel(hud.getLevel() + 1);

         if (hud.getLevel() == 2) {
            handler.addObject(new Paper(random.nextInt(Game.width), -50, ID.Cardboard, handler));
            handler.addObject(new Cardboard(random.nextInt(Game.width), -50, ID.Cardboard, handler));
            handler.addObject(new WaterBottle(random.nextInt(Game.width), -50, ID.WaterBottle, handler));
            handler.addObject(new Wood(random.nextInt(Game.width), -50, ID.Wood, handler));
            hasSpawned = true;

            if (hasSpawned && spawn) {
               startTime = System.currentTimeMillis();
               spawn = false;
            }

            if (endTime - startTime >= 2000) {
               handler.addObject(new BrokenElectronics(random.nextInt(Game.width), -50, ID.BrokenElectronics, handler));
               handler.addObject(new CandyWrapper(random.nextInt(Game.width), -50, ID.CandyWrapper, handler));
               handler.addObject(new WaterBottle(random.nextInt(Game.width), -50, ID.WaterBottle, handler));
               handler.addObject(new Wood(random.nextInt(Game.width), -50, ID.Wood, handler));
            }
         } else if (hud.getLevel() == 3) {
         } else if (hud.getLevel() == 4) {
         } else if (hud.getLevel() == 5) {
         } else if (hud.getLevel() == 6) {
         } else if (hud.getLevel() == 7) {
         } else if (hud.getLevel() == 8) {
         } else if (hud.getLevel() == 9) {
         } else if (hud.getLevel() == 10) {
         } else if (hud.getLevel() == 11) {
         } else if (hud.getLevel() == 12) {
         } else if (hud.getLevel() == 13) {
         } else if (hud.getLevel() == 14) {
         } else if (hud.getLevel() == 15) {
         } else if (hud.getLevel() == 16) {
         } else if (hud.getLevel() == 17) {
         } else if (hud.getLevel() == 18) {
         } else if (hud.getLevel() == 19) {
         } else if (hud.getLevel() == 20) {
         }
      }
   }

}





Dump your java code here :



Special syntax:
  • To highlight a line (yellow background), prefix it with '@@'
  • To indicate that a line should be removed (red background), prefix it with '-'
  • To indicate that a line should be added (green background), prefix it with '+'
  • To post multiple snippets, seperate them by '~~~~'
  EOF
 
Galdo (228 views)
2017-01-12 13:44:09

Archive (397 views)
2017-01-02 05:31:41

0AndrewShepherd0 (855 views)
2016-12-16 03:58:39

0AndrewShepherd0 (792 views)
2016-12-15 21:50:57

Lunch (930 views)
2016-12-06 16:01:40

ral0r2 (1157 views)
2016-11-23 16:08:26

ClaasJG (1263 views)
2016-11-10 17:36:32

CoffeeChemist (1303 views)
2016-11-05 00:46:53

jay4842 (1386 views)
2016-11-01 19:04:52

theagentd (1206 views)
2016-10-24 17:51:53
List of Learning Resources
by elect
2016-09-09 09:47:55

List of Learning Resources
by elect
2016-09-08 09:47:20

List of Learning Resources
by elect
2016-09-08 09:46:51

List of Learning Resources
by elect
2016-09-08 09:46:27

List of Learning Resources
by elect
2016-09-08 09:45:41

List of Learning Resources
by elect
2016-09-08 08:39:20

List of Learning Resources
by elect
2016-09-08 08:38:19

Rendering resources
by Roquen
2016-08-08 05:55:21
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!