25.11.2014 Views

Treball de recerca - IES Narcís Monturiol

Treball de recerca - IES Narcís Monturiol

Treball de recerca - IES Narcís Monturiol

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.

Bubble Racer: Com crear un vi<strong>de</strong>ojoc amb Blen<strong>de</strong>r<br />

Robert Planas<br />

Recordo que per crear una funció usem l'estructura <strong>de</strong>f nom(arguments). Po<strong>de</strong>m cridar una<br />

funció amb l'estructura nom(paràmetres). Les propietats són fonamentals en les funcions.<br />

Po<strong>de</strong>m veuen un exemple en la funció per processar el temps <strong>de</strong> l'script “interface”. En aquest<br />

cas, sí que ha estat útil per simplificar el codi. Recomano veure el fragment sencer <strong>de</strong>s <strong>de</strong> la<br />

línia 88 a la 140. (Bubble Racer v0.2)<br />

Com po<strong>de</strong>m veure la funció ProcesarTiempo s'encarrega <strong>de</strong> processar la variable tiempo. A<br />

l'ultima línia cri<strong>de</strong>m la funció main, dons tot l'script “interface” s'executa dins d'aquesta<br />

funció. La funció main necessita ser cridada perquè s'executi, ja que main en Python només és<br />

un nom, no te cap propietat especial que impliqui que aquesta és la funció principal a<br />

executar.<br />

L'script superior correspon a l'acció <strong>de</strong> canviar <strong>de</strong> menú, <strong>de</strong> MenuLabel quan pressionem la<br />

tecla “Enter” estant en MenuPos = 3. No només tenim que canviar el valor <strong>de</strong> MenuLabel,<br />

sinó que també hem d'establir les propietats corresponents al menú que volem accedir.<br />

Per acabar, aquí po<strong>de</strong>m veure els fragments corresponents a la selecció <strong>de</strong> la resolució i al<br />

botó <strong>de</strong>sar, encarregat <strong>de</strong> guardar els canvis a l'arxiu conf.txt i <strong>de</strong> reiniciar el joc.<br />

Pàg. 28

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

Saved successfully!

Ooh no, something went wrong!