Have I done homework right ?

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
barocxPvP
Posts: 11
Joined: January 1st, 2017, 3:56 pm

Have I done homework right ?

Post by barocxPvP » January 1st, 2017, 6:50 pm

Hello guys, in attachments you can find homeworks for video 3 and 4.
If you test code it does same thing as Chilli does. But code itself is much diffrent so I am afraid that I have not got the point of his tutorials.

It would be nice if someone of you test that code and tell me why is it good/bad and is it a point of homework.

And if it is good then, I guess that Chilli should upload his wiki with my code(Because it is more simplier thant his code) or if it is wrong then please explain me where I made a mistake and how can I fix it.

Thanks everyone for feedback and thanks Chilli for such a great tutorials and good seanse of humor :)
EDIT/NOTE: DO NOT FORGET TO DECLARE ALL VARIABLES IN game.h FILE !
Attachments
HomeworksCHECKhw2.zip
Check homework 2.
(47.56 KiB) Downloaded 140 times

trybane@gmail.com
Posts: 109
Joined: August 11th, 2016, 11:17 am

Re: Have I done homework right ?

Post by trybane@gmail.com » January 1st, 2017, 8:22 pm

I haven't been able to download and check your code, but if you accomplished the objective then it probably is good. Simpler is good but not always a good thing. If you want to expand your code in various ways then it might require more refactoring than if you started with a more complex design. But I'll give more feedback after I get home from work.

trybane@gmail.com
Posts: 109
Joined: August 11th, 2016, 11:17 am

Re: Have I done homework right ?

Post by trybane@gmail.com » January 1st, 2017, 11:51 pm

Hey man, just did a quick review and everything looks nice and clean! Though I will admit that I was confused by the use of the long list of variables for the cursor. I wouldn't recommend doing that in the future because what if you need to make it change to a shape that doesn't use the same amount of variables? You'd have to make the program more complex than it would need to. But not to worry, you'll learn easier ways of doing that sort of thing later down the line anyway.

As for these, it looks nice and clean, similar to my own. I think what Chili was originally looking for was when he asked for people to look for a way to control the cursor was keeping the cursor from flying by tapping the button. But the brake with the space bar works just fine to control it so you still completed the homework :D

Anyways, good job and keep it up!

barocxPvP
Posts: 11
Joined: January 1st, 2017, 3:56 pm

Re: Have I done homework right ?

Post by barocxPvP » January 2nd, 2017, 12:07 am

Okey, I will improve my shape changing(list of variables).
Thanks for feedback :D ! I am glad that I done it right.

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

Re: Have I done homework right ?

Post by albinopapa » January 2nd, 2017, 1:32 am

Actually, with the tutorial you are on, this many variables is almost necessary to change the shape of the cross hair. It's always better to have variables instead of magic numbers or constant numbers. Once you cover loops and arrays, you will be able to do the same thing, with less variables, but for now this is fine.

I like how you skip the else blocks by assigning the defaults and only changing the values under the if conditions, I try to use that method whenever possible myself.

I'm not sure if this was intentional or not, but since you are setting both xspeed and yspeed for each button press, you can't get the cross hair to go diagonal. If you want diagonal movement, you should only set the xspeed in the left/right cases, and yspeed in the up/down cases.
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

trybane@gmail.com
Posts: 109
Joined: August 11th, 2016, 11:17 am

Re: Have I done homework right ?

Post by trybane@gmail.com » January 2nd, 2017, 1:40 am

Ah, I didn't notice the lack of diagonal movement. Tis the cost of not actually testing the code and only reading it.

I would agree with setting variables for every position, but without the ability to use functions and make these set during function calls, it makes it hard to see what's going on. Maybe if he'd used comments to label them though. Regardless, he succeeded whether I visually liked it or not :P

Post Reply