Commit a6178413 by Pedro Rolon

Se agregó fondo y se corrigieron los angulos diagonales

parent d8fb3402
...@@ -15,6 +15,7 @@ import javafx.event.ActionEvent; ...@@ -15,6 +15,7 @@ import javafx.event.ActionEvent;
import javafx.event.EventHandler; import javafx.event.EventHandler;
import javafx.scene.input.KeyEvent; import javafx.scene.input.KeyEvent;
import javafx.scene.input.KeyCode; import javafx.scene.input.KeyCode;
import javafx.scene.paint.Color;
//import Bicicleta; //import Bicicleta;
public class Something extends Application public class Something extends Application
...@@ -28,9 +29,10 @@ public class Something extends Application ...@@ -28,9 +29,10 @@ public class Something extends Application
public void start(Stage stage) public void start(Stage stage)
{ {
double distancia = 10; double distancia = 10;
Canvas canvas = new Canvas(700, 700); Canvas canvas = new Canvas(1300, 800);
GraphicsContext gc = canvas.getGraphicsContext2D(); GraphicsContext gc = canvas.getGraphicsContext2D();
gc.setLineWidth(2.0); gc.setLineWidth(5.0);
//gc.setStroke(Color.BLUE);
Pane root = new Pane(); Pane root = new Pane();
ImageView imagen; ImageView imagen;
...@@ -40,7 +42,7 @@ public class Something extends Application ...@@ -40,7 +42,7 @@ public class Something extends Application
//FileInputStream inputstream = new FileInputStream("file:javacleta.png"); //FileInputStream inputstream = new FileInputStream("file:javacleta.png");
FileInputStream inputstream = new FileInputStream("bici.png"); FileInputStream inputstream = new FileInputStream("bici.png");
//se setea el tamaño de la imagen! //se setea el tamaño de la imagen!
Image img = new Image(inputstream, 50, 50, false, false); Image img = new Image(inputstream, 60, 60, false, false);
//gc.drawImage(img, 0, 0); //gc.drawImage(img, 0, 0);
//es 350 menos porque se toma en cuenta el tamaño de la imagen! //es 350 menos porque se toma en cuenta el tamaño de la imagen!
//gc.drawImage(img, bicicleta.x, 350-bicicleta.y); //gc.drawImage(img, bicicleta.x, 350-bicicleta.y);
...@@ -93,7 +95,7 @@ public class Something extends Application ...@@ -93,7 +95,7 @@ public class Something extends Application
boton1.setOnAction(new EventHandler<ActionEvent>() { boton1.setOnAction(new EventHandler<ActionEvent>() {
@Override @Override
public void handle(ActionEvent event) { public void handle(ActionEvent event) {
mover(gc, bicicleta, distancia, 2.09439510238807, imagen); mover(gc, bicicleta, distancia, 2.3561944901865, imagen);
} }
}); });
...@@ -115,7 +117,7 @@ public class Something extends Application ...@@ -115,7 +117,7 @@ public class Something extends Application
boton3.setOnAction(new EventHandler<ActionEvent>() { boton3.setOnAction(new EventHandler<ActionEvent>() {
@Override @Override
public void handle(ActionEvent event) { public void handle(ActionEvent event) {
mover(gc, bicicleta, distancia, 0.5235987755970001, imagen); mover(gc, bicicleta, distancia, 0.7853981633955001, imagen);
} }
}); });
...@@ -148,7 +150,7 @@ public class Something extends Application ...@@ -148,7 +150,7 @@ public class Something extends Application
boton6.setOnAction(new EventHandler<ActionEvent>() { boton6.setOnAction(new EventHandler<ActionEvent>() {
@Override @Override
public void handle(ActionEvent event) { public void handle(ActionEvent event) {
mover(gc, bicicleta, distancia, 3.665191429179, imagen); mover(gc, bicicleta, distancia, 3.9269908169775, imagen);
} }
}); });
...@@ -170,17 +172,13 @@ public class Something extends Application ...@@ -170,17 +172,13 @@ public class Something extends Application
boton8.setOnAction(new EventHandler<ActionEvent>() { boton8.setOnAction(new EventHandler<ActionEvent>() {
@Override @Override
public void handle(ActionEvent event) { public void handle(ActionEvent event) {
mover(gc, bicicleta, distancia, 5.23598775597, imagen); mover(gc, bicicleta, distancia, 5.4977871437685, imagen);
} }
}); });
root.setStyle("-fx-border-style: solid inside;" + root.setStyle("-fx-background-image: url(\"mapamundi.jpg\");");
"-fx-border-width: 2;" +
"-fx-border-insets: 5;" +
"-fx-border-radius: 5;" +
"-fx-border-color: blue;");
root.getChildren().add(canvas); root.getChildren().add(canvas);
root.getChildren().add(boton1); root.getChildren().add(boton1);
...@@ -197,13 +195,13 @@ public class Something extends Application ...@@ -197,13 +195,13 @@ public class Something extends Application
scene.setOnKeyPressed(e -> { scene.setOnKeyPressed(e -> {
if (e.getCode() == KeyCode.NUMPAD1) { if (e.getCode() == KeyCode.NUMPAD1) {
mover(gc, bicicleta, distancia, 3.665191429179, imagen); mover(gc, bicicleta, distancia, 3.9269908169775, imagen);
} }
else if (e.getCode() == KeyCode.NUMPAD2) { else if (e.getCode() == KeyCode.NUMPAD2) {
mover(gc, bicicleta, distancia, 4.712388980373, imagen); mover(gc, bicicleta, distancia, 4.712388980373, imagen);
} }
else if (e.getCode() == KeyCode.NUMPAD3) { else if (e.getCode() == KeyCode.NUMPAD3) {
mover(gc, bicicleta, distancia, 5.23598775597, imagen); mover(gc, bicicleta, distancia, 5.4977871437685, imagen);
} }
else if (e.getCode() == KeyCode.NUMPAD4) { else if (e.getCode() == KeyCode.NUMPAD4) {
mover(gc, bicicleta, distancia, 3.141592653582001, imagen); mover(gc, bicicleta, distancia, 3.141592653582001, imagen);
...@@ -212,13 +210,13 @@ public class Something extends Application ...@@ -212,13 +210,13 @@ public class Something extends Application
mover(gc, bicicleta, distancia, 0, imagen); mover(gc, bicicleta, distancia, 0, imagen);
} }
else if (e.getCode() == KeyCode.NUMPAD7) { else if (e.getCode() == KeyCode.NUMPAD7) {
mover(gc, bicicleta, distancia, 2.09439510238807, imagen); mover(gc, bicicleta, distancia, 2.3561944901865, imagen);
} }
else if (e.getCode() == KeyCode.NUMPAD8) { else if (e.getCode() == KeyCode.NUMPAD8) {
mover(gc, bicicleta, distancia, 1.570796326791001, imagen); mover(gc, bicicleta, distancia, 1.570796326791001, imagen);
} }
else if (e.getCode() == KeyCode.NUMPAD9) { else if (e.getCode() == KeyCode.NUMPAD9) {
mover(gc, bicicleta, distancia, 0.5235987755970001, imagen); mover(gc, bicicleta, distancia, 0.7853981633955001, imagen);
} }
else if (e.getCode() == KeyCode.PLUS) { else if (e.getCode() == KeyCode.PLUS) {
//distancia++; //distancia++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment