Regarding placing/removing blocks in game.

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
StormsAndOceans
Prole
Posts: 18
Joined: Sun Oct 09, 2011 1:12 am

Re: Regarding placing/removing blocks in game.

Post 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.
User avatar
Ensayia
Party member
Posts: 399
Joined: Sat Jun 12, 2010 7:57 pm

Re: Regarding placing/removing blocks in game.

Post 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.
User avatar
josefnpat
Inner party member
Posts: 955
Joined: Wed Oct 05, 2011 1:36 am
Location: your basement
Contact:

Re: Regarding placing/removing blocks in game.

Post by josefnpat »

Cursor Location Division. Smart.
Missing Sentinel Software | Twitter

FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push
Post Reply

Who is online

Users browsing this forum: Amazon [Bot], Bing [Bot], Google [Bot], Semrush [Bot] and 9 guests