# Search:

Type: Posts; User: DanielVkc

Page 1 of 3 1

## Search: Search took 0.15 seconds.

by DanielVkc
Replies
105
Views
4,386

### Re: Car racing

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...

by DanielVkc
Replies
105
Views
4,386

### Re: Car racing

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.

by DanielVkc
Replies
105
Views
4,386

### Re: Car racing

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++){
...

by DanielVkc
Replies
105
Views
4,386

### Re: Car racing

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.

by DanielVkc
Replies
105
Views
4,386

### Re: Car racing

if(count <= 3) {
t1 = new Timer((int)s1, new ActionListener() {
public void actionPerformed(ActionEvent e){
if (x1 <= 1000) {
...

by DanielVkc
Replies
105
Views
4,386

### Re: Car racing

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 DanielVkc
Replies
105
Views
4,386

### Re: Car racing

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.

by DanielVkc
Replies
105
Views
4,386

### Re: Car racing

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...

by DanielVkc
Replies
105
Views
4,386

### Re: Car racing

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..??

by DanielVkc
Replies
105
Views
4,386

### Re: Car racing

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.

by DanielVkc
Replies
105
Views
4,386

### Re: Car racing

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) {

by DanielVkc
Replies
105
Views
4,386

### Re: Car racing

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...

by DanielVkc
Replies
105
Views
4,386

### Re: Car racing

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...

by DanielVkc
Replies
105
Views
4,386

### Re: Car racing

The car will still continue without stopping.
Because my project requirements needs all the 3 cars to run for 3 laps.

by DanielVkc
Replies
105
Views
4,386

### Re: Car racing

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;
...

by DanielVkc
Replies
105
Views
4,386

### Re: Car racing

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;
...

by DanielVkc
Replies
105
Views
4,386

### Re: Car racing

Mind to show me some examples on the timers with x,y positions especially for this car race application..??

by DanielVkc
Replies
105
Views
4,386

### Re: Car racing

Or would you mind to instruct me directly using the modified code dat I just posted in post#66..??

by DanielVkc
Replies
105
Views
4,386

### Re: Car racing

Do you have the source on it..??

by DanielVkc
Replies
105
Views
4,386

### Re: Car racing

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...

by DanielVkc
Replies
105
Views
4,386

### Re: Car racing

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...

by DanielVkc
Replies
105
Views
4,386

### Re: Car racing

Since now everything can display already, how to make these cars to move along the track..??

by DanielVkc
Replies
105
Views
4,386

### Re: Car racing

I modified everything already..All the images can be displayed now..thanks so much..

by DanielVkc
Replies
105
Views
4,386

### Re: Car racing

So how do I need to link them so that it can be the same..??

by DanielVkc
Replies
105
Views
4,386

### Re: Car racing

My files are :
1. Blue Car.png
2. Green Car.png
3. Red Car.png
4. Track.gif
Results 1 to 25 of 54
Page 1 of 3 1