Racer 1 has completed 0 lap(s)
Racer 1 has completed 1 lap(s)
Racer 1 has completed 2 lap(s)
Racer 1 has completed 3 lap(s)
Racer 2 has completed 0 lap(s)
Racer 2 has completed 1 lap(s)
Racer 2...
Type: Posts; User: DanielVkc
Racer 1 has completed 0 lap(s)
Racer 1 has completed 1 lap(s)
Racer 1 has completed 2 lap(s)
Racer 1 has completed 3 lap(s)
Racer 2 has completed 0 lap(s)
Racer 2 has completed 1 lap(s)
Racer 2...
It will print out :
Racer 1 has completed 0 lap(s)
Racer 1 has completed 1 lap(s)
Racer 1 has completed 2 lap(s)
Racer 1 has completed 3 lap(s)
It displays all of these messages in one time.
laps++;
System.out.println("Racer 1 has completed " + laps + " lap(s)");
Is this correct?Or is it like that?
for(int laps = 0; laps < 4; laps++){
...
In this case, can I use System.out.println to display the message?
How to set the n count in the message since I'm using this method?So that the n will generate automatically inside the message.
if(count <= 3) {
t1 = new Timer((int)s1, new ActionListener() {
public void actionPerformed(ActionEvent e){
if (x1 <= 1000) {
...
Ya,there will be a counter for each car.
They will be increased inside the timer section by using the if-else statement.
Because of the counter that I set for 3 laps and this is how I know all the...
By using the the count++.At first by declaring int count = 0 on top.Then, if the count is 3 then it will stop the race for each car.
Once all the cars stopped after 3 laps by stopping the car timer.
I want to make them to continue until they reach 3 laps then stop the race.
Ya,because the counter is used to indicate after 3 laps, ALL the cars will be stop.
Nope..the race stops after ALL the...
Ya..once I remove everything already then they will keep looping without stopping.
If I insert the for loop inside the there will it be ok..??
Because I want to show the that the race will stop after 3 laps.
For count value part I was confused with the coding.}\
Thr run() just call once then it will loop the race until 3 laps then stop.
if(count <= 3) {
This is to indicate that the race need to be run for 3 laps
t1 = new Timer((int)s1, new ActionListener() {
This is to make the car move at random speed
if (x1 <= 1000) {
Because today I ask my lecturer on modification should be made.
He said that I should put if(count <= 3) then the car will stop after 3 laps by using the stop method.
Else the car will keep on...
If I remove the count variable the cars will be running without stopping just like you said here but without the laps being indicated.
In other words, they will keep on looping.
I feel that...
The car will still continue without stopping.
Because my project requirements needs all the 3 cars to run for 3 laps.
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
import javax.swing.Timer;
import java.applet.*;
public class Race extends Applet implements Runnable{
Image img_1;
...
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
import javax.swing.Timer;
import java.applet.*;
public class Race extends Applet implements Runnable{
Image img_1;
...
Mind to show me some examples on the timers with x,y positions especially for this car race application..??
Or would you mind to instruct me directly using the modified code dat I just posted in post#66..??
Do you have the source on it..??
I defined it as Xpos =30 and Ypos = 30..
After that I use the drawImage method to draw out the components of the cars and its x,y positions..
This is the part I was very confusing while I was doing...
Here is my latest modified code :
import javax.swing.*;
import java.awt.geom.*;
import java.awt.*;
public class RaceTrack extends JFrame
{
private RaceTrackPanel animation;
private JLabel...
Since now everything can display already, how to make these cars to move along the track..??
I modified everything already..All the images can be displayed now..thanks so much..
So how do I need to link them so that it can be the same..??
My files are :
1. Blue Car.png
2. Green Car.png
3. Red Car.png
4. Track.gif