Timeline for Update a value in the function
Current License: CC BY-SA 3.0
11 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 4, 2015 at 19:51 | vote | accept | user7869 | ||
Aug 4, 2015 at 19:49 | comment | added | i_am_david | @user7869 Lucky you two of the best users in CS50 Slack and Stack have answered your question! | |
Aug 4, 2015 at 7:23 | answer | added | curiouskiwi♦ | timeline score: 1 | |
Aug 4, 2015 at 7:20 | answer | added | kzidane | timeline score: 1 | |
Aug 4, 2015 at 4:36 | comment | added | curiouskiwi♦ | You're welcome to do whatever you want. I'm just advising that the breakout distribution code has organized the code in a certain way, with some things broken out as functions and other things to be done in main. | |
Aug 4, 2015 at 4:34 | comment | added | curiouskiwi♦ | you're putting all that into moveBall()? | |
Aug 4, 2015 at 4:29 | comment | added | user7869 | Its not four lines - the ball has to check edge collisions and blocks and paddle collisions thats a lot of lines - if its moved to a function it feels cleaner. | |
Aug 4, 2015 at 4:27 | comment | added | curiouskiwi♦ |
you are essentially moving 4 lines of code from main and creating a function. To me, that's overcomplicating it. Also, you are running into the fact that you can't change the velocity inside your function and have it actually change the one in main, unless you want to return the value to main. In my opinion, moving the ball and setting the velocity based on the ball's position are two separate actions. I have a function that moves the paddle, because it needs to take into account various things (where it is, etc.) but it doesn't need to change any values in main.
|
|
Aug 4, 2015 at 2:30 | comment | added | user7869 | Oh. How come? - it's kinda messy when it's all in main i find. | |
Aug 4, 2015 at 1:34 | comment | added | curiouskiwi♦ |
If this is for breakout , I would only suggest that you don't create your own moveBall function and simply handle the ball movement in main.
|
|
Aug 4, 2015 at 0:56 | history | asked | user7869 | CC BY-SA 3.0 |