-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c7eac8e
Showing
6 changed files
with
252 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>Coche</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=1.8 | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.source=1.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
|
||
public class Coche { | ||
|
||
private double vel; | ||
private double dir; | ||
private double posx; | ||
private double posy; | ||
private String pil; | ||
|
||
|
||
public Coche(double vel, double dir, double posx, double posy, String pil) { | ||
super(); | ||
this.vel = vel; | ||
this.dir = dir; | ||
this.posx = posx; | ||
this.posy = posy; | ||
this.pil = pil; | ||
} | ||
|
||
public Coche() { | ||
super(); | ||
this.vel = 0; | ||
this.dir = 0; | ||
this.posx = 0; | ||
this.posy = 0; | ||
this.pil = null; | ||
} | ||
|
||
public double getVel() { | ||
return vel; | ||
} | ||
|
||
public void setVel(double vel) { | ||
this.vel = vel; | ||
} | ||
|
||
public double getDir() { | ||
return dir; | ||
} | ||
|
||
public void setDir(double dir) { | ||
this.dir = dir; | ||
} | ||
|
||
public double getPosx() { | ||
return posx; | ||
} | ||
|
||
public void setPosx(double posx) { | ||
this.posx = posx; | ||
} | ||
|
||
public double getPosy() { | ||
return posy; | ||
} | ||
|
||
public void setPosy(double posy) { | ||
this.posy = posy; | ||
} | ||
|
||
public String getPil() { | ||
return pil; | ||
} | ||
|
||
public void setPil(String pil) { | ||
this.pil = pil; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Coche [vel=" + vel + ", dir=" + dir + ", posx=" + posx + ", posy=" + posy + ", pil=" + pil + "]"; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
import javax.swing.*; | ||
|
||
import java.awt.*; | ||
import java.awt.event.*; | ||
|
||
public class VentanaJuego extends JFrame{ | ||
|
||
private JPanel az; | ||
private JPanel za; | ||
private JButton ac; | ||
private JButton pa; | ||
private JButton izk; | ||
private JButton der; | ||
protected Coche lul; | ||
private boolean ar; | ||
|
||
public VentanaJuego() { | ||
|
||
ar = true; | ||
|
||
Container cp = this.getContentPane(); | ||
|
||
az = new JPanel(); | ||
az.setPreferredSize(new Dimension(750,750)); | ||
az.setBackground(Color.black); | ||
za = new JPanel(new GridLayout(1,4)); | ||
za.setPreferredSize(new Dimension(100,50)); | ||
ac = new JButton("ac"); | ||
pa = new JButton("pa"); | ||
izk = new JButton("izk"); | ||
der = new JButton("der"); | ||
|
||
za.add(ac); | ||
za.add(pa); | ||
za.add(izk); | ||
za.add(der); | ||
|
||
cp.add(az, BorderLayout.NORTH); | ||
cp.add(za,BorderLayout.SOUTH); | ||
|
||
this.setResizable(false); | ||
this.setDefaultCloseOperation(EXIT_ON_CLOSE); | ||
this.setTitle("Coche"); | ||
this.pack();; | ||
this.setVisible(true); | ||
|
||
|
||
Thread acc = new Thread () { | ||
|
||
public void run() { | ||
|
||
|
||
int temp =0; | ||
double velu= 1; | ||
while(ar==true) { | ||
|
||
temp++; | ||
try { | ||
Thread.sleep(100); | ||
} catch (InterruptedException e1) { | ||
// TODO Auto-generated catch block | ||
e1.printStackTrace(); | ||
|
||
} | ||
velu= velu*temp; | ||
if(velu<=24) { | ||
lul.setVel(velu); | ||
} | ||
|
||
System.out.println(lul); | ||
System.out.println(ar); | ||
} | ||
|
||
|
||
|
||
|
||
} | ||
|
||
}; | ||
|
||
|
||
ac.addActionListener(new ActionListener() { | ||
|
||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
|
||
acc.start(); | ||
|
||
|
||
} | ||
}); | ||
|
||
pa.addActionListener(new ActionListener() { | ||
|
||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
|
||
if (ar==true) { | ||
|
||
ar=false; | ||
|
||
|
||
|
||
|
||
} | ||
|
||
|
||
} | ||
}); | ||
|
||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
public static void main(String[] args) { | ||
// TODO Auto-generated method stub | ||
|
||
|
||
|
||
|
||
|
||
SwingUtilities.invokeLater(new Runnable() { | ||
|
||
@Override | ||
public void run() { | ||
VentanaJuego o = new VentanaJuego(); | ||
o.lul = new Coche(); | ||
o.lul.setPosx(150); | ||
o.lul.setPosy(100); | ||
System.out.println(o.lul); | ||
} | ||
}); | ||
|
||
|
||
} | ||
} |