diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..7f8cb3f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+.idea/
+*.iml
+application.log
+target/
diff --git a/Preview/track1.png b/Preview/track1.png
index 0d3dd4b..45427e2 100644
Binary files a/Preview/track1.png and b/Preview/track1.png differ
diff --git a/README.md b/README.md
index 27001f2..5e4884c 100644
--- a/README.md
+++ b/README.md
@@ -1,16 +1,15 @@
# Highway
-A Java game to drive your truck against other 2 trucks throughout the highway and compete to stay on the top of the leaderboard
-Author : Aditya Chatterjee
-:e-mail: me : aditianhacker@gmail.com
+A _Java Swing_ game to drive your car against other 2 cars throughout the highway and compete to stay on the top of the leaderboard
-:movie_camera: : [here](https://www.youtube.com/watch?v=AQzlGbrLvDw)
+-----
-
-Feel free to suggest improvements
+__Language__ : Java SE 8
-## Extension
+__Authors__ : Aditya Chatterjee, Gaboso
-[Endless](https://github.com/Gaboso/Highway) by [Gaboso](https://github.com/Gaboso)
+
+-----
+Feel free to suggest improvements.
diff --git a/Track.java b/Track.java
deleted file mode 100644
index 86096ee..0000000
--- a/Track.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
-The MIT License (MIT)
-
-Copyright (c) 2015 Aditya Chatterjee
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
-
-import java.awt.Color;
-import static java.awt.Color.gray;
-import static java.awt.Color.yellow;
-import java.awt.Font;
-import java.awt.Graphics;import java.awt.Image;
-import java.awt.Rectangle;import java.awt.event.KeyAdapter;
-import java.awt.event.KeyEvent;import javax.swing.JDialog;
-import javax.swing.JFrame;
-import javax.swing.JOptionPane;
-public class Track extends JFrame implements Runnable
-{
- int x,y;int xDirection,yDirection,rectx,recty;int bx,by;
- Font font=new Font("ARIAL",Font.BOLD|Font.ITALIC,20);int t1=0,score=0;double pp=0.0;double pp1=0.0;
- Rectangle MyShip=new Rectangle(x,y,20,50);
- int controlx=1,controly=1;int yy=1;
- Rectangle boundary=new Rectangle(5,380,500,20);
- Rectangle road=new Rectangle(65,0,285,1000);
- Rectangle boundary2=new Rectangle(45,20,20,500);
- Rectangle boundary3=new Rectangle(350,20,20,500);int c=1;
- Rectangle c1=new Rectangle(100,380,20,30);
- Rectangle c2=new Rectangle(300,350,30,10);
- Rectangle illu11=new Rectangle(45,90,20,20);Rectangle illu21=new Rectangle(350,90,20,20);
- Rectangle illu12=new Rectangle(45,200,20,20);Rectangle illu22=new Rectangle(350,200,20,20);
- Rectangle illu13=new Rectangle(45,300,20,20);Rectangle illu23=new Rectangle(350,300,20,20);int sd=0,s1=-30,s2=0;
- int w=0;
- private Graphics dbg;private Image dbImage;
- public void move()
- {
- cv=2,cd=2;
- if(w%13==0)cv=5;
- else if(w%17==0)cv=2;
- if(w%11==0)cd=5;
- else if(w%17==0)cd=2;
- else if(w%100==0)cd=15;
- MyShip.x+=xDirection;MyShip.y+=yDirection;c1.y+=cd;c2.y+=cv;
- sd+=yDirection;s1+=cd;s2+=cv;w++;
- if(yDirection==-3)
- {
- illu11.y-=yDirection;illu12.y-=yDirection;illu13.y-=yDirection;
- illu21.y-=yDirection;illu22.y-=yDirection;illu23.y-=yDirection;
- }
- if(MyShip.x<=50)
- MyShip.x=50;
- if(MyShip.x>=350)
- MyShip.x=350;
- if(MyShip.y<=150)
- MyShip.y=150;
- if(MyShip.y>380)
- MyShip.y=380;
- if(c1.x<=50)
- c1.x=50;
- if(c1.x>=350)
- c1.x=350;
- if(c1.y<=140)
- c1.y=140;
- if(c1.y>380)
- c1.y=380;
- if(c2.x<=50)
- c2.x=50;
- if(c2.x>=350)
- c2.x=350;
- if(c2.y<=155)
- c2.y=155;
- if(c2.y>380)
- c2.y=380;
- if(illu11.y>=350)
- illu11.y=50;
- if(illu12.y>=350)
- illu12.y=50;
- if(illu13.y>=350)
- illu13.y=50;
- if(illu21.y>=350)
- illu21.y=50;
- if(illu22.y>=350)
- illu22.y=50;
- if(illu23.y>=350)
- illu23.y=50;
- }
- public void run()
- {
- try{
- while(true)
- {
- move();Thread.sleep(20);
- }
- }
- catch(Exception e)
- {
- System.err.println(e.getMessage());
- }
- }
- public void setXDirection(int xdir)
- {
- xDirection=xdir;
- }
- public void setYDirection(int ydir)
- {
- yDirection=ydir;
- }
- public class AL extends KeyAdapter
- {
- public void keyPressed(KeyEvent e)
- {
- int keyCode=e.getKeyCode();
- if(keyCode==e.VK_LEFT)
- setXDirection(-3);
- if(keyCode==e.VK_RIGHT)
- setXDirection(+3);
- if(keyCode==e.VK_UP)
- setYDirection(-3);
- if(keyCode==e.VK_DOWN)
- setYDirection(+3);
- }
- public void keyReleased(KeyEvent e)
- {
- int keyCode=e.getKeyCode();
- if(keyCode==e.VK_LEFT)
- setXDirection(0);
- if(keyCode==e.VK_RIGHT)
- setXDirection(0);
- if(keyCode==e.VK_UP)
- setYDirection(0);
- if(keyCode==e.VK_DOWN)
- setYDirection(0);
- }
- }
- public Track()
- {
- setBackground(Color.GREEN);
- addKeyListener(new AL());
- setTitle("SPEED UP");
- setSize(500,400);
- setResizable(false);
- setVisible(true);
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- MyShip.x=200;MyShip.y=350;yy=1;
- }
- public void paint(Graphics g)
- {
- dbImage=createImage(getWidth(),getHeight());
- dbg=dbImage.getGraphics();
- paintComponent(dbg);
- g.drawImage(dbImage,0,0,this);
- }
- public void paintComponent(Graphics g)
- {
- g.setColor(yellow);
- g.fillRect(boundary2.x,boundary2.y,boundary2.width,boundary2.height);
- g.fillRect(boundary3.x,boundary3.y,boundary3.width,boundary3.height);
- g.setColor(gray);
- g.fillRect(road.x, road.y, road.width, road.height);
- g.setColor(Color.white);
- g.fillRect(illu11.x,illu11.y,illu11.width,illu11.height);
- g.fillRect(illu11.x+170,illu11.y,5,25);
- g.fillRect(illu12.x,illu12.y,illu12.width,illu12.height);
- g.fillRect(illu12.x+170,illu12.y,5,25);
- g.fillRect(illu13.x,illu13.y,illu13.width,illu13.height);
- g.fillRect(illu13.x+170,illu13.y,5,25);
- g.fillRect(illu21.x,illu21.y,illu21.width,illu21.height);
- g.fillRect(illu22.x,illu22.y,illu22.width,illu22.height);
- g.fillRect(illu23.x,illu23.y,illu23.width,illu23.height);
- g.setColor(Color.red);
- g.fillRect(MyShip.x,MyShip.y,20,50);
- g.setColor(Color.black);
- g.fillRect(MyShip.x+20,MyShip.y+5,5,5);
- g.fillRect(MyShip.x-5,MyShip.y+5,5,5);
- g.fillRect(MyShip.x+20,MyShip.y+40,5,5);
- g.fillRect(MyShip.x-5,MyShip.y+40,5,5);
- g.setColor(Color.yellow);
- g.fillRect(c1.x,MyShip.y-s1-sd,20,50);
- g.setColor(Color.black);
- g.fillRect(c1.x+20,MyShip.y-s1-sd+5,5,5);
- g.fillRect(c1.x-5,MyShip.y-s1-sd+5,5,5);
- g.fillRect(c1.x+20,MyShip.y-s1-sd+40,5,5);
- g.fillRect(c1.x-5,MyShip.y-s1-sd+40,5,5);
- g.setColor(Color.orange);
- g.fillRect(c2.x,MyShip.y-s2-sd,20,50);
- g.setColor(Color.black);
- g.fillRect(c2.x+20,MyShip.y-s2-sd+5,5,5);
- g.fillRect(c2.x-5,MyShip.y-s2-sd+5,5,5);
- g.fillRect(c2.x+20,MyShip.y-s2-sd+40,5,5);
- g.fillRect(c2.x-5,MyShip.y-s2-sd+40,5,5);
- g.drawString("Car - Dist. travelled", 380, 170);
- String r1="Me "+(-sd);
- g.drawString(r1, 380, 190);
- r1="C1 "+(s1);
- g.drawString(r1, 380, 210);
- r1="C2 "+(s2);
- g.drawString(r1, 380, 230);r1="Rank";
- g.drawString(r1, 380, 250);
- int m=(int)Math.max(s1,Math.max(s2,-sd));String p;
- if(s1-m==0)p="C1";
- else if(s2-m==0)p="C2";
- else p="Me";
- r1="1."+p;g.drawString(r1, 380, 270);
- int m1=(int)Math.min(s1,Math.min(s2,-sd));
- if(s1-m1==0)p="C1";
- else if(s2-m1==0)p="C2";
- else p="Me";
- r1="3."+p;g.drawString(r1, 380, 310);
- m=s1+s2-sd-m-m1;
- if(s1-m==0)p="C1";
- else if(s2-m==0)p="C2";
- else p="Me";
- r1="2."+p;g.drawString(r1, 380, 290);
- repaint();
- }
- public static void main(String[] args)
- {
- String message="BE READY TO FLY YOUR TRUCK";
- JOptionPane pane = new JOptionPane(message);
- JDialog dialog = pane.createDialog(new JFrame(), "Dilaog");
- dialog.show();
- Track su=new Track();
- Thread t1=new Thread(su);
- t1.start();
- }
-}
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..1947eb9
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,72 @@
+
+
+ 4.0.0
+
+ com.highway
+ Highway
+ 1.0.0
+
+
+ com.github.gaboso
+ https://github.com/Gaboso/Highway
+
+
+
+ scm:git:git://github.com/Gaboso/Highway.git
+
+
+ https://github.com/Gaboso/Highway
+
+
+
+
+ UTF-8
+ 1.8
+ 1.8
+
+
+
+
+
+ log4j
+ log4j
+ 1.2.17
+
+
+
+
+
+ ${project.artifactId}
+
+
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+ 3.3.0
+
+
+
+ com.highway.Track
+
+
+
+ jar-with-dependencies
+
+ false
+
+
+
+ make-assembly
+ install
+
+ single
+
+
+
+
+
+
+
+
diff --git a/src/main/java/com/highway/Track.java b/src/main/java/com/highway/Track.java
new file mode 100644
index 0000000..55b15f6
--- /dev/null
+++ b/src/main/java/com/highway/Track.java
@@ -0,0 +1,368 @@
+package com.highway;
+
+/*
+The MIT License (MIT)
+
+Copyright (c) 2015 Aditya Chatterjee
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
+import org.apache.log4j.Logger;
+
+import javax.imageio.ImageIO;
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.io.File;
+import java.net.URI;
+
+public class Track extends JFrame implements Runnable {
+
+ private static final Logger LOGGER = Logger.getLogger(Track.class);
+
+ //Colors
+ private static final Color BACKGROUND_COLOR = Color.decode("#4CAF50");
+ private static final Color COLOR_BOUNDARY = Color.decode("#D32F2F");
+
+ //Fonts
+ private static final Font FONT_TITLE = new Font("Trebuchet MS", Font.BOLD, 14);
+ private static final Font FONT_NORMAL = new Font("Trebuchet MS", Font.PLAIN, 12);
+
+ private static final int KERB_WIDTH = 20;
+ private static final int KERB_HEIGHT = 40;
+ private static final int LANE_DIVIDER_WIDTH = 5;
+ private static final int LANE_DIVIDER_HEIGHT = 25;
+
+ private int x;
+ private int y;
+ private int xDirection;
+ private int yDirection;
+
+ private Rectangle playerCar = new Rectangle(x, y, 20, 50);
+ private Rectangle opponentOne = new Rectangle(100, 380, 20, 30);
+ private Rectangle opponentTwo = new Rectangle(300, 350, 30, 10);
+
+ private Rectangle road = new Rectangle(65, 0, 285, 500);
+ private Rectangle leftBoundary = new Rectangle(45, 20, 20, 500);
+ private Rectangle rightBoundary = new Rectangle(350, 20, 20, 500);
+
+ private Rectangle rightKerbOne = new Rectangle(45, 90, KERB_WIDTH, KERB_HEIGHT);
+ private Rectangle rightKerbTwo = new Rectangle(350, 90, KERB_WIDTH, KERB_HEIGHT);
+ private Rectangle rightKerbThree = new Rectangle(45, 200, KERB_WIDTH, KERB_HEIGHT);
+
+ private Rectangle leftKerbOne = new Rectangle(350, 200, KERB_WIDTH, KERB_HEIGHT);
+ private Rectangle leftKerbTwo = new Rectangle(45, 300, KERB_WIDTH, KERB_HEIGHT);
+ private Rectangle leftKerbThree = new Rectangle(350, 300, KERB_WIDTH, KERB_HEIGHT);
+
+ private int sd = 0;
+ private int s1 = -30;
+ private int s2 = 0;
+ private int w = 0;
+
+ private Track() {
+ setBackground(BACKGROUND_COLOR);
+ addKeyListener(new AL());
+ setTitle("Endless");
+ setSize(510, 400);
+ setIconImage(new ImageIcon(Track.class.getResource("/icon.png")).getImage());
+ setResizable(false);
+ setVisible(true);
+ setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+
+ playerCar.x = 200;
+ playerCar.y = 350;
+ }
+
+ private void move() {
+ int cv = 2;
+ int cd = 2;
+
+ if (w % 13 == 0) {
+ cv = 5;
+ } else if (w % 17 == 0) {
+ cv = 2;
+ }
+
+ if (w % 11 == 0) {
+ cd = 5;
+ } else if (w % 17 == 0) {
+ cd = 2;
+ } else if (w % 100 == 0) {
+ cd = 15;
+ }
+
+ playerCar.x += xDirection;
+ playerCar.y += yDirection;
+
+ opponentOne.y += cd;
+ opponentTwo.y += cv;
+ sd += yDirection;
+ s1 += cd;
+ s2 += cv;
+ w++;
+
+ if (yDirection == -3) {
+ rightKerbOne.y -= yDirection;
+ rightKerbThree.y -= yDirection;
+ leftKerbTwo.y -= yDirection;
+ rightKerbTwo.y -= yDirection;
+ leftKerbOne.y -= yDirection;
+ leftKerbThree.y -= yDirection;
+ }
+
+ playerCar = setXYToCar(playerCar, 150);
+ opponentOne = setXYToCar(opponentOne, 140);
+ opponentTwo = setXYToCar(opponentTwo, 155);
+
+ if (rightKerbOne.y >= 350) {
+ rightKerbOne.y = 50;
+ }
+ if (rightKerbThree.y >= 350) {
+ rightKerbThree.y = 50;
+ }
+ if (leftKerbTwo.y >= 350) {
+ leftKerbTwo.y = 50;
+ }
+ if (rightKerbTwo.y >= 350) {
+ rightKerbTwo.y = 50;
+ }
+ if (leftKerbOne.y >= 350) {
+ leftKerbOne.y = 50;
+ }
+ if (leftKerbThree.y >= 350) {
+ leftKerbThree.y = 50;
+ }
+ }
+
+ @Override
+ public void run() {
+ try {
+ while (true) {
+ move();
+ Thread.sleep(20);
+ }
+ } catch (Exception e) {
+ LOGGER.error(e.getMessage(), e);
+ }
+ }
+
+ private class AL extends KeyAdapter {
+
+ private void setXDirection(int xdir) {
+ xDirection = xdir;
+ }
+
+ private void setYDirection(int ydir) {
+ yDirection = ydir;
+ }
+
+ @Override
+ public void keyPressed(KeyEvent e) {
+ int keyCode = e.getKeyCode();
+ if (keyCode == KeyEvent.VK_LEFT) {
+ setXDirection(-3);
+ }
+ if (keyCode == KeyEvent.VK_RIGHT) {
+ setXDirection(+3);
+ }
+ if (keyCode == KeyEvent.VK_UP) {
+ setYDirection(-3);
+ }
+ if (keyCode == KeyEvent.VK_DOWN) {
+ setYDirection(+3);
+ }
+ }
+
+ @Override
+ public void keyReleased(KeyEvent e) {
+ int keyCode = e.getKeyCode();
+ if (keyCode == KeyEvent.VK_LEFT) {
+ setXDirection(0);
+ }
+ if (keyCode == KeyEvent.VK_RIGHT) {
+ setXDirection(0);
+ }
+ if (keyCode == KeyEvent.VK_UP) {
+ setYDirection(0);
+ }
+ if (keyCode == KeyEvent.VK_DOWN) {
+ setYDirection(0);
+ }
+ }
+ }
+
+ @Override
+ public void paint(Graphics g) {
+ Image image = createImage(getWidth(), getHeight());
+ Graphics dbg = image.getGraphics();
+ paintComponent(dbg);
+ g.drawImage(image, 0, 0, this);
+ }
+
+ private void paintComponent(Graphics g) {
+ drawBoundary(g);
+ drawRoad(g);
+ drawLaneDividers(g);
+ drawAllKerbs(g);
+ drawAllCars(g);
+
+ drawTravelledDistance(g);
+ drawRank(g);
+
+ repaint();
+ }
+
+ private void drawRoad(Graphics g) {
+ g.setColor(Color.DARK_GRAY);
+ g.fillRect(road.x, road.y, road.width, road.height);
+ }
+
+ private void drawBoundary(Graphics g) {
+ //Left boundary
+ g.setColor(COLOR_BOUNDARY);
+ g.fillRect(leftBoundary.x, leftBoundary.y, leftBoundary.width, leftBoundary.height);
+ //Right boundary
+ g.setColor(COLOR_BOUNDARY);
+ g.fillRect(rightBoundary.x, rightBoundary.y, rightBoundary.width, rightBoundary.height);
+ }
+
+ private void drawRank(Graphics g) {
+ g.setFont(FONT_TITLE);
+ g.drawString("Rank", 380, 250);
+
+ g.setFont(FONT_NORMAL);
+ //First place
+ int m = Math.max(s1, Math.max(s2, -sd));
+ g.drawString("1° " + getNameFromDriver(m), 380, 270);
+ //Second place
+ int m1 = Math.min(s1, Math.min(s2, -sd));
+ g.drawString("3° " + getNameFromDriver(m1), 380, 310);
+ //Third place
+ m = s1 + s2 - sd - m - m1;
+ g.drawString("2° " + getNameFromDriver(m), 380, 290);
+ }
+
+ private void drawTravelledDistance(Graphics g) {
+ g.setColor(Color.WHITE);
+ g.setFont(FONT_TITLE);
+ g.drawString("Distance travelled", 380, 170);
+
+ g.setFont(FONT_NORMAL);
+ g.drawString("Me: " + (-sd), 380, 190);
+ g.drawString("Ayrton Penna: " + (s1), 380, 210);
+ g.drawString("Rubens Chinello: " + (s2), 380, 230);
+ }
+
+ private void drawLaneDividers(Graphics g) {
+ g.setColor(Color.YELLOW);
+ g.fillRect(rightKerbOne.x + 170, rightKerbOne.y, LANE_DIVIDER_WIDTH, LANE_DIVIDER_HEIGHT);
+ g.fillRect(leftKerbTwo.x + 170, leftKerbTwo.y, LANE_DIVIDER_WIDTH, LANE_DIVIDER_HEIGHT);
+ g.fillRect(rightKerbThree.x + 170, rightKerbThree.y, LANE_DIVIDER_WIDTH, LANE_DIVIDER_HEIGHT);
+ }
+
+ private void drawAllCars(Graphics g) {
+ drawPlayerCar(g);
+ drawOpponentOne(g);
+ drawOpponentTwo(g);
+ }
+
+ private void drawAllKerbs(Graphics g) {
+ //Kerbs
+ g.setColor(Color.WHITE);
+ drawKerb(g, rightKerbOne);
+ drawKerb(g, leftKerbOne);
+
+ drawKerb(g, rightKerbTwo);
+ drawKerb(g, leftKerbTwo);
+
+ drawKerb(g, rightKerbThree);
+ drawKerb(g, leftKerbThree);
+ }
+
+ private void drawKerb(Graphics g, Rectangle kerb) {
+ g.fillRect(kerb.x, kerb.y, kerb.width, kerb.height);
+ }
+
+ private void drawPlayerCar(Graphics g) {
+ drawCar("blue_car.png", playerCar.x, playerCar.y, g);
+ }
+
+ private void drawOpponentOne(Graphics g) {
+ drawCar("green_car.png", opponentOne.x, playerCar.y - s1 - sd, g);
+ }
+
+ private void drawOpponentTwo(Graphics g) {
+ drawCar("yellow_truck.png", opponentTwo.x, playerCar.y - s2 - sd, g);
+ }
+
+ private void drawCar(String carName, int x, int y, Graphics graphics) {
+ try {
+ URI uri = Track.class.getClassLoader().getResource(carName).toURI();
+
+ File pathToFile = new File(uri);
+ Image car = ImageIO.read(pathToFile);
+ graphics.drawImage(car, x, y, null);
+ } catch (Exception ex) {
+ LOGGER.error(ex.getMessage(), ex);
+ }
+ }
+
+ private String getNameFromDriver(int distanceTravelled) {
+ if (s1 - distanceTravelled == 0) {
+ return "Ayrton Penna";
+ } else if (s2 - distanceTravelled == 0) {
+ return "Rubens Chinello";
+ } else {
+ return "Me";
+ }
+ }
+
+ private Rectangle setXYToCar(Rectangle car, int distanceY) {
+ if (car.x <= 50) {
+ car.x = 50;
+ }
+ if (car.x >= 350) {
+ car.x = 350;
+ }
+ if (car.y <= distanceY) {
+ car.y = distanceY;
+ }
+ if (car.y > 380) {
+ car.y = 380;
+ }
+
+ return car;
+ }
+
+ public static void main(String[] args) {
+ int result = JOptionPane.showConfirmDialog(null, "Be ready to race your car", "Endless", JOptionPane.OK_CANCEL_OPTION);
+
+ // Result equals OK
+ if (result == 0) {
+ Track track = new Track();
+ Thread thread = new Thread(track);
+ thread.start();
+ } else {
+ System.exit(0);
+ }
+ }
+
+}
diff --git a/src/main/resources/blue_car.png b/src/main/resources/blue_car.png
new file mode 100644
index 0000000..5eff516
Binary files /dev/null and b/src/main/resources/blue_car.png differ
diff --git a/src/main/resources/green_car.png b/src/main/resources/green_car.png
new file mode 100644
index 0000000..578fe83
Binary files /dev/null and b/src/main/resources/green_car.png differ
diff --git a/src/main/resources/icon.png b/src/main/resources/icon.png
new file mode 100644
index 0000000..c39ed48
Binary files /dev/null and b/src/main/resources/icon.png differ
diff --git a/src/main/resources/log4j.properties b/src/main/resources/log4j.properties
new file mode 100644
index 0000000..630ce9d
--- /dev/null
+++ b/src/main/resources/log4j.properties
@@ -0,0 +1,16 @@
+# Root logger option
+log4j.rootLogger=DEBUG, stdout, file
+
+# Redirect log messages to console
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p - %m%n
+
+# Redirect log messages to a log file, support file rolling.
+log4j.appender.file=org.apache.log4j.RollingFileAppender
+log4j.appender.file.File=./application.log
+log4j.appender.file.MaxFileSize=5MB
+log4j.appender.file.MaxBackupIndex=10
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p - %m%n
diff --git a/src/main/resources/yellow_truck.png b/src/main/resources/yellow_truck.png
new file mode 100644
index 0000000..fb11fd0
Binary files /dev/null and b/src/main/resources/yellow_truck.png differ