Page 2 of 2

Re: Regarding placing/removing blocks in game.

Posted: Mon Oct 10, 2011 7:30 pm
by StormsAndOceans
Taehl wrote:Just a quick note, but you don't need to check if something equals true - unless the variable is nil or false, it will be evaluated as true. Likewise, saying "a and b" ITSELF will equal true or false. It sounds crazy, but short-circuit evaluation is really handy and convenient once you get comfortable with it. For example, your statement:

Code: Select all

if ((x > 0 and x < 21) == true) and ((y > 279 and y < 301) == true) then
could be written as merely

Code: Select all

if x > 0 and x < 21 and y > 279 and y < 301 then
It reads much more easily, doesn't it?
Thanks.

This was another thing that took me FOREVER to run properly. The solution I had was way too bulky, I know.

Re: Regarding placing/removing blocks in game.

Posted: Mon Oct 10, 2011 9:14 pm
by Ensayia
Being bulky isn't too much of a problem while you are learning to program. Your first goal should be getting the results you desire working, code optimization usually comes later if at all.

If you try to optimize everything early you'll likely get frustrated.

Re: Regarding placing/removing blocks in game.

Posted: Mon Oct 10, 2011 10:54 pm
by josefnpat
Cursor Location Division. Smart.