Roll to Dodge - Altered
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Count to a Million

+3
Megaprr
BAM Blind And Mad
The Silent Watcher
7 posters

Page 17 of 40 Previous  1 ... 10 ... 16, 17, 18 ... 28 ... 40  Next

Go down

Count to a Million - Page 17 Empty Re: Count to a Million

Post  The Dark King Mon May 21, 2012 4:53 pm

411, you found Pacman.... in Java?
The Dark King
The Dark King
Creative Director

Posts : 1009
Join date : 2012-01-15
Location : Does it really matter?

Back to top Go down

Count to a Million - Page 17 Empty Re: Count to a Million

Post  BAM Blind And Mad Mon May 21, 2012 9:48 pm

412. indead, I also found this but it needs some tweaking

Code:


package org.newdawn.spaceinvaders;

import java.awt.Canvas;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferStrategy;
import java.util.ArrayList;

import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 * The main hook of our game. This class with both act as a manager
 * for the display and central mediator for the game logic.
 *
 * Display management will consist of a loop that cycles round all
 * entities in the game asking them to move and then drawing them
 * in the appropriate place. With the help of an inner class it
 * will also allow the player to control the main ship.
 *
 * As a mediator it will be informed when entities within our game
 * detect events (e.g. alient killed, played died) and will take
 * appropriate game actions.
 *
 * @author Kevin Glass
 */
public class Game extends Canvas {
   /** The stragey that allows us to use accelerate page flipping */
   private BufferStrategy strategy;
   /** True if the game is currently "running", i.e. the game loop is looping */
   private boolean gameRunning = true;
   /** The list of all the entities that exist in our game */
   private ArrayList entities = new ArrayList();
   /** The list of entities that need to be removed from the game this loop */
   private ArrayList removeList = new ArrayList();
   /** The entity representing the player */
   private Entity ship;
   /** The speed at which the player's ship should move (pixels/sec) */
   private double moveSpeed = 300;
   /** The time at which last fired a shot */
   private long lastFire = 0;
   /** The interval between our players shot (ms) */
   private long firingInterval = 500;
   /** The number of aliens left on the screen */
   private int alienCount;
   
   /** The message to display which waiting for a key press */
   private String message = "";
   /** True if we're holding up game play until a key has been pressed */
   private boolean waitingForKeyPress = true;
   /** True if the left cursor key is currently pressed */
   private boolean leftPressed = false;
   /** True if the right cursor key is currently pressed */
   private boolean rightPressed = false;
   /** True if we are firing */
   private boolean firePressed = false;
   /** True if game logic needs to be applied this loop, normally as a result of a game event */
   private boolean logicRequiredThisLoop = false;
   
   /**
    * Construct our game and set it running.
    */
   public Game() {
      // create a frame to contain our game
      JFrame container = new JFrame("Space Invaders 101");
      
      // get hold the content of the frame and set up the resolution of the game
      JPanel panel = (JPanel) container.getContentPane();
      panel.setPreferredSize(new Dimension(800,600));
      panel.setLayout(null);
      
      // setup our canvas size and put it into the content of the frame
      setBounds(0,0,800,600);
      panel.add(this);
      
      // Tell AWT not to bother repainting our canvas since we're
      // going to do that our self in accelerated mode
      setIgnoreRepaint(true);
      
      // finally make the window visible
      container.pack();
      container.setResizable(false);
      container.setVisible(true);
      
      // add a listener to respond to the user closing the window. If they
      // do we'd like to exit the game
      container.addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
            System.exit(0);
         }
      });
      
      // add a key input system (defined below) to our canvas
      // so we can respond to key pressed
      addKeyListener(new KeyInputHandler());
      
      // request the focus so key events come to us
      requestFocus();

      // create the buffering strategy which will allow AWT
      // to manage our accelerated graphics
      createBufferStrategy(2);
      strategy = getBufferStrategy();
      
      // initialise the entities in our game so there's something
      // to see at startup
      initEntities();
   }
   
   /**
    * Start a fresh game, this should clear out any old data and
    * create a new set.
    */
   private void startGame() {
      // clear out any existing entities and intialise a new set
      entities.clear();
      initEntities();
      
      // blank out any keyboard settings we might currently have
      leftPressed = false;
      rightPressed = false;
      firePressed = false;
   }
   
   /**
    * Initialise the starting state of the entities (ship and aliens). Each
    * entitiy will be added to the overall list of entities in the game.
    */
   private void initEntities() {
      // create the player ship and place it roughly in the center of the screen
      ship = new ShipEntity(this,"sprites/ship.gif",370,550);
      entities.add(ship);
      
      // create a block of aliens (5 rows, by 12 aliens, spaced evenly)
      alienCount = 0;
      for (int row=0;row<5;row++) {
         for (int x=0;x<12;x++) {
            Entity alien = new AlienEntity(this,"sprites/alien.gif",100+(x*50),(50)+row*30);
            entities.add(alien);
            alienCount++;
         }
      }
   }
   
   /**
    * Notification from a game entity that the logic of the game
    * should be run at the next opportunity (normally as a result of some
    * game event)
    */
   public void updateLogic() {
      logicRequiredThisLoop = true;
   }
   
   /**
    * Remove an entity from the game. The entity removed will
    * no longer move or be drawn.
    *
    * @param entity The entity that should be removed
    */
   public void removeEntity(Entity entity) {
      removeList.add(entity);
   }
   
   /**
    * Notification that the player has died.
    */
   public void notifyDeath() {
      message = "Oh no! They got you, try again?";
      waitingForKeyPress = true;
   }
   
   /**
    * Notification that the player has won since all the aliens
    * are dead.
    */
   public void notifyWin() {
      message = "Well done! You Win!";
      waitingForKeyPress = true;
   }
   
   /**
    * Notification that an alien has been killed
    */
   public void notifyAlienKilled() {
      // reduce the alient count, if there are none left, the player has won!
      alienCount--;
      
      if (alienCount == 0) {
         notifyWin();
      }
      
      // if there are still some aliens left then they all need to get faster, so
      // speed up all the existing aliens
      for (int i=0;i<entities.size();i++) {
         Entity entity = (Entity) entities.get(i);
         
         if (entity instanceof AlienEntity) {
            // speed up by 2%
            entity.setHorizontalMovement(entity.getHorizontalMovement() * 1.02);
         }
      }
   }
   
   /**
    * Attempt to fire a shot from the player. Its called "try"
    * since we must first check that the player can fire at this
    * point, i.e. has he/she waited long enough between shots
    */
   public void tryToFire() {
      // check that we have waiting long enough to fire
      if (System.currentTimeMillis() - lastFire < firingInterval) {
         return;
      }
      
      // if we waited long enough, create the shot entity, and record the time.
      lastFire = System.currentTimeMillis();
      ShotEntity shot = new ShotEntity(this,"sprites/shot.gif",ship.getX()+10,ship.getY()-30);
      entities.add(shot);
   }
   
   /**
    * The main game loop. This loop is running during all game
    * play as is responsible for the following activities:
    * <p>
    * - Working out the speed of the game loop to update moves
    * - Moving the game entities
    * - Drawing the screen contents (entities, text)
    * - Updating game events
    * - Checking Input
    * <p>
    */
   public void gameLoop() {
      long lastLoopTime = System.currentTimeMillis();
      
      // keep looping round til the game ends
      while (gameRunning) {
         // work out how long its been since the last update, this
         // will be used to calculate how far the entities should
         // move this loop
         long delta = System.currentTimeMillis() - lastLoopTime;
         lastLoopTime = System.currentTimeMillis();
         
         // Get hold of a graphics context for the accelerated
         // surface and blank it out
         Graphics2D g = (Graphics2D) strategy.getDrawGraphics();
         g.setColor(Color.black);
         g.fillRect(0,0,800,600);
         
         // cycle round asking each entity to move itself
         if (!waitingForKeyPress) {
            for (int i=0;i<entities.size();i++) {
               Entity entity = (Entity) entities.get(i);
               
               entity.move(delta);
            }
         }
         
         // cycle round drawing all the entities we have in the game
         for (int i=0;i<entities.size();i++) {
            Entity entity = (Entity) entities.get(i);
            
            entity.draw(g);
         }
         
         // brute force collisions, compare every entity against
         // every other entity. If any of them collide notify
         // both entities that the collision has occured
         for (int p=0;p<entities.size();p++) {
            for (int s=p+1;s<entities.size();s++) {
               Entity me = (Entity) entities.get(p);
               Entity him = (Entity) entities.get(s);
               
               if (me.collidesWith(him)) {
                  me.collidedWith(him);
                  him.collidedWith(me);
               }
            }
         }
         
         // remove any entity that has been marked for clear up
         entities.removeAll(removeList);
         removeList.clear();

         // if a game event has indicated that game logic should
         // be resolved, cycle round every entity requesting that
         // their personal logic should be considered.
         if (logicRequiredThisLoop) {
            for (int i=0;i<entities.size();i++) {
               Entity entity = (Entity) entities.get(i);
               entity.doLogic();
            }
            
            logicRequiredThisLoop = false;
         }
         
         // if we're waiting for an "any key" press then draw the
         // current message
         if (waitingForKeyPress) {
            g.setColor(Color.white);
            g.drawString(message,(800-g.getFontMetrics().stringWidth(message))/2,250);
            g.drawString("Press any key",(800-g.getFontMetrics().stringWidth("Press any key"))/2,300);
         }
         
         // finally, we've completed drawing so clear up the graphics
         // and flip the buffer over
         g.dispose();
         strategy.show();
         
         // resolve the movement of the ship. First assume the ship
         // isn't moving. If either cursor key is pressed then
         // update the movement appropraitely
         ship.setHorizontalMovement(0);
         
         if ((leftPressed) && (!rightPressed)) {
            ship.setHorizontalMovement(-moveSpeed);
         } else if ((rightPressed) && (!leftPressed)) {
            ship.setHorizontalMovement(moveSpeed);
         }
         
         // if we're pressing fire, attempt to fire
         if (firePressed) {
            tryToFire();
         }
         
         // finally pause for a bit. Note: this should run us at about
         // 100 fps but on windows this might vary each loop due to
         // a bad implementation of timer
         try { Thread.sleep(10); } catch (Exception e) {}
      }
   }
   
   /**
    * A class to handle keyboard input from the user. The class
    * handles both dynamic input during game play, i.e. left/right
    * and shoot, and more static type input (i.e. press any key to
    * continue)
    *
    * This has been implemented as an inner class more through
    * habbit then anything else. Its perfectly normal to implement
    * this as seperate class if slight less convienient.
    *
    * @author Kevin Glass
    */
   private class KeyInputHandler extends KeyAdapter {
      /** The number of key presses we've had while waiting for an "any key" press */
      private int pressCount = 1;
      
      /**
       * Notification from AWT that a key has been pressed. Note that
       * a key being pressed is equal to being pushed down but *NOT*
       * released. Thats where keyTyped() comes in.
       *
       * @param e The details of the key that was pressed
       */
      public void keyPressed(KeyEvent e) {
         // if we're waiting for an "any key" typed then we don't
         // want to do anything with just a "press"
         if (waitingForKeyPress) {
            return;
         }
         
         
         if (e.getKeyCode() == KeyEvent.VK_LEFT) {
            leftPressed = true;
         }
         if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
            rightPressed = true;
         }
         if (e.getKeyCode() == KeyEvent.VK_SPACE) {
            firePressed = true;
         }
      }
      
      /**
       * Notification from AWT that a key has been released.
       *
       * @param e The details of the key that was released
       */
      public void keyReleased(KeyEvent e) {
         // if we're waiting for an "any key" typed then we don't
         // want to do anything with just a "released"
         if (waitingForKeyPress) {
            return;
         }
         
         if (e.getKeyCode() == KeyEvent.VK_LEFT) {
            leftPressed = false;
         }
         if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
            rightPressed = false;
         }
         if (e.getKeyCode() == KeyEvent.VK_SPACE) {
            firePressed = false;
         }
      }

      /**
       * Notification from AWT that a key has been typed. Note that
       * typing a key means to both press and then release it.
       *
       * @param e The details of the key that was typed.
       */
      public void keyTyped(KeyEvent e) {
         // if we're waiting for a "any key" type then
         // check if we've recieved any recently. We may
         // have had a keyType() event from the user releasing
         // the shoot or move keys, hence the use of the "pressCount"
         // counter.
         if (waitingForKeyPress) {
            if (pressCount == 1) {
               // since we've now recieved our key typed
               // event we can mark it as such and start
               // our new game
               waitingForKeyPress = false;
               startGame();
               pressCount = 0;
            } else {
               pressCount++;
            }
         }
         
         // if we hit escape, then quit the game
         if (e.getKeyChar() == 27) {
            System.exit(0);
         }
      }
   }
   
   /**
    * The entry point into the game. We'll simply create an
    * instance of class which will start the display and game
    * loop.
    *
    * @param argv The arguments that are passed into our game
    */
   public static void main(String argv[]) {
      Game g =new Game();

      // Start the main game loop, note: this method will not
      // return until the game has finished running. Hence we are
      // using the actual main thread to run the game.
      g.gameLoop();
   }
}


Code:


package org.newdawn.spaceinvaders;

import java.awt.GraphicsConfiguration;
import java.awt.GraphicsEnvironment;
import java.awt.Image;
import java.awt.Transparency;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;
import java.util.HashMap;

import javax.imageio.ImageIO;

/**
 * A resource manager for sprites in the game. Its often quite important
 * how and where you get your game resources from. In most cases
 * it makes sense to have a central resource loader that goes away, gets
 * your resources and caches them for future use.
 * <p>
 * [singleton]
 * <p>
 * @author Kevin Glass
 */
public class SpriteStore {
   /** The single instance of this class */
   private static SpriteStore single = new SpriteStore();
   
   /**
    * Get the single instance of this class
    *
    * @return The single instance of this class
    */
   public static SpriteStore get() {
      return single;
   }
   
   /** The cached sprite map, from reference to sprite instance */
   private HashMap sprites = new HashMap();
   
   /**
    * Retrieve a sprite from the store
    *
    * @param ref The reference to the image to use for the sprite
    * @return A sprite instance containing an accelerate image of the request reference
    */
   public Sprite getSprite(String ref) {
      // if we've already got the sprite in the cache
      // then just return the existing version
      if (sprites.get(ref) != null) {
         return (Sprite) sprites.get(ref);
      }
      
      // otherwise, go away and grab the sprite from the resource
      // loader
      BufferedImage sourceImage = null;
      
      try {
         // The ClassLoader.getResource() ensures we get the sprite
         // from the appropriate place, this helps with deploying the game
         // with things like webstart. You could equally do a file look
         // up here.
         URL url = this.getClass().getClassLoader().getResource(ref);
         
         if (url == null) {
            fail("Can't find ref: "+ref);
         }
         
         // use ImageIO to read the image in
         sourceImage = ImageIO.read(url);
      } catch (IOException e) {
         fail("Failed to load: "+ref);
      }
      
      // create an accelerated image of the right size to store our sprite in
      GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
      Image image = gc.createCompatibleImage(sourceImage.getWidth(),sourceImage.getHeight(),Transparency.BITMASK);
      
      // draw our source image into the accelerated image
      image.getGraphics().drawImage(sourceImage,0,0,null);
      
      // create a sprite, add it the cache then return it
      Sprite sprite = new Sprite(image);
      sprites.put(ref,sprite);
      
      return sprite;
   }
   
   /**
    * Utility method to handle resource loading failure
    *
    * @param message The message to display on failure
    */
   private void fail(String message) {
      // we'n't available
      // we dump the message and exit the game
      System.err.println(message);
      System.exit(0);
   }
}


Code:


package org.newdawn.spaceinvaders;

import java.awt.Graphics;
import java.awt.Image;

/**
 * A sprite to be displayed on the screen. Note that a sprite
 * contains no state information, i.e. its just the image and
 * not the location. This allows us to use a single sprite in
 * lots of different places without having to store multiple
 * copies of the image.
 *
 * @author Kevin Glass
 */
public class Sprite {
   /** The image to be drawn for this sprite */
   private Image image;
   
   /**
    * Create a new sprite based on an image
    *
    * @param image The image that is this sprite
    */
   public Sprite(Image image) {
      this.image = image;
   }
   
   /**
    * Get the width of the drawn sprite
    *
    * @return The width in pixels of this sprite
    */
   public int getWidth() {
      return image.getWidth(null);
   }

   /**
    * Get the height of the drawn sprite
    *
    * @return The height in pixels of this sprite
    */
   public int getHeight() {
      return image.getHeight(null);
   }
   
   /**
    * Draw the sprite onto the graphics context provided
    *
    * @param g The graphics context on which to draw the sprite
    * @param x The x location at which to draw the sprite
    * @param y The y location at which to draw the sprite
    */
   public void draw(Graphics g,int x,int y) {
      g.drawImage(image,x,y,null);
   }
}


Code:


package org.newdawn.spaceinvaders;

import java.awt.Graphics;
import java.awt.Rectangle;

/**
 * An entity represents any element that appears in the game. The
 * entity is responsible for resolving collisions and movement
 * based on a set of properties defined either by subclass or externally.
 *
 * Note that doubles are used for positions. This may seem strange
 * given that pixels locations are integers. However, using double means
 * that an entity can move a partial pixel. It doesn't of course mean that
 * they will be display half way through a pixel but allows us not lose
 * accuracy as we move.
 *
 * @author Kevin Glass
 */
public abstract class Entity {
   /** The current x location of this entity */
   protected double x;
   /** The current y location of this entity */
   protected double y;
   /** The sprite that represents this entity */
   protected Sprite sprite;
   /** The current speed of this entity horizontally (pixels/sec) */
   protected double dx;
   /** The current speed of this entity vertically (pixels/sec) */
   protected double dy;
   /** The rectangle used for this entity during collisions  resolution */
   private Rectangle me = new Rectangle();
   /** The rectangle used for other entities during collision resolution */
   private Rectangle him = new Rectangle();
   
   /**
    * Construct a entity based on a sprite image and a location.
    *
    * @param ref The reference to the image to be displayed for this entity
     * @param x The initial x location of this entity
    * @param y The initial y location of this entity
    */
   public Entity(String ref,int x,int y) {
      this.sprite = SpriteStore.get().getSprite(ref);
      this.x = x;
      this.y = y;
   }
   
   /**
    * Request that this entity move itself based on a certain ammount
    * of time passing.
    *
    * @param delta The ammount of time that has passed in milliseconds
    */
   public void move(long delta) {
      // update the location of the entity based on move speeds
      x += (delta * dx) / 1000;
      y += (delta * dy) / 1000;
   }
   
   /**
    * Set the horizontal speed of this entity
    *
    * @param dx The horizontal speed of this entity (pixels/sec)
    */
   public void setHorizontalMovement(double dx) {
      this.dx = dx;
   }

   /**
    * Set the vertical speed of this entity
    *
    * @param dx The vertical speed of this entity (pixels/sec)
    */
   public void setVerticalMovement(double dy) {
      this.dy = dy;
   }
   
   /**
    * Get the horizontal speed of this entity
    *
    * @return The horizontal speed of this entity (pixels/sec)
    */
   public double getHorizontalMovement() {
      return dx;
   }

   /**
    * Get the vertical speed of this entity
    *
    * @return The vertical speed of this entity (pixels/sec)
    */
   public double getVerticalMovement() {
      return dy;
   }
   
   /**
    * Draw this entity to the graphics context provided
    *
    * @param g The graphics context on which to draw
    */
   public void draw(Graphics g) {
      sprite.draw(g,(int) x,(int) y);
   }
   
   /**
    * Do the logic associated with this entity. This method
    * will be called periodically based on game events
    */
   public void doLogic() {
   }
   
   /**
    * Get the x location of this entity
    *
    * @return The x location of this entity
    */
   public int getX() {
      return (int) x;
   }

   /**
    * Get the y location of this entity
    *
    * @return The y location of this entity
    */
   public int getY() {
      return (int) y;
   }
   
   /**
    * Check if this entity collised with another.
    *
    * @param other The other entity to check collision against
    * @return True if the entities collide with each other
    */
   public boolean collidesWith(Entity other) {
      me.setBounds((int) x,(int) y,sprite.getWidth(),sprite.getHeight());
      him.setBounds((int) other.x,(int) other.y,other.sprite.getWidth(),other.sprite.getHeight());

      return me.intersects(him);
   }
   
   /**
    * Notification that this entity collided with another.
    *
    * @param other The entity with which this entity collided.
    */
   public abstract void collidedWith(Entity other);
}


Code:


package org.newdawn.spaceinvaders;

/**
 * The entity that represents the players ship
 *
 * @author Kevin Glass
 */
public class ShipEntity extends Entity {
   /** The game in which the ship exists */
   private Game game;
   
   /**
    * Create a new entity to represent the players ship
    * 
    * @param game The game in which the ship is being created
    * @param ref The reference to the sprite to show for the ship
    * @param x The initial x location of the player's ship
    * @param y The initial y location of the player's ship
    */
   public ShipEntity(Game game,String ref,int x,int y) {
      super(ref,x,y);
      
      this.game = game;
   }
   
   /**
    * Request that the ship move itself based on an elapsed ammount of
    * time
    *
    * @param delta The time that has elapsed since last move (ms)
    */
   public void move(long delta) {
      // if we're moving left and have reached the left hand side
      // of the screen, don't move
      if ((dx < 0) && (x < 10)) {
         return;
      }
      // if we're moving right and have reached the right hand side
      // of the screen, don't move
      if ((dx > 0) && (x > 750)) {
         return;
      }
      
      super.move(delta);
   }
   
   /**
    * Notification that the player's ship has collided with something
    *
    * @param other The entity with which the ship has collided
    */
   public void collidedWith(Entity other) {
      // if its an alien, notify the game that the player
      // is dead
      if (other instanceof AlienEntity) {
         game.notifyDeath();
      }
   }
}


Code:


package org.newdawn.spaceinvaders;

/**
 * An entity representing a shot fired by the player's ship
 *
 * @author Kevin Glass
 */
public class ShotEntity extends Entity {
   /** The vertical speed at which the players shot moves */
   private double moveSpeed = -300;
   /** The game in which this entity exists */
   private Game game;
   /** True if this shot has been "used", i.e. its hit something */
   private boolean used = false;
   
   /**
    * Create a new shot from the player
    *
    * @param game The game in which the shot has been created
    * @param sprite The sprite representing this shot
    * @param x The initial x location of the shot
    * @param y The initial y location of the shot
    */
   public ShotEntity(Game game,String sprite,int x,int y) {
      super(sprite,x,y);
      
      this.game = game;
      
      dy = moveSpeed;
   }

   /**
    * Request that this shot moved based on time elapsed
    *
    * @param delta The time that has elapsed since last move
    */
   public void move(long delta) {
      // proceed with normal move
      super.move(delta);
      
      // if we shot off the screen, remove ourselfs
      if (y < -100) {
         game.removeEntity(this);
      }
   }
   
   /**
    * Notification that this shot has collided with another
    * entity
    *
    * @parma other The other entity with which we've collided
    */
   public void collidedWith(Entity other) {
      // prevents double kills, if we've already hit something,
      // don't collide
      if (used) {
         return;
      }
      
      // if we've hit an alien, kill it!
      if (other instanceof AlienEntity) {
         // remove the affected entities
         game.removeEntity(this);
         game.removeEntity(other);
         
         // notify the game that the alien has been killed
         game.notifyAlienKilled();
         used = true;
      }
   }
}


Code:


package org.newdawn.spaceinvaders;

/**
 * An entity which represents one of our space invader aliens.
 *
 * @author Kevin Glass
 */
public class AlienEntity extends Entity {
   /** The speed at which the alient moves horizontally */
   private double moveSpeed = 75;
   /** The game in which the entity exists */
   private Game game;
   
   /**
    * Create a new alien entity
    *
    * @param game The game in which this entity is being created
    * @param ref The sprite which should be displayed for this alien
    * @param x The intial x location of this alien
    * @param y The intial y location of this alient
    */
   public AlienEntity(Game game,String ref,int x,int y) {
      super(ref,x,y);
      
      this.game = game;
      dx = -moveSpeed;
   }

   /**
    * Request that this alien moved based on time elapsed
    *
    * @param delta The time that has elapsed since last move
    */
   public void move(long delta) {
      // if we have reached the left hand side of the screen and
      // are moving left then request a logic update
      if ((dx < 0) && (x < 10)) {
         game.updateLogic();
      }
      // and vice vesa, if we have reached the right hand side of
      // the screen and are moving right, request a logic update
      if ((dx > 0) && (x > 750)) {
         game.updateLogic();
      }
      
      // proceed with normal move
      super.move(delta);
   }
   
   /**
    * Update the game logic related to aliens
    */
   public void doLogic() {
      // swap over horizontal movement and move down the
      // screen a bit
      dx = -dx;
      y += 10;
      
      // if we've reached the bottom of the screen then the player
      // dies
      if (y > 570) {
         game.notifyDeath();
      }
   }
   
   /**
    * Notification that this alien has collided with another entity
    *
    * @param other The other entity
    */
   public void collidedWith(Entity other) {
      // collisions with aliens are handled elsewhere
   }
}


know what game it is?
BAM Blind And Mad
BAM Blind And Mad
Head Technician

Posts : 762
Join date : 2012-01-16
Age : 29
Location : Where I am

http://www.rolltododge.net78.net

Back to top Go down

Count to a Million - Page 17 Empty Re: Count to a Million

Post  The Dark King Tue May 22, 2012 5:16 pm

413, Space Invaders?
The Dark King
The Dark King
Creative Director

Posts : 1009
Join date : 2012-01-15
Location : Does it really matter?

Back to top Go down

Count to a Million - Page 17 Empty Re: Count to a Million

Post  BAM Blind And Mad Tue May 22, 2012 8:58 pm

414. correct and do you think you can de math this

Code:
 
      for (int i = 0; i < 360; i++)
      {
          double t = i / 360.0;
          s.addPoint((int) (150 + 50 * t * Math.cos(8 * t * Math.PI)),
            (int) (150 + 50 * t * Math.sin(8 * t * Math.PI)));
    }

Code:

addPoint
public void addPoint(int x,
                    int y)Appends the specified coordinates to this Polygon.
If an operation that calculates the bounding box of this Polygon has already been performed, such as getBounds or contains, then this method updates the bounding box.


Parameters:
x - the specified x coordinate
y - the specified y coordinate
See Also:
getBounds(), contains(java.awt.Point)

--------------------------------------------------------------------------------
BAM Blind And Mad
BAM Blind And Mad
Head Technician

Posts : 762
Join date : 2012-01-16
Age : 29
Location : Where I am

http://www.rolltododge.net78.net

Back to top Go down

Count to a Million - Page 17 Empty Re: Count to a Million

Post  The Dark King Tue May 22, 2012 9:20 pm

415, not really, from what I saw. It makes little sense to me. All I got out of it was that I am bad at coding. Sorry.
The Dark King
The Dark King
Creative Director

Posts : 1009
Join date : 2012-01-15
Location : Does it really matter?

Back to top Go down

Count to a Million - Page 17 Empty Re: Count to a Million

Post  BAM Blind And Mad Tue May 22, 2012 11:56 pm

416. thanks for trying anyways
BAM Blind And Mad
BAM Blind And Mad
Head Technician

Posts : 762
Join date : 2012-01-16
Age : 29
Location : Where I am

http://www.rolltododge.net78.net

Back to top Go down

Count to a Million - Page 17 Empty Re: Count to a Million

Post  The Dark King Wed May 23, 2012 4:58 pm

417, eh, no big deal.

By the way, ME3 event was announced.

Community Goal: Promote 50,000 characters
Squad Goal: Promote 3 characters

Squad goal results in Commendation Pack, Community Goal results in Victory pack, WHICH HAS A HIGH CHANCE OF RARE WEAPONS.

All 6 classes level 20, going to promote Soldier, Engineer, and Sentinel. Smile
The Dark King
The Dark King
Creative Director

Posts : 1009
Join date : 2012-01-15
Location : Does it really matter?

Back to top Go down

Count to a Million - Page 17 Empty Re: Count to a Million

Post  BAM Blind And Mad Thu May 24, 2012 10:01 pm

BAM Blind And Mad
BAM Blind And Mad
Head Technician

Posts : 762
Join date : 2012-01-16
Age : 29
Location : Where I am

http://www.rolltododge.net78.net

Back to top Go down

Count to a Million - Page 17 Empty Re: Count to a Million

Post  The Dark King Fri May 25, 2012 11:26 am

419, so glad its the long weekend. Smile
The Dark King
The Dark King
Creative Director

Posts : 1009
Join date : 2012-01-15
Location : Does it really matter?

Back to top Go down

Count to a Million - Page 17 Empty Re: Count to a Million

Post  BAM Blind And Mad Fri May 25, 2012 7:56 pm

420. well of course thats my number but well can't help that but..

well something to read when you board on the interwebs

http://www.makeuseof.com/tag/6-apps-zombie-lover-ios-device-ios/
http://main.makeuseoflimited.netdna-cdn.com/tech-fun/wp-content/uploads/2012/05/lotr.png?54b313
BAM Blind And Mad
BAM Blind And Mad
Head Technician

Posts : 762
Join date : 2012-01-16
Age : 29
Location : Where I am

http://www.rolltododge.net78.net

Back to top Go down

Count to a Million - Page 17 Empty Re: Count to a Million

Post  The Dark King Sat May 26, 2012 12:40 pm

421. That. Was. Awesome.
The Dark King
The Dark King
Creative Director

Posts : 1009
Join date : 2012-01-15
Location : Does it really matter?

Back to top Go down

Count to a Million - Page 17 Empty Re: Count to a Million

Post  Megaprr Sun May 27, 2012 12:43 pm

422. anyone know who DwarvenMayhem is?
Megaprr
Megaprr
Moderator

Posts : 376
Join date : 2012-01-17
Age : 2023
Location : SPARTAAAAAAAAAAAAAAAAA

Back to top Go down

Count to a Million - Page 17 Empty Re: Count to a Million

Post  The Dark King Sun May 27, 2012 12:54 pm

423, yeah, you met him actually.
The Dark King
The Dark King
Creative Director

Posts : 1009
Join date : 2012-01-15
Location : Does it really matter?

Back to top Go down

Count to a Million - Page 17 Empty Re: Count to a Million

Post  BAM Blind And Mad Sun May 27, 2012 6:02 pm

BAM Blind And Mad
BAM Blind And Mad
Head Technician

Posts : 762
Join date : 2012-01-16
Age : 29
Location : Where I am

http://www.rolltododge.net78.net

Back to top Go down

Count to a Million - Page 17 Empty Re: Count to a Million

Post  The Dark King Sun May 27, 2012 6:45 pm

425, those are awesome. Great finds.
The Dark King
The Dark King
Creative Director

Posts : 1009
Join date : 2012-01-15
Location : Does it really matter?

Back to top Go down

Count to a Million - Page 17 Empty Re: Count to a Million

Post  BAM Blind And Mad Mon May 28, 2012 5:09 pm

426. going to go program mostly cause have nothing to do
BAM Blind And Mad
BAM Blind And Mad
Head Technician

Posts : 762
Join date : 2012-01-16
Age : 29
Location : Where I am

http://www.rolltododge.net78.net

Back to top Go down

Count to a Million - Page 17 Empty Re: Count to a Million

Post  The Dark King Mon May 28, 2012 5:19 pm

427, ME3 bug fixed for negative recoil. Smile Revenant time!
The Dark King
The Dark King
Creative Director

Posts : 1009
Join date : 2012-01-15
Location : Does it really matter?

Back to top Go down

Count to a Million - Page 17 Empty Re: Count to a Million

Post  BAM Blind And Mad Tue May 29, 2012 5:10 pm

428. tring to figure out internet name for programming projects going to start to post places for other people to test to see what poeple think.
BAM Blind And Mad
BAM Blind And Mad
Head Technician

Posts : 762
Join date : 2012-01-16
Age : 29
Location : Where I am

http://www.rolltododge.net78.net

Back to top Go down

Count to a Million - Page 17 Empty Re: Count to a Million

Post  The Dark King Tue May 29, 2012 6:26 pm

429, just spent 50 minutes trying to copy/move a file. Not happy at console right now.
The Dark King
The Dark King
Creative Director

Posts : 1009
Join date : 2012-01-15
Location : Does it really matter?

Back to top Go down

Count to a Million - Page 17 Empty Re: Count to a Million

Post  BAM Blind And Mad Tue May 29, 2012 10:39 pm

430. what file? was it the ME3 DLC? if so f#$%!!! if not well than I look like an idiot... what one moment that implies that I don't any other time so I suppose the proper statment would be I look like an idiot still.
BAM Blind And Mad
BAM Blind And Mad
Head Technician

Posts : 762
Join date : 2012-01-16
Age : 29
Location : Where I am

http://www.rolltododge.net78.net

Back to top Go down

Count to a Million - Page 17 Empty Re: Count to a Million

Post  The Dark King Wed May 30, 2012 5:00 pm

431, yes, yes it was.
The Dark King
The Dark King
Creative Director

Posts : 1009
Join date : 2012-01-15
Location : Does it really matter?

Back to top Go down

Count to a Million - Page 17 Empty Re: Count to a Million

Post  BAM Blind And Mad Wed May 30, 2012 5:01 pm

432. d@#$ it have 2 more nights of cadets f@#$!!!!!!!!
BAM Blind And Mad
BAM Blind And Mad
Head Technician

Posts : 762
Join date : 2012-01-16
Age : 29
Location : Where I am

http://www.rolltododge.net78.net

Back to top Go down

Count to a Million - Page 17 Empty Re: Count to a Million

Post  The Dark King Wed May 30, 2012 5:30 pm

433, want Borderlands 2 so badly. Sad
The Dark King
The Dark King
Creative Director

Posts : 1009
Join date : 2012-01-15
Location : Does it really matter?

Back to top Go down

Count to a Million - Page 17 Empty Re: Count to a Million

Post  BAM Blind And Mad Thu May 31, 2012 7:18 pm



Last edited by BAM Blind And Mad on Sat Jun 02, 2012 5:27 pm; edited 1 time in total
BAM Blind And Mad
BAM Blind And Mad
Head Technician

Posts : 762
Join date : 2012-01-16
Age : 29
Location : Where I am

http://www.rolltododge.net78.net

Back to top Go down

Count to a Million - Page 17 Empty Re: Count to a Million

Post  Blackstar88 Thu May 31, 2012 10:23 pm

435. Oh god that is disturbing but I thought there was a rule against explicit content bam and then following the rules you should be instantly banned no questions asked
Blackstar88
Blackstar88
Bad Speller

Posts : 271
Join date : 2012-01-16
Age : 129
Location : Dark forest

Back to top Go down

Count to a Million - Page 17 Empty Re: Count to a Million

Post  Sponsored content


Sponsored content


Back to top Go down

Page 17 of 40 Previous  1 ... 10 ... 16, 17, 18 ... 28 ... 40  Next

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum