Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
java-e006-javacleta
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Pedro Rolon
java-e006-javacleta
Commits
73c3e557
Commit
73c3e557
authored
Nov 07, 2018
by
Pedro Rolon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Se agregaron botones y control por teclado
parent
5ccd8ce1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
152 additions
and
4 deletions
+152
-4
Something.java
+152
-4
No files found.
Something.java
View file @
73c3e557
...
...
@@ -10,6 +10,11 @@ import java.io.FileInputStream;
import
java.io.FileNotFoundException
;
import
javafx.scene.image.Image
;
import
javafx.scene.image.ImageView
;
import
javafx.scene.control.Button
;
import
javafx.event.ActionEvent
;
import
javafx.event.EventHandler
;
import
javafx.scene.input.KeyEvent
;
import
javafx.scene.input.KeyCode
;
//import Bicicleta;
public
class
Something
extends
Application
...
...
@@ -22,14 +27,15 @@ public class Something extends Application
@Override
public
void
start
(
Stage
stage
)
{
Canvas
canvas
=
new
Canvas
(
400
,
400
);
double
distancia
=
10
;
Canvas
canvas
=
new
Canvas
(
700
,
700
);
GraphicsContext
gc
=
canvas
.
getGraphicsContext2D
();
gc
.
setLineWidth
(
2.0
);
Bicicleta
bicicleta
=
new
Bicicleta
();
/*
mover(gc, bicicleta, 50);
mover(gc, bicicleta, 50, 1.5708);
mover(gc, bicicleta, 50, 0);
...
...
@@ -40,6 +46,7 @@ public class Something extends Application
mover(gc, bicicleta, 25, 4.71239);
mover(gc, bicicleta, 100, 0.523599);
mover(gc, bicicleta, 100, 5.23599);
*/
...
...
@@ -63,19 +70,160 @@ public class Something extends Application
System
.
out
.
println
(
e
.
getMessage
());
}
//Crea los botones
Button
boton1
=
new
Button
();
Button
boton2
=
new
Button
();
Button
boton3
=
new
Button
();
Button
boton4
=
new
Button
();
Button
boton5
=
new
Button
();
Button
boton6
=
new
Button
();
Button
boton7
=
new
Button
();
Button
boton8
=
new
Button
();
boton1
.
setText
(
"NE"
);
boton1
.
setPrefSize
(
40
,
40
);
boton1
.
setLayoutX
(
0
);
boton1
.
setLayoutY
(
0
);
boton1
.
setOnAction
(
new
EventHandler
<
ActionEvent
>()
{
@Override
public
void
handle
(
ActionEvent
event
)
{
mover
(
gc
,
bicicleta
,
distancia
,
2.09439510238807
);
}
});
boton2
.
setText
(
"N"
);
boton2
.
setPrefSize
(
40
,
40
);
boton2
.
setLayoutX
(
50
);
boton2
.
setLayoutY
(
0
);
boton2
.
setOnAction
(
new
EventHandler
<
ActionEvent
>()
{
@Override
public
void
handle
(
ActionEvent
event
)
{
mover
(
gc
,
bicicleta
,
distancia
,
1.570796326791001
);
}
});
boton3
.
setText
(
"NO"
);
boton3
.
setPrefSize
(
40
,
40
);
boton3
.
setLayoutX
(
100
);
boton3
.
setLayoutY
(
0
);
boton3
.
setOnAction
(
new
EventHandler
<
ActionEvent
>()
{
@Override
public
void
handle
(
ActionEvent
event
)
{
mover
(
gc
,
bicicleta
,
distancia
,
0.523598775597001
);
}
});
boton4
.
setText
(
"E"
);
boton4
.
setPrefSize
(
40
,
40
);
boton4
.
setLayoutX
(
0
);
boton4
.
setLayoutY
(
50
);
boton4
.
setOnAction
(
new
EventHandler
<
ActionEvent
>()
{
@Override
public
void
handle
(
ActionEvent
event
)
{
mover
(
gc
,
bicicleta
,
distancia
,
3.141592653582001
);
}
});
boton5
.
setText
(
"O"
);
boton5
.
setPrefSize
(
40
,
40
);
boton5
.
setLayoutX
(
100
);
boton5
.
setLayoutY
(
50
);
boton5
.
setOnAction
(
new
EventHandler
<
ActionEvent
>()
{
@Override
public
void
handle
(
ActionEvent
event
)
{
mover
(
gc
,
bicicleta
,
distancia
,
0
);
}
});
boton6
.
setText
(
"SE"
);
boton6
.
setPrefSize
(
40
,
40
);
boton6
.
setLayoutX
(
0
);
boton6
.
setLayoutY
(
100
);
boton6
.
setOnAction
(
new
EventHandler
<
ActionEvent
>()
{
@Override
public
void
handle
(
ActionEvent
event
)
{
mover
(
gc
,
bicicleta
,
distancia
,
3.665191429179
);
}
});
boton7
.
setText
(
"S"
);
boton7
.
setPrefSize
(
40
,
40
);
boton7
.
setLayoutX
(
50
);
boton7
.
setLayoutY
(
100
);
boton7
.
setOnAction
(
new
EventHandler
<
ActionEvent
>()
{
@Override
public
void
handle
(
ActionEvent
event
)
{
mover
(
gc
,
bicicleta
,
distancia
,
4.712388980373
);
}
});
boton8
.
setText
(
"SO"
);
boton8
.
setPrefSize
(
40
,
40
);
boton8
.
setLayoutX
(
100
);
boton8
.
setLayoutY
(
100
);
boton8
.
setOnAction
(
new
EventHandler
<
ActionEvent
>()
{
@Override
public
void
handle
(
ActionEvent
event
)
{
mover
(
gc
,
bicicleta
,
distancia
,
5.23598775597
);
}
});
Pane
root
=
new
Pane
();
root
.
setStyle
(
"-fx-padding: 10;"
+
"-fx-border-style: solid inside;"
+
root
.
setStyle
(
"-fx-border-style: solid inside;"
+
"-fx-border-width: 2;"
+
"-fx-border-insets: 5;"
+
"-fx-border-radius: 5;"
+
"-fx-border-color: blue;"
);
root
.
getChildren
().
add
(
canvas
);
root
.
getChildren
().
add
(
boton1
);
root
.
getChildren
().
add
(
boton2
);
root
.
getChildren
().
add
(
boton3
);
root
.
getChildren
().
add
(
boton4
);
root
.
getChildren
().
add
(
boton5
);
root
.
getChildren
().
add
(
boton6
);
root
.
getChildren
().
add
(
boton7
);
root
.
getChildren
().
add
(
boton8
);
Scene
scene
=
new
Scene
(
root
);
scene
.
setOnKeyPressed
(
e
->
{
if
(
e
.
getCode
()
==
KeyCode
.
NUMPAD1
)
{
mover
(
gc
,
bicicleta
,
distancia
,
3.665191429179
);
}
else
if
(
e
.
getCode
()
==
KeyCode
.
NUMPAD2
)
{
mover
(
gc
,
bicicleta
,
distancia
,
4.712388980373
);
}
else
if
(
e
.
getCode
()
==
KeyCode
.
NUMPAD3
)
{
mover
(
gc
,
bicicleta
,
distancia
,
5.23598775597
);
}
else
if
(
e
.
getCode
()
==
KeyCode
.
NUMPAD4
)
{
mover
(
gc
,
bicicleta
,
distancia
,
3.141592653582001
);
}
else
if
(
e
.
getCode
()
==
KeyCode
.
NUMPAD6
)
{
mover
(
gc
,
bicicleta
,
distancia
,
0
);
}
else
if
(
e
.
getCode
()
==
KeyCode
.
NUMPAD7
)
{
mover
(
gc
,
bicicleta
,
distancia
,
2.09439510238807
);
}
else
if
(
e
.
getCode
()
==
KeyCode
.
NUMPAD8
)
{
mover
(
gc
,
bicicleta
,
distancia
,
1.570796326791001
);
}
else
if
(
e
.
getCode
()
==
KeyCode
.
NUMPAD9
)
{
mover
(
gc
,
bicicleta
,
distancia
,
0.523598775597001
);
}
else
if
(
e
.
getCode
()
==
KeyCode
.
PLUS
)
{
//distancia++;
}
else
if
(
e
.
getCode
()
==
KeyCode
.
MINUS
)
{
//distancia--;
}
});
stage
.
setScene
(
scene
);
stage
.
setTitle
(
"Óyeme Carlos llévame en tu Bicicleta"
);
stage
.
show
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment