C++ Finale - Traffic game

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
noU69
Posts: 1
Joined: June 13th, 2019, 8:37 am

C++ Finale - Traffic game

Post by noU69 » June 13th, 2019, 9:00 am

Hello world!
So, yesterday I took my last exam so now I finally have some damn time to code instead of memorize useless shit to pass. But this summer I got selected for a C# internship which starts in like 2 weeks.
Before that , I want to make a really cool game that will sum up all my knowledge gained over time, kinda like a grand finale.
My idea is: (obviously not original but that s not the point)
A straight line traffic game(sort of a frogger), but with traffic from time to time(I ll attach a photo to explain it), and your goal is not to get hit. The player is a car and has to avoid other cars. Also, I would like to make the game infinite, and it to not be predictible.

So my question is: How can I make the game to generate itself infinitely? I can't find anything but I m sure here I'll find some good answers.
I attached a photo below, thanks for reading *this(haha )
Untitled.png
(44.21 KiB) Not downloaded yet

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: C++ Finale - Traffic game

Post by chili » June 16th, 2019, 3:14 pm

you could represent the game data basically as a std::deque, adding enough so that you can render a new full screen with data to spare. As you move right, you add new level data to the front, and remove from the end. It would be pretty easy for a game that only progresses left-right. full 2d would be trickier, but still very doable.
Chili

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: C++ Finale - Traffic game

Post by albinopapa » June 18th, 2019, 4:06 am

My thought was to wrap the city blocks around as they would be the same, each north/south street would be a vector of automobiles that are randomly generated. As one north/south street leaves the right edge, move ( std::move ) each later vector to the previous vectors, then in the last one start spawning new automobiles.

Chili's method though does have some advantages. One, each block and street configuration could be different, such as buildings and number of lanes. Technically the advantage would be releasing one screens worth of data each time instead of 5+ vectors in my scenario.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

Post Reply