I tried to make some games

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
User avatar
DEM0N194
Posts: 28
Joined: April 15th, 2017, 4:14 pm
Location: Slovakia
Contact:

I tried to make some games

Post by DEM0N194 » April 15th, 2017, 7:24 pm

Hey, guys, I made some games a while ago ... and I would like to ask if someone could skim through the code and give me some feedback.

Snake
Pong
PooGame

I made these games a couple months ago and I had to take a break from programming for various reason but now I want to get back into it... so if you have any suggestions how I could improve my code or some features that I should add to the games, please do tell me.

Thanks.

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

Re: I tried to make some games

Post by chili » April 16th, 2017, 6:42 am

Hey man, I just took a quick look at pong and snake. Your code looks good. Very logical and easy to follow / understand. Keep up the good work man.

2 things:

I'm not a huge fan of making food a nested class of Snake. Conceptually it seems a little counter-intuitive. What reasoning do you have here?

Also, nice work using a stdlib container for the snake segments, it's the perfect fit, and that actually the example that I was thinking of when I introduce vector<>. I'm wondering why you chose to use deque though?
Chili

User avatar
DEM0N194
Posts: 28
Joined: April 15th, 2017, 4:14 pm
Location: Slovakia
Contact:

Re: I tried to make some games

Post by DEM0N194 » April 17th, 2017, 3:44 pm

I think I was learning about nested classes at the time ... And I thought since food isn't actually used anywhere else outside of snake I could just make it nested ... But know that u mention it Food isn't really a part of the snake so yeah I see what u mean.

As for the deque I first used just a vector, but then I took a look at different containers and read that the deque is most efficient when using push_front, pop_back, ... And since that's what I use for moving the snake I decided to go with deque.

Thanks for the feedback I really appreciate it man.

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

Re: I tried to make some games

Post by chili » April 26th, 2017, 2:01 am

Hmm, actually deque is not such a bad idea. I generally stick to vector<> for performance reasons, but I don't think vector has push_front, so from an ease of use/elegance of code standpoint, deque is pretty good here :)
Chili

Post Reply