User avatar
D.E.L.B.
Posts: 92
Joined: Sat Jun 09, 2012 7:16 pm
Location: Wales, UK
Contact: Website

The Mag Pi Help - Fish Game

Tue Sep 04, 2012 11:23 pm

I get everything apart from these two bits:

Code: Select all

# Make the ball chase Tux
if bx>=tx: bx=bx1
else: bx=bx+1
if by>=ty: by=by1
else: by=by+1
fx=fx4
if fx<=10:
fx=600; fy=random.randint(0,370)
# Collision Detection (Tux & Fish, Tux & Ball)
if fx<=tx+50 and fx>=tx and fy>=ty30
and fy<=ty+70:
toy.play(); fx=600;fy=random.randint(0,370); score +=1
if bx<=tx+40 and bx>=tx40
and by>=ty50
and by<=ty+60:
burp.play(); bx=600; by=15;
lives =
1; tx=280; ty=180
and also this:

Code: Select all

tx=280; ty=180; txd=0; tyd=0
bx=600; by=15
fx=600; fy=random.randint(0,370)
bkcol=[127,212,255]
lives=3; score=0; run = True;
What do the semi colons denote? I'm not sure on the first part I provided though, so if you could go into that in-depth it would be awesome! Thanks.

BlackJack
Posts: 288
Joined: Sat Aug 04, 2012 8:28 am
Contact: Website

Re: The Mag Pi Help - Fish Game

Wed Sep 05, 2012 6:41 am

@D.E.L.B.: The semicolons separate statements within one line. Think of them as having the same effect as line breaks. The Style Guide for Python Code (PEP 8) discourages the use of semicolons in regular source code.

Code: Select all

while not self.asleep():
    sheep += 1

User avatar
D.E.L.B.
Posts: 92
Joined: Sat Jun 09, 2012 7:16 pm
Location: Wales, UK
Contact: Website

Re: The Mag Pi Help - Fish Game

Wed Sep 05, 2012 3:30 pm

Same, I haven't seen any type of source code that does that ever.

So what about the first part, what does that do?

Return to “Python”