11.07.2015 Views

Here - 1000 BiT

Here - 1000 BiT

Here - 1000 BiT

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

THE RIGHT WAY TO SHOOTIt's no good if the diamond has to stop moving while the arrow moves.So when line 70 sees that the "shooting" key is pressed, it doesn't just jump to asubroutine that shoots the arrow across the screen. Instead, it sets a flag. The flag is thevariable S. The flag is set when S< >0.When the flag is set, the computer takes turns moving the arrow one space, then thediamond, then the arrow again, etc.The "move arrow"subroutine has to recognize two things:First, is this a new arrow or just one which already started across?Line 310 does this. S equals 1 only for a new arrow.After each move of the arrow, S gets 1 bigger and X, the position of the arrow, gets 1smaller so the arrow goes to the right.Second, the arrow must be stopped when it gets to the other side of the screen, and thediamond must be told that it can shoot another arrow.Line 316 does this. When S=38, the arrow has moved 38 spaces and is at the otherside of the screen. S is set back to 0, meaning that the diamond is allowed to shootagain. (The arrow was erased in line 315 and no new arrow has been written so thescreen is empty of arrows.)162

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!