Register    Login    Forum    Search    FAQ

Board index » Everything




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post Posted: April 15th, 2017, 7:24 pm 
User avatar

Joined: April 15th, 2017, 4:14 pm
Posts: 17
Location: Slovakia
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.


Top 
 Profile  
Reply with quote  
 Post Posted: April 16th, 2017, 6:42 am 
Site Admin
User avatar

Joined: December 31st, 2011, 4:53 pm
Posts: 3448
Location: Japan
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


Top 
 Profile  
Reply with quote  
 Post Posted: April 17th, 2017, 3:44 pm 
User avatar

Joined: April 15th, 2017, 4:14 pm
Posts: 17
Location: Slovakia
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.


Top 
 Profile  
Reply with quote  
 Post Posted: April 26th, 2017, 2:01 am 
Site Admin
User avatar

Joined: December 31st, 2011, 4:53 pm
Posts: 3448
Location: Japan
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


Top 
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
 
Post new topic Reply to topic  [ 4 posts ] 

Board index » Everything


 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron