top chrono (car race)

Advanced game related topics
jak64
Enthusiast
Enthusiast
Posts: 502
Joined: Sat Aug 15, 2020 5:02 pm
Location: Ciboure (France)

top chrono (car race)

Post by jak64 »

infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: top chrono (car race)

Post by infratec »

I just tried your game.

I did not fully understand the functionallity :oops:

But ...
If you use
viewtopic.php?f=12&t=75564

You can increase and decrease the speed of the movie. :wink:

Or maybe Rashads code
viewtopic.php?p=560078#p560078
No external player and can also increase an decrease speed.
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: top chrono (car race)

Post by BarryG »

Is it a game or video? Pressing Q and M do nothing?
jak64
Enthusiast
Enthusiast
Posts: 502
Joined: Sat Aug 15, 2020 5:02 pm
Location: Ciboure (France)

Re: top chrono (car race)

Post by jak64 »

How long will you take to climb a Pyrenees pass by car? Here is this little program that will test your reflexes.
I filmed the drive up to the Saint-Ignace pass, near my home, then I sped up the video 2 times and wrote this little game "top_chrono".
When the game starts and the 3 second countdown is over, the road will pass in front of you. In the top banner, the words "FREINER" (Brake) or "ACCELERER" (Accelerate) will appear randomly. As quickly as possible, press the corresponding key (m to accelerate or q to brake, but these keys can be changed in the code at the start of the program). The faster you react, the less time you will waste.
Be careful, if you make the wrong key or press keys when nothing is written in the strip, neither FREINER (brake) nor ACCELERER (Accelerate), you will incur penalties which will be added to your total time. The record is saved in the record.txt file which it will suffice to delete in the "resources" directory to reset the record.

For the resolution, look at the beginning of the code, everything is explained, you can choose the dimensions you want or put it in full screen if you wish by modifying the constant #height_ecran at the beginning of the code.

You can also put a video of your own, in .avi (preferably a video filmed from a windshield) in the "resources" directory. The program generates a FREINER (brake) or ACCELERER (Accelerate) action every 5 seconds more or less between 0 and 0.75 seconds. The number of actions depends on the duration of the video, the program calculates it automatically: for example if your video lasts 1 minute, the number of actions calculated will be around 12. If your video lasts 2 minutes, this number will be about 24, etc. The game window will also be adjusted automatically. the game lasts 2 minutes and about 20 seconds with the current video.

The executable (top_chrono.exe) is in 64 bits Windows. The zipped file (top_chrono.7z) weighs 126 MB because it contains the video, the source code of the program being only 534 lines long.

I wrote this program with Purebasic version v5.73 on an old computer (lenovo E330). You may have display problems on recent computers ...

Note :
I tried using the functions to speed up or slow down the video but since it is done 50 times per second in the game loop the result was not good and sometimes the video would freeze.
And even if it worked fine, it wouldn't do me any good in this game. Indeed, if I slowed down the video by pressing q and if I speeded it up by pressing m, the time achieved for the race would not be significant for this game.
How to achieve a better time with this method ?
To convince yourself of this, do a test with a video (by slowing it down and speeding it up) and you will see that we cannot make this game by acting on the speed of the video.

It's unpretentious, just to spend a few minutes and test your reaction times ...

Thank you for your comments.

When "ACCELERER" is displayed, press the m key as quickly as possible.
Image

When "FREINER" is displayed, press the q key as quickly as possible.
Image

The time you have achieved enters the top 10.
Image

The time you have achieved does not make it into the top 10.
Image

Here is the link to download the full game
https://u.pcloud.link/publink/show?code ... QulyX03yk0
jak64
Enthusiast
Enthusiast
Posts: 502
Joined: Sat Aug 15, 2020 5:02 pm
Location: Ciboure (France)

Re: top chrono (car race)

Post by jak64 »

Correction: the file which contains the 10 best times is called "classement.txt" and not "record.txt" in the "ressources" directory.
Post Reply