Skip to content

Commit

Permalink
Merge pull request #2 from pmaasz/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
pmaasz authored Aug 1, 2018
2 parents 0fd3e60 + 7225293 commit 7e8e3f3
Show file tree
Hide file tree
Showing 31 changed files with 510 additions and 427 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.DS_Store

.idea/
File renamed without changes.
3 changes: 1 addition & 2 deletions Steve.iml → Steve/Steve.iml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

</module>
Binary file not shown.
Binary file added Steve/productions/production/Steve/Eyes.class
Binary file not shown.
Binary file added Steve/productions/production/Steve/Frame$1.class
Binary file not shown.
Binary file not shown.
Binary file added Steve/productions/production/Steve/Frame.class
Binary file not shown.
Binary file added Steve/productions/production/Steve/LeftEye.class
Binary file not shown.
Binary file added Steve/productions/production/Steve/Repo.class
Binary file not shown.
Binary file added Steve/productions/production/Steve/RightEye.class
Binary file not shown.
Binary file added Steve/productions/production/Steve/Steve.class
Binary file not shown.
43 changes: 43 additions & 0 deletions Steve/src/DrawPanel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import javax.swing.*;
import java.awt.*;

public class DrawPanel extends JPanel
{
private LeftEye leftEye;

private RightEye rightEye;

private Eyes eyes;

public DrawPanel(LeftEye leftEye, RightEye rightEye, Eyes eyes)
{
this.leftEye = leftEye;
this.rightEye = rightEye;
this.eyes = eyes;
}

public void paintComponent(Graphics g)
{
Graphics2D g2 = (Graphics2D)g;

//Background
g2.setColor(Color.BLACK);
g2.fillRect(0, 0, getWidth(), getHeight());

//Blink
if (this.eyes.isBlink())
{
g.setColor(eyes.getColor());
} else {
g.setColor(this.eyes.getColor());
}

//Left
g2.drawRoundRect(this.leftEye.getLeftXPos(),this.leftEye.getLeftYPos(), this.leftEye.getWidthleft(), this.leftEye.getHeightleft(), this.eyes.getCurve(), this.eyes.getCurve());
g2.fillRoundRect(this.leftEye.getLeftXPos(),this.leftEye.getLeftYPos(), this.leftEye.getWidthleft(), this.leftEye.getHeightleft(), this.eyes.getCurve(), this.eyes.getCurve());

//Right
g2.drawRoundRect(this.rightEye.getRightXPos(),this.rightEye.getRightYPos(), this.rightEye.getWidthright(), this.rightEye.getHeightright(), this.eyes.getCurve(), this.eyes.getCurve());
g2.fillRoundRect(this.rightEye.getRightXPos(),this.rightEye.getRightYPos(), this.rightEye.getWidthright(), this.rightEye.getHeightright(), this.eyes.getCurve(), this.eyes.getCurve());
}
}
59 changes: 59 additions & 0 deletions Steve/src/Eyes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import java.awt.*;

public class Eyes
{
private int curve = 30;

private int radius = 2;

private int counter = 0;

private boolean blink = false;

private Color color;

public Eyes()
{
this.color = new Color(10, 200, 255);
}

public Color getColor() {
return this.color;
}

public void setColor(int r , int g, int b) {
this.color = new Color(r , g, b);
}

public int getCurve() {
return curve;
}

public void setCurve(int curve) {
this.curve = curve;
}

public int getRadius() {
return radius;
}

public void setRadius(int radius) {
this.radius = radius;
}

public int getCounter() {
return counter;
}

public void setCounter(int counter) {
this.counter = counter;
}

public boolean isBlink() {
return blink;
}

public void setBlink(boolean blink) {
this.blink = blink;
}
}
115 changes: 115 additions & 0 deletions Steve/src/Frame.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import java.awt.event.*;
import javax.swing.*;

public class Frame extends JFrame
{
private double mouseX;

private double mouseY;

private boolean click;

private int counter = 0;

protected DrawPanel drawPanel;

public Frame(LeftEye leftEye, RightEye rightEye, Eyes eyes)
{
this.drawPanel = new DrawPanel(leftEye, rightEye, eyes);

add(this.drawPanel);
pack();
setSize(300,300);
setResizable(false);
setLocationRelativeTo(null);
setVisible(true);
setTitle("S.T.E.V.E.");
addMouseMotionListener(new KeyHandler());
addMouseListener(new KeyHandler());
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
}

public void repaintDrawPanel()
{
this.drawPanel.repaint();
}

public double getMouseX()
{
return mouseX;
}

public double getMouseY()
{
return mouseY;
}

public void setMouseX(double mouseX)
{
this.mouseX = mouseX;
}

public void setMouseY(double mouseY)
{
this.mouseY = mouseY;
}

public boolean isClick()
{
return click;
}

public void setClick(boolean click)
{
this.click = click;
}

public int getCounter() {
return counter;
}

public void setCounter(int counter) {
this.counter = counter;
}

private class KeyHandler implements MouseMotionListener, MouseListener
{

@Override
public void mouseDragged(MouseEvent e) { }

@Override
public void mouseMoved(MouseEvent e)
{
setMouseX(e.getX());
setMouseY(e.getY());
}

@Override
public void mouseClicked(MouseEvent e) { }

@Override
public void mousePressed(MouseEvent e)
{
setClick(true);
}

@Override
public void mouseReleased(MouseEvent e)
{
setClick(false);
}

@Override
public void mouseEntered(MouseEvent e) { }

@Override
public void mouseExited(MouseEvent e) { }
}
}
47 changes: 47 additions & 0 deletions Steve/src/LeftEye.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
public class LeftEye
{
private int leftXPos = 55;

private int leftYPos = 40;

private int widthleft = 80;

private int heightleft = 90;

public LeftEye ()
{

}

public int getLeftXPos() {
return leftXPos;
}

public void setLeftXPos(int leftXPos) {
this.leftXPos = leftXPos;
}

public int getLeftYPos() {
return leftYPos;
}

public void setLeftYPos(int leftYPos) {
this.leftYPos = leftYPos;
}

public int getWidthleft() {
return widthleft;
}

public void setWidthleft(int widthleft) {
this.widthleft = widthleft;
}

public int getHeightleft() {
return heightleft;
}

public void setHeightleft(int heightleft) {
this.heightleft = heightleft;
}
}
36 changes: 36 additions & 0 deletions Steve/src/Repo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
public class Repo
{
public void blink(Eyes eyes, Frame frame)
{
int counter = frame.getCounter();

if (!eyes.isBlink() && ((counter % 1100) == 0))
{
eyes.setBlink(true);
eyes.setColor(0,0,0);

try {
Thread.sleep(300);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
else if (counter > 1100)
{
eyes.setBlink(false);
}

counter++;
frame.setCounter(counter);
}

public void angry(Frame frame, Eyes eyes)
{
if(frame.isClick())
{
eyes.setColor(255,30,30);
} else {
eyes.setColor(10, 200, 255);
}
}
}
47 changes: 47 additions & 0 deletions Steve/src/RightEye.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
public class RightEye
{
private int rightXPos = 155;

private int rightYPos = 40;

private int widthright = 80;

private int heightright = 90;

public RightEye()
{

}

public int getRightXPos() {
return rightXPos;
}

public void setRightXPos(int rightXPos) {
this.rightXPos = rightXPos;
}

public int getRightYPos() {
return rightYPos;
}

public void setRightYPos(int rightYPos) {
this.rightYPos = rightYPos;
}

public int getWidthright() {
return widthright;
}

public void setWidthright(int widthright) {
this.widthright = widthright;
}

public int getHeightright() {
return heightright;
}

public void setHeightright(int heightright) {
this.heightright = heightright;
}
}
Loading

0 comments on commit 7e8e3f3

Please sign in to comment.