Refactoring ClearButton. Made by drawing CircleHitbox. Need to finish doing HitboxCircleRenderingFunction and saving hitboxCircle when you put the second point
This commit is contained in:
@ -3,24 +3,62 @@ package gui.render;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class HitboxCircleRenderingFunction implements ShapeRenderingFunction {
|
||||
import model.Entity;
|
||||
import model.HitboxCircle;
|
||||
import model.Point;
|
||||
|
||||
public class HitboxCircleRenderingFunction implements ShapeRenderingFunction {
|
||||
Point firstIsoPoint = null;
|
||||
Point currentIsoPoint = new Point(0,0);
|
||||
int currentRadius=0;
|
||||
Entity entity;
|
||||
|
||||
public void setEntityInHitboxCircle(Entity e) {
|
||||
entity = e;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawing(Graphics2D g) {
|
||||
// TODO Auto-generated method stub
|
||||
HitboxCircle nowHitbox = (HitboxCircle)entity.getHitbox();
|
||||
if(nowHitbox.getRadius()!=0) {
|
||||
g.drawOval((int)nowHitbox.getCurrentRefPoint().x, (int)nowHitbox.getCurrentRefPoint().y, (int)nowHitbox.getRadius()*2, (int)nowHitbox.getRadius());
|
||||
}else if(firstIsoPoint != null) {
|
||||
currentRadius = Math.abs((int)firstIsoPoint.x-(int)currentIsoPoint.x);
|
||||
g.drawOval((int)firstIsoPoint.x, (int)firstIsoPoint.y, currentRadius, currentRadius/2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
HitboxCircle nowHitbox = (HitboxCircle)entity.getHitbox();
|
||||
if(nowHitbox.getRadius()==0 && firstIsoPoint == null) {
|
||||
firstIsoPoint = new Point(e.getX(), e.getY());
|
||||
}else if(nowHitbox.getRadius()==0 && firstIsoPoint != null) {
|
||||
// высчитываем в параметры хитбокссеркла нужный радиус и текущую реф поинт.
|
||||
// Не забываем высчитать реф поинт хитбокса относительно текущей.
|
||||
// после чего вызываем listPointsToString и нотифай, который отправляет данные на сохранение
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
currentIsoPoint.x = e.getX();
|
||||
currentIsoPoint.y = e.getY();
|
||||
}
|
||||
|
||||
public void functionClearHitboxJButton() {
|
||||
HitboxCircle nowHitbox = (HitboxCircle)entity.getHitbox();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void functionClearJButton() {
|
||||
firstIsoPoint = null;
|
||||
currentIsoPoint = new Point(0,0);
|
||||
currentRadius = 0;
|
||||
HitboxCircle nowhitbox = (HitboxCircle)entity.getHitbox();
|
||||
nowhitbox.setRadius(0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user