Newer
Older
EPQ-3D-renderer / src / Player.java
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;

public class Player {

    // image that represents the player's position on the board
    private BufferedImage image;
    // current position of the player on the board grid
    private Point3D position;
    private Point3D rotation;

    // called when the player is initialised
    public Player() {
    }

    // unused because the player should not be drawn
    // I'm leaving it in as a hint to buffered Images
    public void draw(Graphics g, ImageObserver observer) {
        int width = 100;
        int height = 100;

        BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB );

        for ( int py = 0; py < height; py++ ) {
            for ( int px = 0; px < width; px++ ) {
                // Set the pixel colour of the image n.b. x = cc, y = rc
                img.setRGB(px, py, Color.BLACK.getRGB() );
            }
        }
        g.drawImage(img, 0, 0, observer);
    }

    public void keyPressed(int key) {
        if (key == KeyEvent.VK_UP) {
        }
        if (key == KeyEvent.VK_RIGHT) {
        }
        if (key == KeyEvent.VK_DOWN) {
        }
        if (key == KeyEvent.VK_LEFT) {
        }
    }
    public void keyReleased(int key){

    }
    public void tick(Point2D mouseRel) {
        // System.out.println(mouseRel.x + " " + mouseRel.y);
        // gets called once every tick, before the repainting process happens.
    }

    // returnValue Functions
    public Point3D getPos() {
        return position;
    }
    public Point3D getRot() {
        return rotation;
    }

}