Skip to content

Commit

Permalink
hola
Browse files Browse the repository at this point in the history
  • Loading branch information
StepCrow committed Sep 9, 2018
0 parents commit c7eac8e
Show file tree
Hide file tree
Showing 6 changed files with 252 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .classpath
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>
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin/
17 changes: 17 additions & 0 deletions .project
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>
11 changes: 11 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
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
75 changes: 75 additions & 0 deletions src/Coche.java
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 + "]";
}


}
142 changes: 142 additions & 0 deletions src/VentanaJuego.java
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);
}
});


}
}

0 comments on commit c7eac8e

Please sign in to comment.