Code-It-Yourself! Retro Arcade Racing Game - Programming from Scratch (Quick and Simple C++)

Поделиться
HTML-код
  • Опубликовано: 19 окт 2024

Комментарии • 304

  • @tratzz84
    @tratzz84 5 лет назад +200

    Somehow it makes me feel like watching Bob Ross making a painting. Loved it, thanks!

    • @GregoryTheGr8ster
      @GregoryTheGr8ster 5 лет назад +1

      Gr8 minds think alike! I noticed the same Bob Ross similarity recently, though on a different video.

    • @jwdonal
      @jwdonal 5 лет назад

      You are so right. :)

    • @decapent316
      @decapent316 4 года назад

      This is exactly what I was thinking.

  • @bane_37
    @bane_37 6 лет назад +106

    You are amazing. I am such a visual learner and for years I read about pseudo 3d and the math's involved and never really understood it until this video. You were able to visually show me how the code/math translates to the screen in an easy to understand way. Thank you so much!

    • @javidx9
      @javidx9  6 лет назад +17

      Hi bane, thanks and no problem! I'm very much a visual learner too, that's why I like to do lots of little programs to learn about specific things.

    • @abual.yaceininformation3147
      @abual.yaceininformation3147 2 года назад

      pleasIf you please, your WhatsApp number is right

  • @researchandbuild1751
    @researchandbuild1751 5 лет назад +24

    This is a great video because it teaches you how to think at the base level, that most games are basic math. It's easy to get caught up in complexity of modern game engines (sprites, rigidbodies, collisions, etc, etc) and overlook the simple solutions for things. Also, I always wondered how they made these old racing games.
    Thanks for this!

    • @javidx9
      @javidx9  5 лет назад +7

      Hey R&B, my pleasure. You're right, too many programming videos emphasize the end result and not the journey - thats what I try to do on this channel.

  • @metox3388
    @metox3388 4 года назад +3

    Really well done! It reminds me a lot in "Buggy boy" which I played on a Commodore C64. Thank you so much for sharing your knowledge to the world. I have learned so many things from you.

    • @achtsekundenfurz7876
      @achtsekundenfurz7876 3 года назад

      There's a remake underway.
      It's called _Buggy the vampire slayer_ - and it's gonna suck more than the vampires ever did...
      #GamingIn2020 ;)

  • @rallokkcaz
    @rallokkcaz 6 лет назад +13

    Javid, these videos are so inspiring and easy to follow. Thank you so much for this.

    • @javidx9
      @javidx9  6 лет назад +4

      Hey thanks rallokkcaz, my pleasure!

  • @pedestrian9287
    @pedestrian9287 4 года назад +9

    Amazing video. Just wish I could think and come up with something like this. The math alone is not too advance but the way it's used is clever.
    Thanks for the video!

  • @RukkunSensu
    @RukkunSensu 4 года назад +2

    Thanks for uploading this tutorial, I'm trying to do a game in Unity(C#) with pixelArt and i was lack of concepts and ideas.
    This was very helpfull. The other viewers are right, you are the Bob Ross of Coding.

    • @RukkunSensu
      @RukkunSensu 4 года назад

      sorry for my bad english, still learning

  • @mrDalien
    @mrDalien 2 года назад +7

    No hablo tu idioma, pero tu código habla por sí mismo. Eres un excelente programador, y si explicas como programas, pues, eres asombroso. Gracias por el video! Necesitaba un ejemplo para hacer un juego así, desde la consola de comandos.

  • @paul8028
    @paul8028 6 лет назад +13

    Excellent video and for the length of it, it's not boring at all like many others. Very well presented and explained. Congratulations.

    • @javidx9
      @javidx9  6 лет назад +3

      Thanks Pablo!

    • @paul8028
      @paul8028 6 лет назад +1

      Sir Lone Coder, I have a question for you, if you can spare the time: your video was very helpful in understanding some basics and i even implemented it using LibGDX, but i want to achieve roads like Cisco Heat or Outrun, that are made of sprites. I'm trying to understand how its done, but is giving me some difficulties. How can I render tracks like this video but using sprites?

  • @REDFOGSX
    @REDFOGSX 4 месяца назад +1

    I recently started to play my old Road Rash game and as someone using Unreal Engine, I can't stop thinking how they could deliver that feeling of 3D collisions when hitting the car, or when vehicles hit the AI ​​at an intersection without being 3D. It would be amazing to have an additional video to this video even if it is 6 years old. 😁

  • @higgins007
    @higgins007 6 лет назад +3

    Such a brilliant illustration of putting basic (relatively) mathematics principles to practical use. Me likey! :)

    • @javidx9
      @javidx9  6 лет назад +3

      Cheers Paul, more often than not, you only need simple maths to create cool things!

  • @dlg9581
    @dlg9581 3 года назад +1

    I have always struggled trying to code a 2d racing game with java. With yours insights, I made a lot of progress.

  • @techbear82
    @techbear82 5 лет назад +2

    You are god-sent. Thank you for sharing this knowledge. F1 Race was one of the games I played as a child on the NES. Thank you.

  • @JM_Traslo
    @JM_Traslo 4 года назад +4

    I think the one big difference here might be that you let the player move away from the center. Taking something like Hang-on / Super Hang-On, you'll see the style was to keep the player dead-center and instead offset the track itself to simulate player movement.

  • @cheaterman49
    @cheaterman49 5 лет назад +1

    I think I agree with your conclusion, and it's the sort of thought I always have after watching your videos - there's nothing particularly difficult here, except maybe thinking of the interactions between all the simple things that are needed - the things themselves are simple, but how they work together is of course a bit more complicated.

    • @javidx9
      @javidx9  5 лет назад

      Thats exactly it, the components on their own are always quite simple, and with experience and practice, you can form those simple components into complex machines.

  • @darryljf7215
    @darryljf7215 4 года назад +1

    Great job explaining.
    I used to play Lotus Turbo Esprit on the Amiga in the early 90's. I was learning C pgmg at the time but I could never work out how they made these type of car racing games. Now I know and it's not as hard as I thought it was !

  • @elaguy3549
    @elaguy3549 6 лет назад +1

    Thanks for the video! It's nice to see a video game programming video have explanations for the code instead of just typing it with some music in the background. Keep up the good work!

    • @javidx9
      @javidx9  6 лет назад

      Thanks Elaguy!

  • @adamfryman6789
    @adamfryman6789 2 года назад +1

    Enjoyed this tutorial, used it to do the same thing in javascript on a canvas. Instead of plotting pixels though I turned them into rects and just had 5 draw calls per row

  • @chenlin-z2d
    @chenlin-z2d 10 месяцев назад

    It's cool, I like it,I'm a student, I' m interested in games, and now I have learned C++,this video is helpful for me. Thank you for sharing.

  • @andresmata8859
    @andresmata8859 6 лет назад +3

    I love your videos, but this one in particular is awesome! Thanks for the great series.

    • @javidx9
      @javidx9  6 лет назад

      Hi Andres, thanks man, I like this one too, one of my faves :D

  • @the-code-provider
    @the-code-provider 7 лет назад +2

    Man, you're the BEST RUclipsr of your category.
    Thanks.. Thanks a lot !

    • @javidx9
      @javidx9  7 лет назад +1

      Lol, cheers that means a lot, looks like Discord collapsed!

    • @the-code-provider
      @the-code-provider 7 лет назад

      Yes, their server often crash since this morning :-/

  • @sergiyradonezhsky634
    @sergiyradonezhsky634 4 года назад +1

    now, the question is, after many many videos watched, have I actually learned to code it myself? answer is no. but that's cuz i'm dumb these videos are absolutely brilliant mate.

    • @frundok
      @frundok 3 года назад

      The whole point of the videos is to teach you how to code so you're basically saying his videos were useless lol

  • @spjewkes
    @spjewkes 7 лет назад +6

    I stumbled across your video and it's very good. You've inspired me to try and do more of this sort of thing. I like the use of the console to do the graphics. A neat idea and side-steps a large amount of set-up and fiddling with APIs, allowing you to get to the real meat of the problem. I just need to find a similar solution on the Mac :)

    • @javidx9
      @javidx9  7 лет назад +1

      Hi Steve. I completely agree! On some of my other videos the community has had discussions and posted source regarding mac and Linux implementations with varying degrees of success. I'd point you there but I'm out and about at the moment.

    • @spjewkes
      @spjewkes 7 лет назад

      Not a problem. I'm happy to go through more of your videos and read the comments :)

  • @Teuopoty
    @Teuopoty 5 лет назад +2

    It reminds me of a game I played in my childhood. Top gear from Super Nitendo. I liked it a lot.

  • @tctrainconstruct2592
    @tctrainconstruct2592 4 года назад +6

    I converted it to the PGE and it still fits in 250 lines of code.
    I also shrunk the car a bit, lowered the lap times to 3, and changed the resolution to 256x220 (the same as a SNES or a NES) and added an FPS counter.

    • @davep7176
      @davep7176 Год назад

      Hey, I know it was 2 years ago, but still worth asking... Did you keep and share the code anywhere? I'd love to see the finished, concise version to compare to my own project. Thanks

  • @thisismyapple6858
    @thisismyapple6858 4 года назад +1

    I am so glad that I understand the mafs he talking about

  • @code-dredd
    @code-dredd 5 лет назад +1

    -"But the player will never know that they're nonsense" -javid@14:23
    -"They'll never know.... because you won't be alive to tell them." -Thanos@2019
    :0!

  • @FredM80
    @FredM80 7 лет назад +1

    I really like these old algorithms to make pseudo 3D or other tricks to make some graphics, before 3D cards were included into all machines. Thx for this video !

    • @javidx9
      @javidx9  7 лет назад

      No problem Fred, Cheers!

  • @JaimeFins
    @JaimeFins 5 лет назад +2

    Indeed, ur really amazing. I'm learning a lot with you. I would love too see a 2nd part of this tutorial on how to implement billboards and other cars and colisions ;)

  • @davidchan8732
    @davidchan8732 4 года назад

    I just like this kind of tutorial that program retrospect games from scratch

  • @marcosadrian65
    @marcosadrian65 2 года назад +1

    It's amazing how you did this I will try to replicate in Godot engine I only wonder how do you will handle hills here?

  • @decapent316
    @decapent316 4 года назад

    You really have a knack for explaining all of this! If i would subscribe twice if i could

  • @surprisingstuff
    @surprisingstuff 5 лет назад

    These are brilliant, so glad I found this channel.

  • @SeNniN06
    @SeNniN06 7 лет назад +1

    I've been thinking of making one of these. Will sit down one day and give it a shot now. Thanks. :]

    • @javidx9
      @javidx9  7 лет назад

      Hi SeNniN, that's great news - good luck!

  • @josegabrielgruber
    @josegabrielgruber Год назад

    Such a simple and rich video, nice work!

  • @karenlutas6778
    @karenlutas6778 4 года назад +1

    recently I been looking for good content thanks

    • @javidx9
      @javidx9  4 года назад

      Hey thanks Karen, I get a lot of comments now, but ones like this make it all worth while!

  • @logosknight54
    @logosknight54 5 лет назад

    I have never done any of this before. But you motivate me to get into it

  • @deejons5760
    @deejons5760 11 дней назад

    I wanted to do the project, but I didn't understand the slightest how to do it after watching this video, and making the C++ makelists is the hardest thing for me currently.

  • @PhilBoswell
    @PhilBoswell 6 лет назад +10

    I watched your video on using Splines and now I'm wondering whether that could be combined with this to allow for a funky Track Editor…

    • @javidx9
      @javidx9  6 лет назад +3

      Lol, wait for another two videos! 😂

  • @GreatHacker1
    @GreatHacker1 5 лет назад

    Your accent looks very much like British, it is quite cool. Nice video bro. Thanks

    • @javidx9
      @javidx9  5 лет назад +1

      Thanks! There could be a reason for that 😉

  • @endoflevelboss
    @endoflevelboss 2 года назад

    "It's simple tricks like this that can create a much more compelling gameplay experience". Compelling gameplay experience? Wow those are some powerful words. While you're going down that path how about, I'm going to add some hills to further enhance the exhilaration and serve as a visceral adrenalin driver on the corners submerging the player in an alternate F1 reality. That's the same sort of remark isn't it... Anyway good video and nice ponytail cupcake!

  • @2kBofFun
    @2kBofFun Год назад

    It was really nice to watch, I do wonder how close this is to original Pole Position like games. Somehow I would have liked it even better if it was non-object code with integer calculations instead of floats and sines.

  • @BrekMartin
    @BrekMartin 7 лет назад +1

    Very nice again :) if I had the room, I think I'd prefer this in my microcontroller. Great that you have some more viewers onboard!

    • @javidx9
      @javidx9  7 лет назад +1

      I was considering your micro project when I was editing :-) On the one hand, it requires very little RAM as the whole screen (except for the car) is generated each frame, but on the other, I use loads of the new C++ stuff, which of course wraps up loads of micro instructions - it would certainly be a challenge.

    • @BrekMartin
      @BrekMartin 7 лет назад +1

      Just checking in again for a refresher :D It’s working on the Sony PSP, but only for a few frames and appears to get stuck (but not crash). It behaves the same full screen 480x272, or just using 160x100. I haven’t found or remembered how to use any hardware timer yet, so not sure what to do with “elapsed time”. I’ve tried incrementing it for each frame, and leaving it constant. Not sure if that’s a running time, or the time between frames. I see the white line, and a straight, and then I think a right turn. If I were to screen shot it, it does look exactly like what I see on RUclips though. funny stuff :D

    • @javidx9
      @javidx9  7 лет назад

      I would imagine leaving the elapsed time (between frames) constant would be correct (ideally something similar to the frame rate of the system) if there's no hardware timer, I guess it would just speed up and slow down depending on the CPU load but should remain playable. I don't believe I accumulate time directly as part of the functioning of the algorithm, and I can't think of any stall risks other than vectors not behaving, but I imagine your code is not 1:1 like mine :D. Could it be that the algo thinks the car is off the track and sets the speed to 0? But... hang on... more interestingly, you've got something like this running on a PSP? I'd love to see that (and the code)!

    • @BrekMartin
      @BrekMartin 7 лет назад

      I’m totally trying to steal this, only changing what needs be for the platform, and in plain C the track is a pair of float arrays, your ASCII blocks are pixels in a frame buffer. ASCII would be fine but it’s a small screen anyway. It’s been a ling time for the PSP, but I think it would do this 30-60fps, so that’s 30.0? I’ll definitely give it another look tomorrow, and happy to share. I haven’t even printed out those debug values yet, and the car is misbehaving, yes.. watching the x value for that would help too.

    • @javidx9
      @javidx9  7 лет назад

      It would be 1.0/30.0 for the elapsed time then. This may explain a few things, as all the interpolation assumes the elapsed time will be tiny - In fact it may fall to pieces with an elapsed time >= 0.1 (10fps).

  • @valleykid6577
    @valleykid6577 4 года назад

    I need to say man, you've done a wonderful job at this.
    I've programmed professionally for 20 years, and I admit to learning a few things from you in some of the videos.
    keep it up!

  • @PauloConstantino167
    @PauloConstantino167 6 лет назад

    Lovely, but in fact the road should not disappear when it hits the vertical middle of the screen! That means a slope downwards. If the road is in fact flat, it should go on getting smaller and smaller till it hits the horizon at a point. If there is a bend instead, then it should show on the screen far away. See what I mean ?

  • @debrucey
    @debrucey 5 лет назад +16

    I’d love to know how this was implemented on retro machines considering most of them didn’t have floating point math or an efficient way of calculating trigonometric functions.

    • @javidx9
      @javidx9  5 лет назад +11

      Anything floating point can do, can also be done using fixed point maths, and some really elegant and crazy hacks exploiting the properties of binary numbers.

    • @jeffthecoder
      @jeffthecoder 4 года назад +2

      Hmm, well, an 8-bit byte can hold a fixed point value between 0 and 255. With a little imagination it can alternatively be represented as a value between 0.0 and 25.5, or a value between 0.00 and 2.55. As far as calculating goes, pretty much anything outside of simple addition and subtraction isn't really possible on the fly if you want the game to run faster than 1 frame per second. You'd want to store precalculated answers in memory in a look-up-table/array so that you can then get an "instant answer".

    • @javidx9
      @javidx9  4 года назад +8

      Thats not quite accurate. Assuming 8 bits, being split 4.4 and the split is arbitrary, the left hand side could represent 0 to 15, and the right hand side, represents between 0 and 1 with a resolution of 1/16th. Addition and subtraction do remain unaltered, multiplication and division need to be tracked and performed in a larger word width, which you can then shift back into place. More often than not in fixed point maths you engineer the solution in such a way that fixed point can be exploited readily, i.e. you cant just drop it in place. Tracking the scaling can become fiddly too, butt since youve engineered the solution, it is likely you know the domains you are operating within, potentially eliminating any "post processing" requirements of the scaling operations youve performed.

    • @achtsekundenfurz7876
      @achtsekundenfurz7876 3 года назад

      Fixed point is pretty much the answer, and the early machines didn't have an OS either, so almost the entire RAM was available to the program.
      Calculating the width of the road once per line rather than once every pixel (see ~ 05:10 to 06:00) can't hurt either. :P

  • @CraigPerry
    @CraigPerry 3 года назад

    This channel is really well done

  • @stcpimus
    @stcpimus 3 года назад

    Hi from colombia from 2021
    you can create 2 variables outside of the cycle
    ScreenWMid = ScreenWidth() / 2
    ScreenHMid = ScreenHeight() / 2
    and you dont need to do the division into the 2cycles
    The same thing, defining variables outside to the cycle
    float fPerspective;
    and then into the cycle
    For example
    fPerspective = y / ScreenHMid

  • @cgiscript415
    @cgiscript415 10 месяцев назад

    30:55 animation stutters when lap is completed and starts again. i believe its because of sin function. resetting distance variable, which is phase shift, interrupt our sin function's cycle. is there any way to achive "smooth transition" between laps ?
    fascinating pseudo3d tutorial btw!!

  • @NeilRoy
    @NeilRoy 4 года назад

    Just watching this again three years later and for your ASCII art for your car you could have used R"( )" instead of L" ". R"()" (including brackets) will not recognize escape codes so you can just put one backslash or forward slash and it will display exactly what you have, no escape codes.
    There was another similar programming page I seen one time where they also added in hills, which you may have seen in similar games from back then. They should be simple to implement but fun. Also things like trees etc... as well as a wall on one side (like in Test Drive). Could be interesting to update this using the pixel game engine with more features etc. I may try my hand at this myself.

  • @krabattondovich8372
    @krabattondovich8372 5 лет назад +1

    Thank you. You almost clear with your explanations, cool. Would you plan to make tutorial about Voronoi diagramma and some voxel engine?

  • @nairrohit83
    @nairrohit83 4 года назад

    Little help some one? Forgive me but maybe i missed something?...I did not quite get the perspective equation with roadwidth. The roadwidth seems should have decreased at lower portion of the screen and increased at higer portions...unless the equation is different because that is not what is happening (and should not !)...Update: I think I got it now!. The coordinates start at top left and there is a Row variable which is actually used for drawing!

  • @tw7522
    @tw7522 5 лет назад +1

    You're doing a great job. I learned a lot. Thanks

    • @javidx9
      @javidx9  5 лет назад

      Hey thanks Tomasz, I appreciate that!

  • @memevel
    @memevel 3 года назад

    Welcome to the CIY channel

  • @erc0re526
    @erc0re526 7 лет назад +1

    Heya ! Super video :D I was wondering, whats the editor you're using on the bottom right screen ?

    • @javidx9
      @javidx9  7 лет назад +1

      Thanks ArcOre! Oh dear I'm showing my age here - its a pre "Emerald" release of "Crimson Editor" - a text editor I can use with my eyes closed. I should make the effort to jump to sublime or something, but I just love it.

    • @erc0re526
      @erc0re526 7 лет назад +1

      Ahhhh Crimson yesss I knew I saw that editor somewhere before haha! Well if it works for you, I don't see why you would change :D

  • @supersolik
    @supersolik 6 лет назад +1

    Very useful video, i've really learned a lot from it, thank you man :)

    • @javidx9
      @javidx9  6 лет назад

      Hi Sergey, no problem, cheers!

  • @ChupoCro
    @ChupoCro 5 лет назад +4

    Hi, let me first say I am really surprised your videos don't have at least 10x more views than they do. You really explain everything in very well organized and concise way. One of your 3D Graphics Engine videos appeared as a recomendation when I opened the RUclips application on my TV a few days ago and since then I watched about 15 of your videos and I plan to watch all of them. Your memories of your first Nintendo are similar to my memories of my ZX Spectrum I got in early 80s :-) Regarding this racing engine, it would be a nice follow up if you implemented a few different styles of displaying the track similar to the ones used back in the days. For example, in a lot of racing games a car (or a motorcycle) was always in the middle of the screen and the track was moving left and right to make an illusion of a turn. One of such games was Full Throttle: ruclips.net/video/cA-5ImcMzpM/видео.html And there were a few where you could drive up and down the hills as in WEC Le Mans: ruclips.net/video/ETJG3p2nW0A/видео.html There was an interesting algorithm for creating the illusion of driving up and down the hills despite of fixed horizon in Full Throttle 2: ruclips.net/video/loDDSiSX8Ls/видео.html It would be really nice if you did one more video showing the implementation of these styles. Maybe you could even introduce a flag to choose if the car will be always in the middle or not. Here are a few more old style racing games to compare the track rendering engines: ruclips.net/video/YNZKgYOMAVk/видео.html If I remember correctly you mentioned VHDL in one of your Sound Sinthesizer videos so I hope in some future videos you are maybe going to cover even that. Regards

  • @obsoletepowercorrupts
    @obsoletepowercorrupts 7 лет назад +1

    This is a neat little simple demonstration. I suppose for an advanced version, one could have the "rows" of track (which vanish into the distance by means of that sine wave) instanciated as objects in a linked list (maybe also hold them as class nodes in a superclass), and so between each, on might "fake" a sort of interpolation so as to make the jagged edges "smoother looking" by means of recursion if an object called ts own process/method via a unary relationship. A settings menu could tweak how much that was done (if it affected performance). Maybe Fourier series might help. Not sure. Or maybe a Fourier transform would do it actually. Yeah actually, if each "jagged bit" is a square, one could "get" eaach corner of the jagged bits as a square and then for each square, separate that into its fourier series (a bunch of sine waves) and hten populate a linked list and interpolate between those. I'm not sure if that would work mind you, because I CBA to try. x'D

    • @javidx9
      @javidx9  7 лет назад +2

      Hi, I like you already! If I understand you correctly, you think that using a connected structure of the visible track rows (maybe 2D patches), that "sort of" settle themselves out biased by a coarse global field of influence, because the patches are spatially aware of their neighborhood, according to some rule set that facilitates interpolation, (breathe in) then you should consider looking at Multilayer Convolutional/Recurrent Neural Networks - they take quite a similar approach to smartly interpolating between steady states. It would certainly be an advanced version of the game. The risk is that the "game" and the rendering in my example are highly coupled, and such an abstract approach would yield a system where you're not sure of the state at all times, therefore can't facilitate the player sensibly. In essence I would still have to have both curvatures calculated anyway, or radically rethink how the game is implemented at all levels. As an intellectual exercise I like these sort of things, but man, that would be a long video!

    • @obsoletepowercorrupts
      @obsoletepowercorrupts 7 лет назад

      Yeah That's pretty much how I imagined it. One could use object or struct or whatever, bu the principle would be vaguely along those lines. I suggested OO since it would be easier to interogate. The suprclass could be grabbed as a save state so as to mess with it further. However, one could do it in assembly I suppose, if one were hardcore and familiar with bit-revorder (bit reversed addressing) and butterly-algorithms, then it really would work on some retro machine I suppose.
      Do you have links for the specific videos on Neural networks you had in mind, so I can have a butcher's gander at them? :) Cheers! I do need to get better at stuff tbqhwy.
      Yes it would be a long video and abstruse nerdery. I wonder though if one might "cheat" by simply having those variables (or methods) available (public) to be called by another software. So for example, one could build the image (or part of it) as a linked list and then you could half-inch some manner of video compression code (FourCC's? Discrete Cosine Transform) and get that to do it (interpolate and compress via Floating Point arithmetic) and "overlay" it (a bit like how Afterburner on the sega Cd was over layed with the 32x part of the game - but do it in software not over a cable). I see Brek Martin did your code example on a PSP. He speaks of video compression and Amiga CD32 FMV cartridge quite a bit and it is cool. That little (psp) device is over 300mhz and so, by my reckoning, can do MPEG2 and some Mpeg4-esque bit twiddling.
      A dynamically linked list (at least doubly linked) would allow a efficiency for the objects (call destructor of objects).
      Actually I shouldn't have suggested "method" as that is Java and would lend itself to garbage collection which could happen at anytime.
      The usage of C++ would not only avoid that but it could allow multiple inheritance so that objects that breifly "exist" in the linked list as a stepping stone for points of interpolation could inherit from multiple objects (choosing what to inherit from depending on performance so as to scale performance on the fly).
      This has got me wondering. Would it be worthwhile to overide the operation (or method in java) of those objects to inherit only what was needed or available at ony one given moment (to scale that performance of the fourier analysis)? With regard to that, I assume the linked list would grow and shrink when you go around corners because you'd end up with an tangent would you not and that would asymptote, like when using the tangent in calculus for instantaneous rate of change? Basically polymorphism so that you keep the curve from becoming blocking (while at the same frame rate) when you go around corners. I can't think how to do it though.

    • @javidx9
      @javidx9  7 лет назад +1

      "choosing what to inherit from depending on performance so as to scale performance on the fly" is the bit that I think you would struggle with. If a system needs to choose the best option, it can only do it if it has evaluated the other options first, even at a coarse approximation level you would need to ensure that performing this evaluation across the set of options is worthwhile. My gut tells me it wouldn't be. That said, GPUs have been doing this for years with MipMaps and such, selectively choosing textures and interpolators depending on what was required, but it could determine the effectiveness of its options before choosing. I get the impression (perhaps incorrectly) that your approach wouldn't know if it was successful until after it's done it. All algorithms like this need to be hard bounded to stop asymptopic behavior. That's why the coding gods gave us atan2!
      I'm intrigued by leveraging a video decoder to fake the drawing with doctored data, but my understanding is the block size is not scaleable? Perhaps really low-res video stream inflated to a higher res where each block is crudely a section of visible track? I may be wrong there though. Video codecs are something I've not spent much time with.

    • @obsoletepowercorrupts
      @obsoletepowercorrupts 7 лет назад

      Aye you're right. It'd be shite.

  • @zPamboli
    @zPamboli 5 лет назад +2

    How can I do this with graphics instead of coloring the console? I'm kinda noob and I don't know what libraries should I use if I need any.

    • @javidx9
      @javidx9  5 лет назад

      Hi Raptor, I released a simple library people can use to get started called "olcPixelGameEngine" which is the tool I use in a lot of my videos - its great for beginners to get playing with graphics very simply

  • @jsceo
    @jsceo 5 лет назад +1

    this is amazing, how and where did you learn that mechanics for making 2d or even pseudo 3d games?

  • @johnconley4955
    @johnconley4955 4 года назад

    I do like watching you and the programming you do...you're obviously a good one. Can you help me on this though? I'm using Notepad++....how do I transfer from ++ to CMD?

  • @pythonsqlite7760
    @pythonsqlite7760 10 месяцев назад

    Im trying to understand sin function here. If i reset the distance variable which helps to control the phase to zero, screen stutters. How can i smoothly reset the distance variable so i have a infinite scrolling road ?

  • @lXBlackWolfXl
    @lXBlackWolfXl 5 лет назад +3

    I got lost when you started talking about sine waves. I've never learned anything about trigonometry. And yes, I'm taking programming classes, so I can make sense of your code (even though I've only learned the basics of C++), but my professor believes that programming classes focus too much on math (a student from our small community college actually won a national contest recently, because he was the only one who actually knew how to code, seriously). The only math class I've taken taught statistics, that's it.
    Also, this looks like an atari racing game. How much of this would be used in a more advanced game, like say the original mario kart? That game has other racers on the track, along with other sprites either on the road or beside it. Would it be that hard to add things like rocks and tufts of grass to the sides of the road? To me it looks like the landscape in Mario Kart is a texture that's been distorted to appear to look like its a flat plane on the ground. This same technic appears to have been used in other SNES games too. Final Fantasy III and Secret of Mana also seem to use this. Though I've noticed that the ground in Final Fantasy III acts like its on a curved surface.

    • @javidx9
      @javidx9  5 лет назад +4

      Hi BlackWolf, To an extent I agree with your professor, the majority of programming doesnt involve any "maths" at all, other than some simple arithmetic. I dont have any advanced maths training beyond what you learn as a teenager, some linear algebra, a bit of calculus and some geometry/trigonometry. Applications such as games or simulations, often exploit more advanced maths because they need to, but the bulk of programming does not. However, consider this. Take the photo viewing app on a phone, you can swipe left and right, and the photos have the feeling of "weight". Someone somewhere has implemented inertia, acceleration and forces, then had to break that up to suit the system of the phone, so most likely they are using the derivatives of these properties. I guess even in basic code, knowing a bit of maths can make you stand out. lol just my 2p.
      Regarding other forms of racing game rendering, I point you towards: ruclips.net/video/ybLZyY655iY/видео.html

  • @gnoath5684
    @gnoath5684 2 года назад

    what's missing now is a low pitched hum that will change based on the player speed.

  • @eddieloius4592
    @eddieloius4592 3 года назад +1

    If you wanted to work at a higher pixel depth (16-bit graphics) ,how much different does this code need to be?

    • @javidx9
      @javidx9  3 года назад +1

      Not very. The successor PixelGameEngine would be almost identical, But works with conventional imagery and files

  • @bubuche1987
    @bubuche1987 Год назад

    I haven't watched the video yet but I wonder if it would be hard to add hills (like in ... many games of this kind) easily. I liked the lotus racing games on Atari St and if Atari was capable of displaying that they should be implementable in Js/c++.

  • @davep7176
    @davep7176 4 года назад

    I used this vid to make a c++ racer in SFML. But say I want to add road signs, for example to tell player when left/right turn is coming, what would be a good way to approach that?

  • @amber1862
    @amber1862 6 лет назад

    Firstly, this is amazing! Secondly, the use of that sine function is confusing me; I understand the formula you used and its purpose, but it looks to me that increasing the x value will increase the frequency, but the graph says it's doing the opposite. I'm aware that I'm probably forgetting something really simple lol. Thanks!

  • @ishida3730
    @ishida3730 4 года назад

    Well, I wan't to make that 'Retro Arcade Racing Game' but My Visual Studio IDE shows some errors in your Header File,
    Please Help!

  • @darkfrei2
    @darkfrei2 9 месяцев назад

    Nice game, thanks for your video!

  • @ZboneWalker
    @ZboneWalker 7 лет назад +1

    Your videos are awesome. Thanks!

    • @javidx9
      @javidx9  7 лет назад

      Hey thanks Zbone, I appreciate that!

  • @abdullahajeebi
    @abdullahajeebi 8 месяцев назад

    This makes me want to code an NES's APU into it.

  • @eddieloius4592
    @eddieloius4592 3 года назад

    What's the earliest point at which you can test or preview what you have on screen?

  • @KJ7JHN
    @KJ7JHN Год назад

    do you have a video on how to install and setup Visual Studio for C++? I've got VS installed, but it's throwing all of these hoops at me. I'm not quite sure how to dance around them. Thanks.

    • @javidx9
      @javidx9  Год назад

      It's pretty default as an installation, make sure you check Desktop Development C++ package though. You need that for the things I show

  • @GamerSaga
    @GamerSaga 6 лет назад

    hello, i copied the text for the olcconsolegameengine and have enabled unicode but i am still getting the error saying i need to enable it when trying to run the program.

  • @رضیہالدین
    @رضیہالدین 6 лет назад

    There's just one phrase for the key idea in the video: "The Simplicity of Complexity."

    • @javidx9
      @javidx9  6 лет назад

      Absolutely! Thanks Razia (according to google!)

  • @1...........123-t9b
    @1...........123-t9b 4 года назад

    Are there multiple versions of the olcConsoleGameEngine? If so, am I using the right version of the olcConsoleGameEngine? I don't know why I have exceptions.
    Sorry about asking you too much. I guess I should stop asking, and try to figure it out myself.
    😳
    👉👈

  • @jimgordon6017
    @jimgordon6017 4 года назад

    You define the meaning of amazing

  • @XDandrewsDX
    @XDandrewsDX 6 лет назад +1

    This is incredible!

    • @javidx9
      @javidx9  5 лет назад

      lol thanks Andre

  • @jianhengmao6815
    @jianhengmao6815 6 лет назад

    Does this method work when you have opponents and obstacles on the track?

  • @alfiewhitson7726
    @alfiewhitson7726 5 лет назад

    very nice however I'm slightly puzzled on as to how exactly it is that you set the character output color in c++ in the way that you have it doing so within your framework ? Just that the only way in which I can actually think of with regards to how to actually change font colours in c++ console applications is using the windows.h and then using the system("set color ") functionality however obviously that returns a string output alongside actually updating the text colour... are you using that function and then clearing the output message off of the screen then drawing the appropriate output chars to the screen

    • @alfiewhitson7726
      @alfiewhitson7726 5 лет назад

      if so, how could this be compensated for in Linux i.e Linux has no system("set color") command as far as I know or would it just be logical to port it to wine ? alongside that I also just thought it might be of some use if you can find some sort of dosbox API which you could use so as to run the game at higher resolutions. For instance, if you used a display driver emulator within dosbox and you have it so that each output char in the original version of the game is paired to a second font which is only 1 pixel in size then that 1 pixel sized font is printed in substitution of the ascii art you were using, then theoretically speaking you could add waaaaay more detail into graphics for example as that could allow you to increase the output bit depth for example, alongside the fact that generally speaking a pixel would have a size in memory of 12 bytes, then you're only having to use up 1 byte worth of memory per "pixel" therefore meaning that you could get higher frame rates because the memory size of the console output buffer would be smaller. also that could mean that you could have the ability to use bitmap graphics instead. I think there's a way in C# at least that you can output images to the console however, I don't know how complex it'd be to convert the code used in that example to C++ nonetheless, here's a link :
      stackoverflow.com/questions/33538527/display-a-image-in-a-console-application

  • @ticiusarakan
    @ticiusarakan 3 года назад

    that's amazing!!! can you explain in you future videos how sega genesis kawasaki game works?

  • @justaprogrammer6031
    @justaprogrammer6031 4 года назад +1

    you dont show where all these files come frome

  • @misterj9817
    @misterj9817 6 лет назад +11

    I love you !

  • @GrowlingM1ke
    @GrowlingM1ke 5 лет назад +2

    I edited the code to make the game a bit more interesting, basically randomly generating the track each time the player starts the program, it's just a few lines of code :)
    Add this to the private:
    float generateBiasedRand(float min, float max, bool biased) {
    if (biased && 0 + (rand() % (1 - 0 + 1)) == 1) {
    float extremeTrack = 0.75 + static_cast (rand()) / (static_cast (RAND_MAX / (0.25)));
    if (0 + (rand() % (1 - 0 + 1)) == 1)
    return extremeTrack;
    else return -extremeTrack;
    }
    else {
    return min + static_cast (rand()) / (static_cast (RAND_MAX / (max - min)));
    }
    }
    Then add this to the OnUserCreate() function in protected:
    // randomly generate track
    srand((unsigned)time(NULL));
    int number = rand() % 3 + 4;
    vecTrack.push_back(make_pair(0.0f, 10.0f)); // Short section for start/finish line
    for (int i = 0; i < number; i++) {
    // making it biased for the turns so the player 50% of the time receives more extreme turns
    vecTrack.push_back(make_pair(generateBiasedRand(-1.0f, 1.0f, true), generateBiasedRand(100.0f, 400.0f, false)));
    vecTrack.push_back(make_pair(0.0f , generateBiasedRand(100.0f, 200.0f, false)));
    }
    Then remove all the previous vecTrack.push_back stuff you had originally
    My next step is to make some sort roadblock that the car will crash into and slow down the player, but I'm wrapping my head around how to implement that.

    • @javidx9
      @javidx9  5 лет назад +1

      Thanks GrowlingMike. Im always pleased when people modify my programs like this - its great to see what people do with them!

  • @mikul9204
    @mikul9204 5 лет назад +1

    I'm making this in java with a 1000 by 800 frame and it's already running at 14 fps all I have made so far is moving forward. Drawing pixel by pixel seems to be hard for it, how could I optimise?

    • @javidx9
      @javidx9  5 лет назад

      Hi Mikul, fundamentally you are making about 11,200,000 draw calls per second, so yes pixel by pixel may be a challenge at such a high resolution. There are two golden rules with rasterizing, 1) Only draw what you can see, 2) Draw as much as you can in one go. Dont forget old games like this were low resolution! Going to a higher resolution probably does require a different approach even though the theory remains the same.

  • @devlogsandgaming
    @devlogsandgaming 4 года назад

    is there a way to add sound to this and make the tracks randomised

  • @d.s.h6629
    @d.s.h6629 Год назад

    love your videos man

  • @ArthurDetaille
    @ArthurDetaille 7 лет назад +4

    THANK YOU A LOT ! i love you SO MUCH !

    • @javidx9
      @javidx9  7 лет назад +4

      lol, YOU'RE WELCOME!, I'm pleased you have FOUND IT USEFUL!

  • @FrostGamingHype
    @FrostGamingHype 2 года назад

    javid how can we make something like that out of console pixel without using your game engine and how to set the console 8 char wide like how you did without the olc console game engine

  • @random5064
    @random5064 4 года назад

    Is there a way to add in shifting up and down gears?

  • @lozD83
    @lozD83 4 года назад

    Finally had a go at this one today. It was so much fun! I used the olcPixelEngine instead of the olcConsoleEngine though. Unfortunately, olcPixelEngine::DrawString() seems to massively drop the frame rate (I'm sure this will have been covered elsewhere), so I instead used just a simple DrawRect() so that I could get a debug representation of the player on the screen :) I can already imagine how I could get AI players into the game. This was truly insightful. Great stuff, Javid!

    • @lozD83
      @lozD83 4 года назад +1

      Now all I need to is to get an implementation running on my Amiga. Rendering pixel by pixel isn't going to cut it though, so it'll be an interesting challenge.

  • @TheSteveTheDragon
    @TheSteveTheDragon 4 года назад

    Would it be possible to do something like this in Unity?

  • @KLNHOMEALONE
    @KLNHOMEALONE 5 лет назад +1

    That's brilliant!

    • @javidx9
      @javidx9  5 лет назад

      Thanks Leonid!

  • @jianhengmao6815
    @jianhengmao6815 6 лет назад

    may I ask whether there is any possibility of improving the graphics so the tracks and mountains looks smoother

    • @javidx9
      @javidx9  6 лет назад

      Hi Jianheng, In this video i use a deliberately low resolution as it emphasizes simplicity - feel free to alter it to a higher resolution, but you may need to adjust some of the other values in the code

    • @jianhengmao6815
      @jianhengmao6815 6 лет назад

      thank you very much, and is it the length of each strips has to be adjusted?

  • @Lambdaphile
    @Lambdaphile 5 месяцев назад

    This is perfect, thanks!

  • @KJ7JHN
    @KJ7JHN 7 месяцев назад

    Being a novice c++ programmer I ask, will this code work in turbo c++?

    • @javidx9
      @javidx9  7 месяцев назад

      No. It uses features that don't exist in Turbo C++. Over the years new things get added to the C++ language, and if I'm not mistaken, Turbo C++ hasn't had an update in almost 30 years.

  • @kasunsanuka
    @kasunsanuka 5 лет назад

    nice work....but i wanna know how to do this in 3D game....plz...can u hlep me...now stduying in game programming collage in Japan.

  • @Haynesybob
    @Haynesybob 6 лет назад +2

    nice vid daddio

    • @javidx9
      @javidx9  6 лет назад

      lol cheers Haynesy XD

  • @quaxiscorporationforresear5557
    @quaxiscorporationforresear5557 6 лет назад +1

    is there any way I can do this on a mac with visual studio on mac. I have Xcode

    • @javidx9
      @javidx9  6 лет назад +1

      Hi JP, the short answer is not really - the mac/linux terminal is a very different tool to the windows command prompt. However, I'm imminently about to release a linux/mac compatible file that emulates what you see in these videos, so non-windows users can join in too.