MagnusJMJ / APME

Ugeopgaver i Æstetisk Programmering. (2. sem.)
0 stars 1 forks source link

Miniex 4 feedback by Mick Holst #4

Closed Epsilon99 closed 7 years ago

Epsilon99 commented 7 years ago

Really nice project and nice clean code (probably the best I've seen thus far, doing these feedbacks).

I love the description and simplicity of your project. It's intuative and it shows that you had a vision (the positive and negative feedback). There will always be bugs, that is why we always strive to be better. If everything worked the first time, programming would not be 'fun' ;)

I have some key points, regarding the code itself. Since your code already is really clean, I thought I would point you in some directions:

Look into functions. I see the way you change color, is by setting what is called a "flag", a way to say 'We need to do something about this'. This means that your code will have to run through the loop, before making the change you're calling. Not a big difference, when it's something aestethic like color. But had it been a important variable, this kind of solution would not be ideal. By making a function, you can make sure that your code runs through it 'right now', instead of handling it later. This also means less ressources used, instead of checking if we set the flag, we just use one if-statement to do the code we wanted (This is not something that will burn down your computer, but slower computer can be a bit slow when you have alot of these).

function draw(){
      if(weWantNewColor == blabla)
            changeColor();
}

function changeColor(){
      red   = random(255);
      green = random(255);
      blue  = random(255);
}

You can go check the Javascript refference here

The issue with the ball getting stuck on walls, I would say might be caused by the rebounce. By just making it xVel *= -bounce; means that you're constantly flipping and dampning the value, so the balls get past the point, it really messes with the physics. This is normal for physics engines, having issue with high velocity and framerate. A hotfix could be to simply put the ball at the edge of the screen, when getting a certain amount stuck in the wall. Would look a bit clunky, but might fix it. Another fix, which is a bit more complex, is to check the upcommingframe, to see if the collision is going to happen, and then adjust the ball so it dosen't go all the way in, but stille maintain the same path and velocity. There are many suggested ways to fix this and you can do a quick google-search for more examples.

I don't if it's a case of preference that you assign values to variables in setup, but I just wanted to point out that it's possible to assign values to a variable when you decalre it in global scope.

Some small other things I could pin point, but I think if contributed with my most 'concerning' thoughts. Still nice to see some clean code and a thoughtout project.