101 Commits
Author SHA1 Message Date
Remco 73300b3cc1 iets 2015-04-08 23:21:46 +02:00
Remco a8660820e3 disabled editting while watching simulation 2015-04-08 23:21:10 +02:00
Remco 2eb2d0825c nieuwe shit 2015-04-08 16:39:23 +02:00
Yorick 547ebfbf6a Merge branch 'develop' of https://github.com/ProjectgroepA4/FestivalPlanner into develop 2015-04-08 16:13:48 +02:00
Yorick d75016f9a9 FOLLOW WAYPOINT WOO 2015-04-08 16:13:28 +02:00
Remco 13ab1900d2 Added Cancel button 2015-04-08 15:57:55 +02:00
Remco 7ffc00110f Added PathPopup 2015-04-08 15:46:19 +02:00
Yorick fc16b4c019 kut remco 2015-04-08 15:37:11 +02:00
Yorick ab91a7f1aa Merge branch 'develop' of https://github.com/ProjectgroepA4/FestivalPlanner into develop 2015-04-08 15:12:49 +02:00
Yorick 07b083453c Follow waypoints added 2015-04-08 15:12:33 +02:00
Remco 867486f6ad bugfix WayPoint 2015-04-08 14:47:49 +02:00
Yorick a82809c959 Merge branch 'develop' of https://github.com/ProjectgroepA4/FestivalPlanner into develop 2015-04-08 14:46:11 +02:00
Yorick f571189849 kaas 2015-04-08 14:46:08 +02:00
Remco 7c66edad14 WayPoint popup edited 2015-04-08 14:35:46 +02:00
Yorick a6eb4578da Merge banaan dev 2015-04-08 14:27:19 +02:00
Yorick 420e596590 Waypoint kaas 2015-04-08 14:22:01 +02:00
Yorick a03463442c Merge guus dev 2015-04-08 13:24:41 +02:00
Yorick 9066d0212f icons 2015-04-08 13:14:52 +02:00
Yorick 1e5d95733f Merge kenneth dev 2015-04-08 13:11:22 +02:00
Yorick e1f88aba2d Waypointpopup 2015-04-08 12:59:49 +02:00
kennyboy55 4e277e7d5f Added new keyboard controls 2015-04-08 12:55:51 +02:00
kennyboy55 9cce659329 Added new textures 2015-04-08 12:55:38 +02:00
kennyboy55 3d0324e80b Fixed focus 2015-04-08 12:55:07 +02:00
Yorick 2dcdc954ae Merge remote-tracking branch 'origin/kenneth' into develop 2015-04-08 12:43:11 +02:00
Yorick ad62094ee7 Working 2015-04-08 12:42:12 +02:00
kennyboy55 0c9d41585c Attempt to fix focus problem. Fixed path selection 2015-04-08 11:48:29 +02:00
Yorick 701f2aed4b merge kenneth dev 2015-04-08 11:22:01 +02:00
Yorick e31b44d43f Merge branch 'develop' of https://github.com/ProjectgroepA4/FestivalPlanner into develop 2015-04-08 11:18:41 +02:00
Yorick 82a94ba456 Started with waypoints 2015-04-08 11:18:30 +02:00
kennyboy55 2a8ff8e29a Entrance now snaps to side. 2015-04-08 11:18:25 +02:00
kennyboy55 33bb880018 Fixed scale 2015-04-08 10:55:23 +02:00
kennyboy55 a164f7b781 Improved Agenda module 2015-04-08 10:55:16 +02:00
Remco 8ed04d356a Added new Waypoint sprite
Als ie niet goed is moet je het zeggen
2015-04-08 10:29:42 +02:00
Yorick 1f6811332e Visitors following paths..sort of.. 2015-04-07 22:01:07 +02:00
Yorick f2c1544d71 merge banaan dev 2015-04-07 19:35:38 +02:00
Yorick 32de28204c halverwege 2015-04-07 19:32:10 +02:00
kennyboy55 0c59eb5dd3 Stuff 2015-04-07 16:11:20 +02:00
Yorick d6b511bab5 Merge guus dev 2015-04-07 15:30:17 +02:00
Yorick d60924a05b Merge banaan dev 2015-04-07 15:22:28 +02:00
Yorick ad4eacc20c kaas 2015-04-07 15:06:20 +02:00
Yorick 284823c28b hi 2015-04-07 14:49:00 +02:00
Yorick 41b4c5db8f Added several thingz 2015-04-07 14:31:44 +02:00
Yorick cba61d4dc5 Merge guus dev 2015-04-07 13:59:34 +02:00
kennyboy55 050493a70b Try to fix camera zoom motion. Needs attention 2015-04-07 13:58:29 +02:00
Yorick 5a0def924a Merge branch 'develop' of https://github.com/ProjectgroepA4/FestivalPlanner into develop 2015-04-07 13:13:00 +02:00
Yorick ea7ecfcd56 Saven werkt van guus 2015-04-07 13:12:02 +02:00
kennyboy55 2d56ac1b89 Added Control Panel and improved Properties Panel. 2015-04-07 13:05:13 +02:00
xrgman 1684976a47 fixed nullpointer 2015-04-07 12:13:40 +02:00
Yorick 5a9c3f259a oops 2015-04-07 12:12:42 +02:00
Yorick 3920354ae2 Kaas 2015-04-07 12:00:04 +02:00
Remco bcbc9b1027 kaas 2015-04-07 11:58:32 +02:00
Yorick 6f58084554 Merge kenneth en develop 2015-04-07 11:55:55 +02:00
Yorick c8c1d85eba Merge banaan en develop 2015-04-07 11:35:05 +02:00
kennyboy55 a138807c2a Fixed collision and updated to WCS (Wesley Code Standard) 2015-04-06 16:44:21 +02:00
kennyboy55 fe5a8a5c2d Improved code structure. 2015-04-06 16:28:14 +02:00
kennyboy55 24790d8d19 Added area in Objects and made new panel for changing them. 2015-04-06 16:27:49 +02:00
kennyboy55 7e5c09da58 Starting with area 2015-04-06 15:31:21 +02:00
Remco 30192ec4aa Added Sprite Visitor 2015-04-06 11:39:10 +02:00
kennyboy55 65cd07af6f Removing useless stuff 2015-04-04 11:02:05 +02:00
Yorick df8fdd803b Merged banaan and develop 2015-03-24 09:58:21 +01:00
Yorick 8131464be7 SCrolling limited woo 2015-03-17 14:12:39 +01:00
Yorick d0c92db9f7 STAGE 4 2015-03-17 13:41:01 +01:00
Yorick f289bec571 KAas 2015-03-17 13:39:16 +01:00
Yorick 6dec40e70a Woo 2015-03-17 13:28:01 +01:00
kennyboy55 c21af8db1a Fixed actionlisteners 2015-03-17 13:27:21 +01:00
Yorick a0a0e604a9 kaas 2015-03-17 13:21:43 +01:00
xrgman 297026bf11 fixed dots
🍡
2015-03-17 12:55:09 +01:00
aareschluchtje 140d5803ef added Food, edited the icons and changed the sprites 2015-03-17 12:42:36 +01:00
kennyboy55 8bf08d4e1d Fixed KeyListeners 2015-03-17 11:51:16 +01:00
kennyboy55 ddf5e4e908 Merge branch 'kenneth' into develop 2015-03-17 11:45:47 +01:00
kennyboy55 fd6e334649 Updated images 2015-03-17 11:45:31 +01:00
kennyboy55 47345f70c4 Merge branch 'kenneth' into develop 2015-03-17 11:43:01 +01:00
Yorick 583e447b81 KAAASS 2015-03-17 11:42:48 +00:00
Yorick 1eb4f8df41 Remove podium 2015-03-17 11:33:01 +00:00
kennyboy55 ecdb50320a Kenny Images added 2015-03-17 11:41:53 +01:00
kennyboy55 b551f91b90 Merged 2015-03-17 11:27:50 +01:00
Yorick fe8fb76759 Merge branch 'develop' of https://github.com/ProjectgroepA4/FestivalPlanner into develop 2015-03-17 10:55:54 +00:00
Yorick ea487bd24f Dragging now works properly 2015-03-17 10:55:34 +00:00
kennyboy55 47f04ee68f Added actions 2015-03-17 11:24:51 +01:00
kennyboy55 fa146df5a6 Added super cool properties stuffz 2015-03-17 11:07:57 +01:00
aareschluchtje c00a542ffc Edited StageIcon 2015-03-17 10:49:06 +01:00
aareschluchtje 01b538b3b4 Added Alpha 2015-03-17 10:39:07 +01:00
Remco b9eb9965dc Changed to new Podium (Stage) 2015-03-17 10:30:10 +01:00
Yorick f6bb5a8f44 Rectangle rotating 2015-03-16 23:00:10 +01:00
Yorick dfee405657 succesfully merged Banaan 2015-03-16 22:21:52 +01:00
Yorick d08e226650 Merge branch 'develop' of https://github.com/ProjectgroepA4/FestivalPlanner into develop 2015-03-16 21:29:47 +01:00
Yorick 99e52ebc1a Merge branch 'master' of https://github.com/ProjectgroepA4/FestivalPlanner into develop 2015-03-16 21:29:33 +01:00
aareschluchtje 87fb690de7 Also added a resize to the new Stage sprite 2015-03-16 17:49:11 +01:00
aareschluchtje ceaabb37c7 New resized sprites 2015-03-16 17:43:22 +01:00
Yorick 836f058c85 Fixed nullpointerexceptions 2015-03-16 13:46:20 +00:00
Yorick d31272622c Merge branch 'master' of https://github.com/ProjectgroepA4/FestivalPlanner into develop 2015-03-16 13:43:30 +00:00
Yorick 388021d93d Succesful merge but with nullpointerexceptions 2015-03-13 08:53:46 +00:00
Yorick 23020d03b6 Added some icons and implemented them 2015-03-12 23:42:06 +00:00
Yorick 7e51fe541a Scrolling works, had boundaries, only draws an object when image is drawn, woo 2015-03-12 23:00:44 +00:00
aareschluchtje fefffeef19 added food sprite and resized wc 2015-03-12 23:52:53 +01:00
Yorick fa726f062e Scrolling added 2015-03-12 22:44:02 +00:00
aareschluchtje d0f9601737 smaller path 2015-03-12 23:20:21 +01:00
aareschluchtje 33f0105337 new horrible sprites 2015-03-12 23:16:43 +01:00
Yorick be6aba1e38 Added images to Panel 2015-03-12 21:56:42 +00:00
kennyboy55 08c411070d Added properties panel 2015-03-12 20:51:25 +01:00
Yorick be342a5976 added dragbar 2015-03-11 21:50:15 +00:00
33 changed files with 569 additions and 477 deletions
-41
View File
@@ -1,41 +0,0 @@
package Agenda;
import java.io.Serializable;
public class Stage implements Serializable {
private static final long serialVersionUID = 1;
private String name;
private String description;
public Stage(String name, String description)
{
this.name = name;
this.description = description;
}
public String getName()
{
return this.name;
}
public String getDescription()
{
return this.description;
}
public void setDescription(String description)
{
this.description = description;
}
public void setName(String name)
{
this.name = name;
}
public String toString()
{
return name;
}
}
+100
View File
@@ -0,0 +1,100 @@
package Applicatie;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class AddPeoplePanel extends JFrame {
public AddPeoplePanel(Panel topPanel) {
super("Adding people");
setDefaultCloseOperation(HIDE_ON_CLOSE);
setResizable(false);
JPanel mainPanel = new JPanel(new BorderLayout());
JLabel label;
JButton button;
//Top:
JPanel panel = new JPanel();
label = new JLabel("Enter the amount of people you want to add: ");
panel.add(label);
mainPanel.add(panel,BorderLayout.NORTH);
//Center:
panel = new JPanel();
JTextField amountOfPeopleField = new JTextField("0");
amountOfPeopleField.setPreferredSize(new Dimension(100,20));
amountOfPeopleField.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
try {
amountOfPeopleField.setBackground(Color.WHITE);
int amountOfPeople = Integer.parseInt(amountOfPeopleField.getText());
amountOfPeopleField.setText(amountOfPeople + "");
}
catch(NumberFormatException nf) {
amountOfPeopleField.setBackground(Color.RED);
}
}
@Override
public void keyPressed(KeyEvent e) {
}
});
label = new JLabel("people ");
panel.add(amountOfPeopleField);
panel.add(label);
mainPanel.add(panel,BorderLayout.CENTER);
//Bottom:
panel = new JPanel();
button = new JButton("Cancel");
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
AddPeoplePanel.this.dispose();
}
});
panel.add(button);
button = new JButton("Apply");
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if(amountOfPeopleField.getBackground() != Color.RED) {
topPanel.addVisitors(Integer.parseInt(amountOfPeopleField.getText()));
AddPeoplePanel.this.dispose();
}
else
JOptionPane.showMessageDialog(topPanel, "Only numbers are accepted");
}
});
panel.add(button);
mainPanel.add(panel,BorderLayout.SOUTH);
add(mainPanel);
//Finishing off
pack();
setSize(290,150);
setLocationRelativeTo(null);
setVisible(true);
}
}
-268
View File
@@ -1,268 +0,0 @@
package Applicatie;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Shape;
import java.awt.geom.AffineTransform;
import java.awt.geom.Ellipse2D;
import java.awt.geom.NoninvertibleTransformException;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import javax.swing.ImageIcon;
public abstract class DrawObject
{
Point2D position;
double rotation;
double scale;
private Image image;
protected boolean selected;
private Rectangle2D rektAngle;
private Rectangle2D upperLeftCorner;
private Rectangle2D upperRightCorner;
private Rectangle2D bottomLeftCorner;
private Rectangle2D bottomRightCorner;
private Ellipse2D rotateDot;
static final int UPPERLEFT = 0;
static final int UPPERRIGHT = 1;
static final int BOTTOMLEFT = 2;
static final int BOTTOMRIGHT = 3;
private Color rectangleColor;
public DrawObject(String filename, Point2D position)
{
image = new ImageIcon(filename).getImage();
scale = 1;
rotation = 0;
this.position = position;
rectangleColor = Color.BLACK;
}
public abstract String getName();
public void draw(Graphics2D g)
{
AffineTransform tx = getTransform();
g.drawImage(image, tx, null);
if (selected)
{
// g.rotate(Math.toRadians(rotation), image.getWidth(null)/2,
// image.getHeight(null)/2);
AffineTransform rotate = AffineTransform.getRotateInstance(Math.toRadians(rotation), position.getX() + image.getWidth(null) / 2, position.getY() + image.getHeight(null) / 2);
//g.transform(rotate);
g.setColor(rectangleColor);
g.setStroke(new BasicStroke(7));
rektAngle = new Rectangle2D.Double((int) position.getX(), (int) position.getY(), image.getWidth(null), image.getHeight(null));
tx = getTransformRectangle();
rektAngle.setFrame(tx.createTransformedShape(rektAngle).getBounds());
g.draw(rektAngle);
g.setColor(Color.YELLOW);
upperLeftCorner = new Rectangle2D.Double(rektAngle.getX() - 7, rektAngle.getY() - 7, 15, 15);
upperRightCorner = new Rectangle2D.Double(rektAngle.getX() + rektAngle.getWidth() - 8, rektAngle.getY() - 7, 15, 15);
bottomLeftCorner = new Rectangle2D.Double(rektAngle.getX() - 7, rektAngle.getY() + rektAngle.getHeight() - 8, 15, 15);
bottomRightCorner = new Rectangle2D.Double(rektAngle.getX() + rektAngle.getWidth() - 8, rektAngle.getY() + rektAngle.getHeight() - 8, 15, 15);
g.fill(upperLeftCorner); // upperleft
g.fill(upperRightCorner); // upperright
g.fill(bottomLeftCorner); // bottomleft
g.fill(bottomRightCorner); // bottomright
g.setColor(Color.RED);
rotateDot = new Ellipse2D.Double((rektAngle.getX() + (rektAngle.getWidth() / 2)) - 8, rektAngle.getY() - 8, 15, 15);
g.fill(rotateDot);
}
}
protected AffineTransform getTransform()
{
AffineTransform tx = new AffineTransform();
tx.scale(scale, scale);
tx.translate(position.getX(), position.getY());
tx.rotate(Math.toRadians(rotation), image.getWidth(null) / 2, image.getHeight(null) / 2);
return tx;
}
protected AffineTransform getTransformSelection()
{
AffineTransform tx = new AffineTransform();
tx.scale(scale, scale);
tx.translate(position.getX(), position.getY());
return tx;
}
/**
* Special transformation for the selection rectangle, because the
* translation of the image one places the rectangle translated from the
* image.
*
* @return affineTransform
*/
private AffineTransform getTransformRectangle()
{
AffineTransform tx = new AffineTransform();
tx.scale(scale, scale);
return tx;
}
public boolean contains(Point2D clickPoint)
{
Shape shape;
if (rektAngle == null)
{
shape = new Rectangle2D.Double(0, 0, image.getWidth(null), image.getHeight(null));
return getTransform().createTransformedShape(shape).contains(clickPoint);
}
else
{
shape = new Rectangle2D.Double(-9, -9, image.getWidth(null) + 13, image.getHeight(null) + 13);
return getTransformSelection().createTransformedShape(shape).contains(clickPoint);
}
}
public Point2D getObjectPoint(Point2D point)
{
try
{
return getTransform().inverseTransform(point, null);
}
catch (NoninvertibleTransformException e)
{
e.printStackTrace();
}
return null;
}
/**
* Checking collision.
* @param object. the drawObject to check collision with.
* @return if there is a collision.
*/
public boolean collision(DrawObject object)
{
Shape ownShape = getRectangle();
Rectangle2D otherRectangle = object.getTransform().createTransformedShape(object.getImageRectangle()).getBounds2D();
if(ownShape.intersects(otherRectangle))
return true;
else
return false;
}
/**
* This method checks if the place thats clicked is inside one of the
* corners.
*
* @param point
* @param corner
* @return if the clicked point is inside one of the corners
*/
public boolean containsCorner(Point2D point, int corner)
{
Rectangle2D chosenCorner = null;
switch (corner)
{
case 0:
chosenCorner = upperLeftCorner;
break;
case 1:
chosenCorner = upperRightCorner;
break;
case 2:
chosenCorner = bottomLeftCorner;
break;
case 3:
chosenCorner = bottomRightCorner;
break;
case 4:
if (point.getX() > rotateDot.getX() && point.getX() < rotateDot.getX() + rotateDot.getWidth() && point.getY() > rotateDot.getY() && point.getY() < rotateDot.getY() + rotateDot.getHeight())
return true;
else
return false;
}
if (point.getX() > chosenCorner.getX() && point.getX() < chosenCorner.getX() + chosenCorner.getWidth() && point.getY() > chosenCorner.getY() && point.getY() < chosenCorner.getY() + chosenCorner.getHeight())
return true;
else
return false;
}
public void setSelected(boolean b)
{
selected = b;
}
public Point2D getPosition()
{
return position;
}
public void setPosition(Point2D position)
{
this.position = position;
}
public double getRotation()
{
return rotation;
}
public void setRotation(double rotation)
{
this.rotation = rotation;
}
public double getScale()
{
return scale;
}
public void setScale(double scale)
{
this.scale = scale;
}
public Image getImage()
{
return image;
}
public void setImage(Image image)
{
this.image = image;
}
public boolean isSelected()
{
return selected;
}
public Rectangle2D getRectangle()
{
return rektAngle;
}
public void setRectangle(Rectangle2D rectangle)
{
rektAngle = rectangle;
}
public Color getRectangleColor()
{
return rectangleColor;
}
public void setRectangleColor(Color rectangleColor)
{
this.rectangleColor = rectangleColor;
}
public Rectangle2D getImageRectangle() {
return new Rectangle2D.Double(0,0, image.getWidth(null), image.getHeight(null));
}
}
+72 -32
View File
@@ -63,6 +63,7 @@ public class Panel extends JPanel implements ActionListener
private Path currentPath;
private static int width = 1920;
private static int height = 1080;
private boolean play = false;
Point2D cameraPoint = new Point2D.Double(getWidth() / 2, getHeight() / 2);
float cameraScale = 1;
@@ -73,7 +74,7 @@ public class Panel extends JPanel implements ActionListener
Point lastMousePosition = new Point(0, 0);
Point2D selectionPosition = new Point(0, 0);
Images images = new Images();
javax.swing.Timer t;
Timer t;
SimpleDateFormat formatter;
GregorianCalendar date;
@@ -146,10 +147,9 @@ public class Panel extends JPanel implements ActionListener
addMouseMotionListener(new MouseMotion(this));
addMouseWheelListener(new MouseWheel(this));
addFocusListener(new WindowFocusListener(this));
t = new Timer(1000 / 10, this);
t = new Timer(1000 / 100, this);
}
public int getPanelInfoLength()
@@ -171,18 +171,21 @@ public class Panel extends JPanel implements ActionListener
ArrayList<AgendaStage> stages = agenda.getStages();
Object[] s = new Object[stages.size()];
AgendaStage stage = null;
if (stages.size() != 0) {
for (int i = 0; i < stages.size(); i++) {
if (stages.size() != 0)
{
for (int i = 0; i < stages.size(); i++)
{
s[i] = stages.get(i);
}
stage = (AgendaStage) JOptionPane.showInputDialog(null,
"Select the right Stage", "Select Stage",
JOptionPane.PLAIN_MESSAGE, null, s, "stage");
stage = (AgendaStage) JOptionPane.showInputDialog(null, "Select the right Stage", "Select Stage", JOptionPane.PLAIN_MESSAGE, null, s, "stage");
}
if (stage != null){
if (stage != null)
{
return new Stage(null, stage);
} else {
}
else
{
return null;
}
case 1:
@@ -209,6 +212,18 @@ public class Panel extends JPanel implements ActionListener
{
waypoints.add(w);
}
public Waypoint getWaypoint(int i)
{
for(Waypoint w : waypoints)
{
if(w.getSelf() == i)
{
return w;
}
}
return null;
}
public ArrayList<Waypoint> getWaypoints()
{
@@ -226,10 +241,10 @@ public class Panel extends JPanel implements ActionListener
if(!entrances.isEmpty()) {
DrawObject entrance = entrances.get((int) Math.floor(Math.random()*entrances.size()));
Point point = new Point((int)entrance.getPosition().getX(),(int)entrance.getPosition().getY());
visitors.add(new Visitor("visitor",point, agenda, objects));
visitors.add(new Visitor("visitor",point, agenda, objects, waypoints, date));
}
else {
JOptionPane.showMessageDialog(this, "You don't have a entrance");
JOptionPane.showMessageDialog(this, "You don't have an entrance");
}
}
@@ -549,13 +564,27 @@ public class Panel extends JPanel implements ActionListener
{
if (path.containsPoint(point))
{
setcurrentPath(path);
setClickedOption("Path");
return true;
}
}
return false;
}
public Path getClickedPath(Point2D point)
{
for (Path path : paths)
{
if (path.containsPoint(point))
{
return path;
}
}
return null;
}
/**
* Remove a path from the list.
@@ -588,17 +617,17 @@ public class Panel extends JPanel implements ActionListener
{
this.agenda = agenda;
}
public static int getFieldWidth()
{
return width;
}
public static int getFieldHeight()
{
return height;
}
@Override
public void actionPerformed(ActionEvent e)
{
@@ -614,7 +643,7 @@ public class Panel extends JPanel implements ActionListener
for (Visitor v : visitors)
{
v.update(objects, currentTime, visitors, paths);
v.update(objects, currentTime, visitors, paths, this);
}
repaint();
@@ -634,6 +663,16 @@ public class Panel extends JPanel implements ActionListener
{
this.t = t;
}
public void setPlay(boolean play)
{
this.play = play;
}
public boolean getPlay()
{
return play;
}
public void newWorld(int width, int height, int terrainIndex)
{
@@ -644,21 +683,22 @@ public class Panel extends JPanel implements ActionListener
cameraScale = 1;
switch (terrainIndex)
{
case 0:
background = grass;
break;
case 1:
background = grass2;
break;
case 2:
background = sand;
break;
case 3:
background = sand2;
break;
case 4:
background = stone;
break;
case 0:
background = grass;
break;
case 1:
background = grass2;
break;
case 2:
background = sand;
break;
case 3:
background = sand2;
break;
case 4:
background = stone;
break;
}
repaint();
}
+71
View File
@@ -0,0 +1,71 @@
package Applicatie;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import Objects.Path;
public class PathPopup extends JFrame
{
private static final long serialVersionUID = 1;
public PathPopup(Path p, Panel panel)
{
super("");
setDefaultCloseOperation(HIDE_ON_CLOSE);
JPanel content = new JPanel();
content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
JPanel south = new JPanel(new FlowLayout());
JPanel center = new JPanel();
JPanel panel1 = new JPanel();
JLabel name = new JLabel("Add WayPoint");
name.setFont(new Font("Dialog", Font.BOLD, 20));
panel1.add(name);
content.add(panel1);
content.add(center);
content.add(south);
JTextField tf = new JTextField(10);
center.add(tf);
JButton edit = new JButton("Done");
edit.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
p.addWaypoint(Integer.valueOf(tf.getText()), panel);
dispose();
}
});
JButton cancel = new JButton("Cancel");
cancel.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
dispose();
}
});
south.add(edit);
south.add(cancel);
setContentPane(content);
setVisible(true);
setSize(200, 150);
}
}
+111 -21
View File
@@ -28,6 +28,7 @@ public class Visitor
Agenda agenda;
ArrayList<DrawObject> objects;
int target;
int finalTarget;
public Visitor(String filename, Point2D position, Agenda agenda, ArrayList<DrawObject> objects)
{
@@ -41,7 +42,8 @@ public class Visitor
this.objects = objects;
fillActions();
System.out.println(actions.size());
target = 0;
target = 1;
finalTarget = 4;
}
public void draw(Graphics2D g2)
@@ -63,17 +65,17 @@ public class Visitor
public DrawObject getEntrance()
{
for(DrawObject o : objects)
for (DrawObject o : objects)
{
if(o instanceof Entrance)
if (o instanceof Entrance)
{
return o;
}
}
return null;
}
public void update(ArrayList<DrawObject> objects, int currentTime, ArrayList<Visitor> visitors, ArrayList<Path> paths)
public void update(ArrayList<DrawObject> objects, int currentTime, ArrayList<Visitor> visitors, ArrayList<Path> paths, Panel panel)
{
DrawObject target = getEntrance();
for (Action a : actions)
@@ -85,7 +87,99 @@ public class Visitor
}
moveToTarget(target, objects, visitors, paths);
// moveToTarget(target, objects, visitors, paths);
move(target, panel);
}
public void move(DrawObject tar, Panel panel)
{
Point2D targetPoint = panel.getWaypoint(target).getPosition();
double newRot = Math.atan2(targetPoint.getY() - position.getY(), targetPoint.getX() - position.getX());
int difx = (int) (targetPoint.getX() - position.getX());
int dify = (int) (targetPoint.getY() - position.getY());
int distance = (int) Math.sqrt((difx * difx) + (dify * dify));
if (rotation > newRot && distance > 10)
{
rotation -= 0.15;
}
else if (rotation < newRot && distance > 10)
{
rotation += 0.15;
}
Point2D oldPosition = position;
// face direction
float directionX = (float) Math.cos(rotation);
float directionY = (float) Math.sin(rotation);
if (distance > 10)
{
position = new Point2D.Double((position.getX() + directionX * speed), (position.getY() + directionY * speed));
}
boolean possible = true;
for (DrawObject object : objects)
{
if (object instanceof Entrance || object instanceof Waypoint)
{
continue;
}
if (hitTest(object))
{
possible = false;
}
}
if (possible == false)
{
position = oldPosition;
rotation += 0.2;
}
if (checkIfOnWaypoint(panel))
{
HashMap<Integer, int[]> options = new HashMap<Integer, int[]>();
for (Waypoint w : panel.getWaypoints())
{
options.put(w.getSelf(), w.getOptions());
}
for (Map.Entry<Integer, int[]> e : options.entrySet())
{
for (int i : e.getValue())
{
System.out.println("KEY:" + e.getKey());
System.out.println("VAL:" + i);
System.out.println("TAR: " + target);
System.out.println("____________");
if (finalTarget != target)
{
if (finalTarget == i && e.getKey() == target)
{
target = finalTarget;
break;
}
else if (finalTarget == i)
{
target = e.getKey();
break;
}
}
}
}
}
}
public boolean checkIfOnWaypoint(Panel panel)
{
if (panel.getWaypoint(target).contains(position))
{
return true;
}
return false;
}
public void moveToTarget(DrawObject target, ArrayList<DrawObject> objects, ArrayList<Visitor> visitors, ArrayList<Path> paths)
@@ -100,7 +194,7 @@ public class Visitor
break;
}
Shape containsShape = p.containsPointShape(position);
if(containsShape != null)
if (containsShape != null)
{
tar = new Point2D.Double(containsShape.getBounds().getCenterX(), containsShape.getBounds().getCenterY());
}
@@ -208,27 +302,23 @@ public class Visitor
}
}
lastShape = values.get(lastdistance);
Point2D.Double target2 = new Point2D.Double(lastShape.getBounds().getCenterX(), lastShape.getBounds().getCenterY());
double newRot = Math.atan2(target2.getY() - position.getY(), target2.getX() - position.getX());
int difx = (int) (target2.getX() - position.getX());
int dify = (int) (target2.getY() - position.getY());
int distance = (int) Math.sqrt((difx * difx) + (dify * dify));
System.out.println(rotation);
System.out.println(newRot);
System.out.println("--------------");
// if (rotation > newRot && distance > 10)
// {
// rotation -= 0.15;
// }
// else if (rotation < newRot && distance > 10)
// {
// rotation += 0.15;
// }
rotation = newRot;
if (rotation > newRot && distance > 10)
{
rotation -= 0.15;
}
else if (rotation < newRot && distance > 10)
{
rotation += 0.15;
}
Point2D oldPosition = position;
+90 -9
View File
@@ -1,10 +1,13 @@
package Applicatie;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
@@ -16,25 +19,82 @@ import Objects.DrawObject;
public class WaypointPopup extends JFrame {
private static final long serialVersionUID = 1;
private JLabel title;
public WaypointPopup(DrawObject w)
public WaypointPopup(DrawObject w, Panel panel)
{
super("Artist editscreen!");
super("Edit WayPoint");
Waypoint wp = (Waypoint) w;
setDefaultCloseOperation(HIDE_ON_CLOSE);
JPanel content = new JPanel(new BorderLayout());
JPanel south = new JPanel(new FlowLayout());
JPanel center = new JPanel(new GridLayout(5,2));
JPanel north = new JPanel();
if(wp.getSelf() == 0)
{
title = new JLabel("Edit WayPoint");
}
else
{
title = new JLabel("Edit WayPoint " + wp.getSelf());
}
title.setFont(new Font("Dialog", Font.BOLD, 24));
north.add(title);
content.add(north, BorderLayout.NORTH);
JPanel center = new JPanel(new FlowLayout());
JPanel row1 = new JPanel();
row1.setLayout(new BoxLayout(row1, BoxLayout.Y_AXIS));
JPanel row2 = new JPanel();
row2.setLayout(new BoxLayout(row2, BoxLayout.Y_AXIS));
JPanel south = new JPanel();
content.add(south, BorderLayout.SOUTH);
content.add(center, BorderLayout.CENTER);
center.add(row1);
center.add(row2);
JPanel empty = new JPanel();
empty.add(Box.createRigidArea(new Dimension(0, 20)));
row2.add(empty);
JPanel panel1 = new JPanel();
JLabel name = new JLabel("Waypoint");
name.setFont(new Font("Dialog", Font.PLAIN, 20));
panel1.add(name);
center.add(panel1);
row1.add(panel1);
JTextField tf = new JTextField(5);
center.add(tf);
JTextField tf = new JTextField(wp.getSelf() + "", 10);
row2.add(tf);
JPanel panel2 = new JPanel();
JLabel options = new JLabel("Options");
options.setFont(new Font("Dialog", Font.PLAIN, 20));
panel2.add(options);
row1.add(panel2);
JPanel empty2 = new JPanel();
empty2.add(Box.createRigidArea(new Dimension(0, 5)));
row2.add(empty2);
String optionss = "";
if(wp.getOptions() != null)
{
if(wp.getOptions().length != 0)
{
int[] optionsa = wp.getOptions();
optionss += optionsa[0];
for(int i = 1; i < optionsa.length; i++)
{
optionss += "-" + optionsa[i];
}
}
}
JTextField tx = new JTextField("" + optionss, 8);
row2.add(tx);
JPanel help = new JPanel();
JLabel example = new JLabel("example: '1-2-3'");
example.setFont(new Font("Dialog", Font.PLAIN, 12));
help.add(example);
row2.add(help);
JButton edit = new JButton("Done");
edit.addActionListener(new ActionListener()
@@ -44,14 +104,35 @@ public class WaypointPopup extends JFrame {
public void actionPerformed(ActionEvent e)
{
wp.setSelf(Integer.valueOf(tf.getText()));
panel.addWaypoint(wp);
dispose();
String options[] = tx.getText().split("-");
int ioptions[] = new int[options.length];
for(int i = 0; i < options.length; i++)
{
ioptions[i] = Integer.valueOf(options[i]);
System.out.println(ioptions[i]);
}
wp.setOptions(ioptions);
}
});
south.add(edit);
JButton cancel = new JButton("Cancel");
cancel.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
dispose();
}
});
south.add(cancel);
setContentPane(content);
setVisible(true);
setSize(500,320);
setSize(300,250);
}
}
+106 -86
View File
@@ -10,6 +10,8 @@ import java.awt.image.BufferedImage;
import javax.swing.SwingUtilities;
import Applicatie.Panel;
import Applicatie.PathPopup;
import Applicatie.Waypoint;
import Applicatie.WaypointPopup;
import Objects.DrawObject;
@@ -33,115 +35,133 @@ public class Mouse extends MouseAdapter
Point2D clickPoint = panel.getClickPoint(e.getPoint());
panel.setLastClickPosition(clickPoint);
panel.setLastMousePosition(e.getPoint());
if (!panel.getClickedOption().equals("Path"))
if(!panel.getPlay())
{
if (e.getY() < 150)
if (!panel.getClickedOption().equals("Path"))
{
int i = 0;
int last = 0;
for (BufferedImage image : panel.getPanelInfo())
if (e.getY() < 150)
{
if (e.getX() >= panel.getScrollfactor() && e.getX() < last + image.getWidth() + panel.getScrollfactor())
int i = 0;
int last = 0;
for (BufferedImage image : panel.getPanelInfo())
{
DrawObject tempDrawObj = panel.createNewDrawObject(i);
if (tempDrawObj != null)
if (e.getX() >= panel.getScrollfactor() && e.getX() < last + image.getWidth() + panel.getScrollfactor())
{
tempDrawObj.setPosition(clickPoint);
if (!panel.getObjects().isEmpty())
panel.clearObjectSelection();
panel.setDragObject(tempDrawObj);
panel.getDragObject().setSelected(true);
panel.getPP().setSelected(tempDrawObj);
panel.setSelectedObject(tempDrawObj);
selectedObject = tempDrawObj;
DrawObject tempDrawObj = panel.createNewDrawObject(i);
if (tempDrawObj != null)
{
tempDrawObj.setPosition(clickPoint);
if (!panel.getObjects().isEmpty())
panel.clearObjectSelection();
panel.setDragObject(tempDrawObj);
panel.getDragObject().setSelected(true);
panel.getPP().setSelected(tempDrawObj);
panel.setSelectedObject(tempDrawObj);
selectedObject = tempDrawObj;
}
break;
}
break;
i++;
last += image.getWidth();
}
if (panel.getDragObject() != null)
{
panel.add(panel.getDragObject());
}
i++;
last += image.getWidth();
}
if (panel.getDragObject() != null)
else
{
panel.add(panel.getDragObject());
}
}
else
{
for (DrawObject o : panel.getObjects())
{
if (o.contains(clickPoint))
for (DrawObject o : panel.getObjects())
{
if (o.contains(clickPoint))
{
if (SwingUtilities.isRightMouseButton(e))
{
if (o instanceof Waypoint)
{
new WaypointPopup(o, panel);
}
}
if (o == selectedObject)
{
boolean upperLeft = o.containsCorner(clickPoint, 0);
boolean upperRight = o.containsCorner(clickPoint, 1);
boolean bottomLeft = o.containsCorner(clickPoint, 2);
boolean bottomRight = o.containsCorner(clickPoint, 3);
boolean rotate = o.containsCorner(clickPoint, 4);
if (upperLeft)
{
panel.setClickedOption("upperLeft");
}
else if (upperRight)
{
panel.setClickedOption("upperRight");
}
else if (bottomLeft)
{
panel.setClickedOption("bottomLeft");
}
else if (bottomRight)
{
panel.setClickedOption("bottomRight");
}
else if (rotate)
{
panel.setClickedOption("rotate");
}
else
{
panel.setClickedOption("drag");
}
}
if (selectedObject != null)
selectedObject.setSelected(false);
o.setSelected(true);
selectedObject = o;
panel.setDragObject(o);
panel.getPP().setSelected(o);
panel.setSelectedObject(o);
panel.setSelectionPosition(panel.getDragObject().getPosition());
}
}
Path clickedPath = panel.getClickedPath(clickPoint);
if (clickedPath != null)
{
if (SwingUtilities.isRightMouseButton(e))
{
if (o instanceof Waypoint)
{
new WaypointPopup(o);
}
new PathPopup(clickedPath, panel);
}
if (o == selectedObject)
{
boolean upperLeft = o.containsCorner(clickPoint, 0);
boolean upperRight = o.containsCorner(clickPoint, 1);
boolean bottomLeft = o.containsCorner(clickPoint, 2);
boolean bottomRight = o.containsCorner(clickPoint, 3);
boolean rotate = o.containsCorner(clickPoint, 4);
if (upperLeft)
{
panel.setClickedOption("upperLeft");
}
else if (upperRight)
{
panel.setClickedOption("upperRight");
}
else if (bottomLeft)
{
panel.setClickedOption("bottomLeft");
}
else if (bottomRight)
{
panel.setClickedOption("bottomRight");
}
else if (rotate)
{
panel.setClickedOption("rotate");
}
else
{
panel.setClickedOption("drag");
}
}
if (selectedObject != null)
selectedObject.setSelected(false);
o.setSelected(true);
selectedObject = o;
panel.setDragObject(o);
panel.getPP().setSelected(o);
panel.setSelectedObject(o);
panel.setSelectionPosition(panel.getDragObject().getPosition());
}
else
{
panel.checkPath(clickPoint);
}
}
if (panel.getDragObject() == null && selectedObject != null)
{
selectedObject.setSelected(false);
panel.setSelectedObject(null);
panel.getPP().clearSelected();
selectedObject = null;
}
panel.checkPath(clickPoint);
}
if (panel.getDragObject() == null && selectedObject != null)
{
selectedObject.setSelected(false);
panel.setSelectedObject(null);
panel.getPP().clearSelected();
selectedObject = null;
else
{ // Making path.
panel.getCurrentPath().addPoint(new Point2D.Double(clickPoint.getX(), clickPoint.getY()));
}
}
else
{ // Making path.
panel.getCurrentPath().addPoint(new Point2D.Double(clickPoint.getX(), clickPoint.getY()));
}
panel.repaint();
}
public void mouseReleased(MouseEvent e)
{
if (panel.getDragObject() != null)
if (panel.getDragObject() != null && !panel.getPlay())
{
if (panel.getDragObject().getRectangleColor() != Color.RED)
{
+19 -7
View File
@@ -14,6 +14,7 @@ import java.util.ArrayList;
import javax.imageio.ImageIO;
import Applicatie.Panel;
import Applicatie.Waypoint;
/**
@@ -95,7 +96,7 @@ public class Path
}
return null;
}
/**
* Check if one of the lines contains the given point.
*
@@ -114,12 +115,13 @@ public class Path
}
return false;
}
public boolean intersectsRect(Rectangle2D rect)
{
for(Shape line : getPath())
for (Shape line : getPath())
{
if(line.intersects(rect))
if (line.intersects(rect))
{
return true;
}
@@ -144,13 +146,23 @@ public class Path
lines.add(stroke.createStrokedShape(line));
}
return lines;
}
public void addWaypoint(Waypoint w)
public void addWaypoint(int i, Panel panel)
{
waypoints.add(w);
for (Waypoint w : panel.getWaypoints())
{
if (w.getSelf() == i)
{
waypoints.add(w);
return;
}
}
}
/**
* Add a point to the path.
*
-13
View File
@@ -1,13 +0,0 @@
package Objects;
import java.awt.geom.Point2D;
import Applicatie.DrawObject;
public class Podium extends DrawObject {
public Podium(Point2D position) {
super("images/stage3.png", position);
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 897 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 180 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 202 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 911 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 155 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 B