Game programming I – Week 1

Game programming I - Week 1

 

As we leave week 1, we have learned about loops, conditional statements, debugging and other essential parts in programming.
Above is one of the exercises we were told to do,  tho in fact, I completed three exercises in an attempt to solve the first of them. It does however have a minor modification.

In the exercise I set out to complete, we were told to allow the user to input two values where the highest one would be represented on the screen, thus the use of “if (A > B)” and “else if (B > A)”, however I felt that there was no reason why both numbers shouldn’t be shown and therefor I made that minor modification to make it visually compare the values in front of the user instead of just giving the highest value. An example of the result of this code is “5 is bigger than 3″ which is if the user gives either A or B the value 5 and the other 3.

I used double in case the user wanted to compare decimal numbers and since it is used to compare, a high accuracy would allow the widest array of choices for the user.

The second else if statement has been shown to be used if the user uses a letter on the first value as well, tho I have not determined why, however, if using a letter on the second value it will give a result which is “is bigger than -9.25596e+061″, very mysterious.

Writing for example “5 3″ the first time it asks for a value will make it ask for the second value, while showing the result of the code – “5 is bigger than 3″ pressing any key will complete the program so no other value can actually be added.

Filed under: Game programming I – 5SD022, University Tagged: 2014, 5SD022, programming

About Marcus van Aller

2015 Graphics