SFML community forums

General => SFML projects => Topic started by: Mortal on November 30, 2015, 01:09:40 pm

Title: Car Racing For Beginners : Finished
Post by: Mortal on November 30, 2015, 01:09:40 pm
i was reading about pseudo-3d racing game. the tutorial is here in this link below it's short and easy for read especially for beginner but unfortunately, it is for javascript language, the challenge is how to  make it in C++/SFML. Humbly i have done my first attempt in make this game.

Demo:

http://www.youtube.com/watch?v=c5ixex8Ty08

the tutorial: http://codeincomplete.com/posts/2012/6/22/javascript_racer/ (http://codeincomplete.com/posts/2012/6/22/javascript_racer/).
Title: Re: Car Racing For Beginners
Post by: eXpl0it3r on November 30, 2015, 02:00:15 pm
This looks quite neat. Makes me want to implement my own thingy. :D
Title: Re: Car Racing For Beginners
Post by: Mortal on November 30, 2015, 02:21:17 pm
i'm glad you like it eXpl0it3r.

i would like to see your version of this game  ;)
it quite simple even the math behind it is some how easy to grasp.
Title: Re: Car Racing For Beginners
Post by: Ungod on November 30, 2015, 03:34:17 pm
This has a nice immersion of speed!
Title: Re: Car Racing For Beginners
Post by: Mortal on November 30, 2015, 03:47:27 pm
This has a nice immersion of speed!
yeah, if someone focused on road, he will feel that ;D
Title: Re: Car Racing For Beginners
Post by: Hapax on November 30, 2015, 05:46:42 pm
This looks really good. Good work!

Did you find that it made a big difference when you added something in the distance (i.e. your background)? I think it really fills out the view :)

The road itself looks pretty cool, a lot like the one in the tutorial.

Just a couple of minor points to improve (as seen in the video):
Title: Re: Car Racing For Beginners
Post by: Mortal on November 30, 2015, 06:24:15 pm
This looks really good. Good work!

Did you find that it made a big difference when you added something in the distance (i.e. your background)? I think it really fills out the view :)

The road itself looks pretty cool, a lot like the one in the tutorial.
thanks Hapax, i'm so glad you like it. yes a lot of differences when i added background  to the scene.in my humble opinion, i believe successful games is relying on graphics.

Just a couple of minor points to improve (as seen in the video):
  • There are flickering light horizontal lines on the track, quite near the horizon. This is the only thing that looks "bad".
good point, i didn't notice this flickering before. i edited repo, i have fixed it.

Just a couple of minor points to improve (as seen in the video):

  • There is oddness in the track! When slightly moving, or stopped after moving, the track "bloats". It can be see at the beginning (0:02) and end (1:12) but most notably after stopping at (0:12).
    I don't know if this is the case but it looks like the expansion of the width of the track as it travels towards the bottom of the screen is either ahead or behind the movement of the "camera's" position.
sorry, i couldn't see the oddity on track. in video above slightly i can say there is some sort of bloats in the track. but when i ran the exe file in my PC it seems fine. it is very hard to tell so, it's confusing.
Title: Re: Car Racing For Beginners
Post by: Elias Daler on November 30, 2015, 08:56:06 pm
This looks really awesome, great job
Title: Re: Car Racing For Beginners
Post by: Mortal on December 01, 2015, 08:54:58 am
This looks really awesome, great job
thank you,
the easy part is done, i have finished the road geometries only. but there is more need to implement like game entities, collision, Al... etc
Title: Re: Car Racing For Beginners
Post by: Elias Daler on December 01, 2015, 09:25:05 am
thank you,
the easy part is done, i have finished the road geometries only. but there is more need to implement like game entities, collision, Al... etc
Don't forget to separate the code by putting it into different files. It would be much easier to read it that way :D
Title: Re: Car Racing For Beginners
Post by: Mortal on December 03, 2015, 07:13:11 am
Don't forget to separate the code by putting it into different files. It would be much easier to read it that way :D
thanks for advise, but the game is fairly small and dont think it worths to be in separate files.

UP DATED

Demo
http://www.youtube.com/watch?v=plUnBs-zsGY
Title: Re: Car Racing For Beginners
Post by: Elias Daler on December 03, 2015, 08:16:41 am
thanks for advise, but the game is fairly small and dont think it worths to be in separate files.
It's always worth it. :)
As the game gets bigger, it's easier to refactor and manage stuff.

The update looks very awesome, by the way. Great job! :D
Title: Re: Car Racing For Beginners
Post by: Mortal on December 03, 2015, 09:29:44 am
thanks for advise, but the game is fairly small and dont think it worths to be in separate files.
It's always worth it. :)
As the game gets bigger, it's easier to refactor and manage stuff.

The update looks very awesome, by the way. Great job! :D
thanks for complements. you are absolutely right, but this project was made for education purpose, i don't know if i will make it full game or stop at where it become. since i have implemented most of essential parts like road geometries and game's entities and collision.
Title: Re: Car Racing For Beginners
Post by: Elias Daler on December 03, 2015, 02:12:21 pm
thanks for complements. you are absolutely right, but this project was made for education purpose, i don't know if i will make it full game or stop at where it become. since i have implemented most of essential parts like road geometries and game's entities and collision.
I think that it's easier to study ways to structure stuff in smaller projects, because it's pretty hard to do in bigger projects, because you have to move a lot of things around. Once you understand how to structure and decouple stuff in your smaller project, you'll start writing your next projects using this structure. :)

Oh, and there are other benefits, of course. Once you put start putting stuff in .h and .cpp recompilation will be a lot faster, because there'll be less stuff to recompile. Now you're recompiling everything in your one file.
This isn't a problem in a small project, probably, but will become much bigger once the project starts getting bigger.
Title: Re: Car Racing For Beginners
Post by: Mortal on December 03, 2015, 03:58:49 pm
thanks for complements. you are absolutely right, but this project was made for education purpose, i don't know if i will make it full game or stop at where it become. since i have implemented most of essential parts like road geometries and game's entities and collision.
I think that it's easier to study ways to structure stuff in smaller projects, because it's pretty hard to do in bigger projects, because you have to move a lot of things around. Once you understand how to structure and decouple stuff in your smaller project, you'll start writing your next projects using this structure. :)

Oh, and there are other benefits, of course. Once you put start putting stuff in .h and .cpp recompilation will be a lot faster, because there'll be less stuff to recompile. Now you're recompiling everything in your one file.
This isn't a problem in a small project, probably, but will become much bigger once the project starts getting bigger.
absolutely, i agree with that, thanks for valuable info, i will keep it in my mind, and for this project i have 3 classes only and its functionality can be implemented directly. for readability sake, i separated them in classes.
Title: Re: Car Racing For Beginners
Post by: Mortal on December 04, 2015, 08:23:40 am
UPDATE


Demo:
http://www.youtube.com/watch?v=-FEmbhtfJiI
Title: Re: Car Racing For Beginners : Finished
Post by: Brax on December 04, 2015, 04:51:31 pm
Looks awesome! :D
Title: Re: Car Racing For Beginners : Finished
Post by: Mortal on December 04, 2015, 05:17:57 pm
Looks awesome! :D
thanks Brax, i'm so glad you like it
Title: Re: Car Racing For Beginners : Finished
Post by: Hapax on December 05, 2015, 04:50:01 am
Looks good. You've managed to reproduce the Javascript demo version in the tutorial in C++ with SFML rather well!  :)

Now fix the cars so that you can't always see the right-hand side of them  ;)
Title: Re: Car Racing For Beginners : Finished
Post by: Mortal on December 05, 2015, 08:57:29 am
Looks good. You've managed to reproduce the Javascript demo version in the tutorial in C++ with SFML rather well!  :)
thanks Hapax, it seems after all, it is easy to change code from HTML5/javascript to c++/SFML. (IMHO), javascript is C/C++ like no extra job needed to convert it. however ,HTML5 is bit harder but it can be managed. it took me 2 days to get familiar with HTML5/javascript synthetics and code's data and strictures, to be able to convert them to C++/SFML.

Now fix the cars so that you can't always see the right-hand side of them  ;)
yeah, this is indeed a problem, also, i left the AI implementation it is bit ineffective even in original tutorial, for example, if there is heavy traffic ahead the cars rubberbanding left and then right as they try to squeeze through a gap between 2 other vehicles. this is not good and it gives bad expression of game, it needs to rewrite a new robust AI algorithm.

and for textures unfortunately the origin sprite-sheet has only the right-hand textures of cars, i don't know how make new textures for them. it needs artist, surely i'm not :-\
Title: Re: Car Racing For Beginners : Finished
Post by: Hapax on December 05, 2015, 11:01:30 pm
and for textures unfortunately the origin sprite-sheet has only the right-hand textures of cars, i don't know how make new textures for them. it needs artist, surely i'm not :-\
Flip the horizontal scale of the sprite.
e.g.
if the sprite's scale is 2x2, make it -2x2 (notice the negative width)
Voila! The left side of the car  ;)
Title: Re: Car Racing For Beginners : Finished
Post by: Mortal on December 06, 2015, 04:46:34 am
Flip the horizontal scale of the sprite.
e.g.
if the sprite's scale is 2x2, make it -2x2 (notice the negative width)
Voila! The left side of the car  ;)
oh, that's clever :)
i always wondering what does negative value for scaling mean as mentioned in transform tutorial in sfml official site.
now, it much better even it needs more works to get perfect view for cars.   
Title: Re: Car Racing For Beginners : Finished
Post by: Hapax on February 11, 2016, 08:43:03 pm
I randomly wandering onto this thread again so I watched the videos again! I still like how it looks :) Did you ever improve the car side views? ;D

Unfortunately, while re-watching these videos, I noticed something else  :(

When objects are passing the car (very close to the camera), they rise upwards. You can see it in your videos for v2 and for v3. To see what I mean, just drive close to a road-side object (that is near the road) and pass it slowly.
Title: Re: Car Racing For Beginners : Finished
Post by: Mortal on February 12, 2016, 01:23:01 pm
I randomly wandering onto this thread again so I watched the videos again! I still like how it looks :) Did you ever improve the car side views? ;D
thank you, yes i did it, but some of cars were drawing with large side view angle and its movement didn't looks appropriate when i flipped their textures on road curves, only one car that's fit the flipping.

Unfortunately, while re-watching these videos, I noticed something else  :(

When objects are passing the car (very close to the camera), they rise upwards. You can see it in your videos for v2 and for v3. To see what I mean, just drive close to a road-side object (that is near the road) and pass it slowly.
yes, i did notice  that and it is indeed annoying, i tried to fixed but no avail  :-\
i'm currently working in Wolfenstein 3D game engine still not finished but i did level and sliding door and its code need bit refactory.
probably i will post it in screenshot thread soon.