/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package brokensnake;

import java.awt.Rectangle;
import java.util.Random;

/**
 *
 * @author Zemlaynin
 */
public class Enemy
{
 public static int TYPE_GROW = 0;
 public static int TYPE_REDUCE = 1;
 public static int TYPE_SPEED = 2;
 Rectangle r;
 int xShift = 0;
 int yShift = 0;
 int counter = 0;
 int swithTime =1000;
 int lifeCycle =0;
 int speed;
 int type = 0;
 public Enemy(int lvl)
 {
  this.speed = lvl;
  this.swithTime = 100/lvl;
  Random rnd = new Random();
  this.type = rnd.nextInt(3);
  r = new Rectangle(rnd.nextInt(790),rnd.nextInt(790), 10+lvl, 10+lvl);
  
 }
 
 public void shift()
 {
  counter++;
  lifeCycle++;
  
  if(counter > swithTime)
  {
   Random rnd = new Random();
      counter = 0;
  switch (rnd.nextInt(8))
  {

   case 0:
    yShift = -speed;
    xShift = 0;
    break;
   case 1:
    yShift = speed;
    xShift = 0;
    break;
   case 2:
    yShift = 0;
    xShift = -speed;
    break;
   case 3:
    yShift = 0;
    xShift = speed;
    break;

   case 4:
    yShift = -speed;
    xShift = -speed;
   break;
   case 5:
    yShift = -speed;
    xShift = speed;
   break;
   case 6:
    yShift = speed;
    xShift = speed;
   break;
   case 7:
    yShift = speed;
    xShift = -speed;
   break;
  
  }
  }
  r.translate(xShift, yShift);
  
  if(r.x>800-r.width) xShift = -speed;
  if(r.x<0) xShift = speed;
  
  if(r.y>800-r.height) yShift = -speed;
  if(r.y<0) yShift = speed;
  
 }
 
 public Rectangle getRect()
 {
  return r;
 }

 public int getType()
 {
  return type;
 }
 
 public int getLifeCicles()
 {
  return lifeCycle;
 }
 
 
}
