Institute of Computer Science
  1. Main page
  2. Teeme ise arvutimänge
ET
Log in

Teeme ise arvutimänge

  • Esileht
  • I RAAMAT
  • II RAAMAT
  • III RAAMAT
  • IV RAAMAT
  • V RAAMAT
  • VI RAAMAT
    • Heli
      • Helifailid
      • Pygame.mixer
      • Helitugevuse kontroll
      • Taustamuusika
    • Veel kasulikku
      • Edetabel - faili kirjutamine
      • Graafilises keskkonnas nime küsimine
    • Kuidas arendada ennast iseseisvalt edasi?

Tausta muusika

Taustamuusikaga on see lugu, et ükskõik kui pika muusikapala ka ei valiks, siis ma ei tea ju tegelikult kunagi ette, kui pikalt mängija minu mängu mängib. Muusika aga võiks mängida kogu aeg, sõltumata programmi kasutuse pikkusest.

Selle probleemi saab aga pygame's lahendada väga kergelt, ainult ühe arvu lisamisega. Nimelt tuleb play() funktsiooni argumendiks panna mistahes negatiivne arv - tavaliselt -1.

Näiteks:

     heli_linnud.play(-1)

Kui aga tahta mingit pala korrata kindel arv korda, näiteks koputuse heli kolm korda, siis tuleb funktsioon play() sisse kirjutada lihtsalt see arv, mitu korda tahetakse helifaili kordamist kuulda.

Näiteks:

     heli_linnud.play(3)
  • Institute of Computer Science
  • Faculty of Science and Technology
  • University of Tartu
In case of technical problems or questions write to:

Contact the course organizers with the organizational and course content questions.
The proprietary copyrights of educational materials belong to the University of Tartu. The use of educational materials is permitted for the purposes and under the conditions provided for in the copyright law for the free use of a work. When using educational materials, the user is obligated to give credit to the author of the educational materials.
The use of educational materials for other purposes is allowed only with the prior written consent of the University of Tartu.
Terms of use for the Courses environment