<repo_name>daf78/CatchMeIfYouCan<file_sep>/src/org/academiadecodigo/variachis/expertCoders/grid/position/Position.java
package org.academiadecodigo.variachis.expertCoders.grid.position;

import org.academiadecodigo.variachis.expertCoders.grid.Grid;


public class Position {

    private int row;
    private int col;
    private Grid grid;


    public Position(int col, int row, Grid grid) {

        this.col = col;
        this.row = row;
        this.grid = grid;
    }


    public enum Direction {
        DOWN,
        RIGHT,
        LEFT;
    }

    public void setRowZero() {
        this.row = 0;
    }

    public void setCol() {
        this.col = ((int) (Math.random() * grid.getCols()));
    }


    public void move(Direction direction) {
        switch (direction) {
            case LEFT:
                moveLeft();
                break;
            case RIGHT:
                moveRight();
                break;
            case DOWN:
                moveDown();
                break;
        }
    }


    private void moveRight() {
        this.col++;
    }

    private void moveLeft() {
        this.col--;
    }

    private void moveDown() {

        this.row++;
    }



    public boolean equals(Position position) {

        //positions plus five because item collides with grid at row 56/55
        if(this.row == position.row + 5 && this.col == position.col){
            return true;
        }
        if(this.row == position.row + 5 && this.col == position.col +1){
            return true;
        }
        if(this.row == position.row + 5 && this.col == position.col +2){
            return true;
        }
        if(this.row == position.row + 5 && this.col == position.col + 3){
            return true;
        }
        if(this.row == position.row + 5 && this.col == position.col +4){
            return true;
        }
        if(this.row == position.row + 5 && this.col == position.col +5){
            return true;
        }
        if(this.row == position.row + 5 && this.col == position.col +6){
            return true;
        }
        if(this.row == position.row + 5 && this.col == position.col +7){
            return true;
        }
        if(this.row == position.row + 5 && this.col == position.col +8){
            return true;
        }
        if(this.row == position.row + 5 && this.col == position.col -1){
            return true;
        }
        if(this.row == position.row + 5 && this.col == position.col -2){
            return true;
        }
        if(this.row == position.row + 5 && this.col == position.col -3){
            return true;
        }
        if(this.row == position.row + 5 && this.col == position.col -4){
            return true;
        }
        if(this.row == position.row + 5 && this.col == position.col -5){
            return true;
        }
        if(this.row == position.row + 5 && this.col == position.col -6){
            return true;
        }
        if(this.row == position.row + 5 && this.col == position.col -7){
            return true;
        }
        if(this.row == position.row + 5 && this.col == position.col -8){
            return true;
        }
        return false;

    }


    public int getRow() {
        return row;
    }

    public int getCol() {
        return col;
    }



    @Override
    public String toString() {
        return "Position{" +
                "row=" + row +
                ", col=" + col +
                '}';
    }
}<file_sep>/src/org/academiadecodigo/variachis/expertCoders/GameLevel.java
package org.academiadecodigo.variachis.expertCoders;

import org.academiadecodigo.simplegraphics.pictures.Picture;
import org.academiadecodigo.variachis.expertCoders.grid.Grid;
import org.academiadecodigo.variachis.expertCoders.interfaces.Drawable;

public class GameLevel implements Drawable {

    private Level actualLevel ;
    private Picture picture;

    public GameLevel() {
        actualLevel = Level.ZERO;
        picture = new Picture(Grid.PADDING, Grid.PADDING, actualLevel.pic);
    }

    @Override
    public void draw() {
        picture.load(actualLevel.getPic());
        picture.draw();
    }

    public void setActualLevel(Level actualLevel) {
        this.actualLevel = actualLevel;
    }

    public enum Level {
        ZERO("inicial_screen.jpg"),
        ONE("levelOne.jpg"),
        TWO("salinha_screen_2_salinha.jpg"),
        HELP("help.jpg"),
        OVER("gameover_screen.jpg");

        private String pic;

        Level(String pic) {
            this.pic = pic;
        }

        public String getPic() {
            return pic;
        }
    }

    public Level getActualLevel() {
        return actualLevel;
    }
}
<file_sep>/src/org/academiadecodigo/variachis/expertCoders/interfaces/Collidable.java
package org.academiadecodigo.variachis.expertCoders.interfaces;


import org.academiadecodigo.variachis.expertCoders.grid.position.Position;

public interface Collidable extends Drawable {

    boolean checkCollision(Position position);
}
<file_sep>/src/org/academiadecodigo/variachis/expertCoders/AbstractCollidable.java
package org.academiadecodigo.variachis.expertCoders;


import org.academiadecodigo.variachis.expertCoders.grid.position.Position;
import org.academiadecodigo.variachis.expertCoders.interfaces.Collidable;
import org.academiadecodigo.variachis.expertCoders.grid.position.Position.Direction;

public abstract class AbstractCollidable implements Collidable {


    private Position position;


    public AbstractCollidable(Position position) {
        this.position = position;
    }


    public Position getPosition() {
        return position;
    }

    public abstract void draw();

    protected void move(Direction direction) {
        position.move(direction);
    }

}

<file_sep>/src/org/academiadecodigo/variachis/expertCoders/item/ItemFactory.java
package org.academiadecodigo.variachis.expertCoders.item;

import org.academiadecodigo.variachis.expertCoders.grid.Grid;
import org.academiadecodigo.variachis.expertCoders.grid.position.PositionFactory;

public class ItemFactory {

    //Create new items -- random values
    public static Item getItem(Grid grid) {
        return new Item(Item.random(), PositionFactory.getItemPosition(grid));
    }

}
<file_sep>/README.md

# Catch If You Can!

some story here

## Developers
Developed @ <Academia de Código_> <br>
Created by Code Cadets:
<ul>
  <li><NAME></li>
  <li><NAME></li>
  <li><NAME></li>
  <li><NAME></li>
</ul>  

## Concepts Used
Project developed during the 4th week of Academia de Código's 18th bootcamp.
<h4> Concepts learned until now:</h4>
<ul>
  <li>Basic Javao</li>
  <li>Java Build Process</li>
  <li>Basic OOP</li>
  <li>Composition</li>
  <li>Inheritance</li>
  <li>Polymorphism</li>
  <li>Containers</li>
  <li>Nested Classes</li>
  <li>Simple Graphics Library</li>
</ul>  

## Rules && Controles


 <h4>Controls:</h4>
 
```python
<RIGHT> && <LEFT> arrows.
```
 <h4>Rules:</h4>
 
 ```
 You need to catch some good JAVA concepts that are represented as an image in the game.
 In game you can check what are the representations of the concepts and also what are the stats that they give you.
 If your levels reach a good score you will be moved into next level! 
 ```







<file_sep>/src/org/academiadecodigo/variachis/expertCoders/grid/position/PositionFactory.java
package org.academiadecodigo.variachis.expertCoders.grid.position;

import org.academiadecodigo.variachis.expertCoders.grid.Grid;

/**
 * A factory to create different positions for different items.
 */

public class PositionFactory {

    public static Position getPlayerPosition(Grid grid) {
        return new Position((grid.getCols() / 2), (grid.getRows()), grid);

    }

    public static Position getItemPosition(Grid grid) {
        int randomCol = (int) (Math.random() * (grid.getCols() * Grid.CELLSIZE));
        return new Position(randomCol - Grid.CELLSIZE, 0, grid);
    }
}
<file_sep>/src/org/academiadecodigo/variachis/expertCoders/player/Player.java
package org.academiadecodigo.variachis.expertCoders.player;

import org.academiadecodigo.simplegraphics.pictures.Picture;
import org.academiadecodigo.variachis.expertCoders.AbstractCollidable;
import org.academiadecodigo.variachis.expertCoders.grid.Grid;
import org.academiadecodigo.variachis.expertCoders.grid.position.Position;
import org.academiadecodigo.variachis.expertCoders.item.Item;

public class Player extends AbstractCollidable {

    private int knowledge = 50;
    private int fun = 50;
    private Picture playerPicture;
    private Position[] positions = new Position[4]; // TODO: 11/10/2018  


    public Player(Position position) {
        super(position);
        playerPicture = new Picture(super.getPosition().getCol() * Grid.CELLSIZE + Grid.PADDING,
                super.getPosition().getRow() * Grid.CELLSIZE + Grid.PADDING,
                "filipe.png");

    }


    @Override
    public boolean checkCollision(Position position) {

        return getPosition().equals(position);
    }

    @Override
    public void draw() {
        playerPicture.translate(-playerPicture.getWidth(), -playerPicture.getHeight());
        playerPicture.draw();

    }

    @Override
    public void move(Position.Direction direction) {
        super.move(direction);
        int dx = direction == Position.Direction.RIGHT ? 1 : -1;
        int diff = playerPicture.getX() + dx > Grid.PADDING ? dx : 0; // TODO: 11/10/2018

        playerPicture.translate(diff * Grid.CELLSIZE, 0);

    }

    public boolean gameOver(){
        return (getKnowledge() <= 0 || getFun() <= 0);
    }


    public void beingHit(Item item) {
        switch (item.getType()) {
            case CAP:
                knowledge -= 20;
                break;
            case BEER:
                fun += 20;
                break;
            case TREE:
                knowledge += 20;
                break;
            case ABSTRACTION:
                fun -= 20;
                break;
            case POLY:
                int random = ((int) (Math.random() * 4));
                switch (random){
                    case 0:
                        playerPicture.load("mestre_shorts.png");
                        playerPicture.draw();
                        break;
                    case 1:
                        playerPicture.load("sid.png");
                        playerPicture.draw();
                        break;
                    case 2:
                        playerPicture.load("filipe.png");
                        playerPicture.draw();
                        break;
                    case 3:
                        playerPicture.load("seringas.png");
                        playerPicture.draw();
                        break;
                }
                break;
        }
    }


    public boolean nextlevel(){
        return (getFun() >= 100 || getKnowledge() >= 100);
    }


    public int getFun() {
        return fun;
    }

    public int getKnowledge() {
        return knowledge;
    }


    public boolean isLeftOf(int cols) {
        return getPosition().getCol() < cols;
    }

    public boolean isRightOf(int cols) {
        return getPosition().getCol() > cols;
    }


    @Override
    public String toString() {
        return "Player{" +
                "playerPicture=" + playerPicture +
                '}';
    }
}

