[Tutor PyCZ] Dalsi problem s Livewires
Tomáš Bělonožník
rebelme na gmail.com
Úterý Únor 28 00:44:33 CET 2006
Ahoj,
tak jsem se taky jal vyrabet roboti hru z toho Livewires tutorialu a
zasekl jsem se temer na zacatku. Procital jsem si tuhle konferenci a
snazil jsem se tedy vyvarovat global. Muj problem je asi v tom, ze
dostatecne nerozumim prikazu return, nikde sem ani nenasel nejaky
vyklad. Pokusil jsem se aplikovat postup, ktery platil na vyrobHrace i
na posunHrace, ale háže mi to chybu, kterou si nejsem schopen
prelozit"
Hrac_telo, xh, yh = posunHrace()
TypeError: unpack non-sequence
Muj kod ted vypada takhle:
import random
from livewires import *
begin_graphics()
allow_moveables()
def vyrobHrace():
xh=random.randint(0, 639)
yh=random.randint(0, 479)
Hrac_telo = circle(xh, yh, 5, filled=1, colour=Colour.red)
return xh, yh, Hrac_telo
def posunHrace():
stisky = keys_pressed()
if "2" in stisky:
move_to(Hrac_telo, xh, yh+1)
return xh, yh
xh, yh, Hrac_telo = vyrobHrace() # Jak tak nad tim premyslim tak tuhle
radku nechapu...
while 1:
klavesy = keys_pressed()
Hrac_telo, xh, yh = posunHrace() # Tady je problém
if "q" in klavesy:
break
end_graphics()
Díky za jakoukoliv pomoc, mozna mi bude stacit jen vysvetleni toho return...
--
"Any fool who would die for honor is better off dead." - Cabal Patriarch
"I don't know what the next World War will be fought with, but the
World War after that will be fought with sticks and stones." - Albert
Einstein
Další informace o konferenci Tutor