Swift: Conditional code

I chose conditional code because it is an important piece of every program, especially games when the maker doesn’t know exactly what the player will do. This helped me understand how people do this. Conditional code is a piece code that senses something before performing a task. For example, this piece that I completed made Byte walk forward 4 times,(Using for loops,) and each time the code would make him check if he was on a switch. If the switch was no toggled already, then he would toggle it and go back to moving. If it was already toggled, then he would walk on past it.

Though this is not particularly difficult, it still takes me some time to understand if I should use conditions or just plain old code. I feel this will become simpler and more clear to me over time. For some reason, I worry more about loops and if I repeated things too much.

I feel that in the future code, conditional code will become more important and easier for me.

Leave a Reply

Your email address will not be published. Required fields are marked *