PSD-Tutorials.de
Forum für Design, Fotografie & Bildbearbeitung
Tutkit
Agentur
Hilfe
Kontakt
Start
Forum
Aktuelles
Besonderer Inhalt
Foren durchsuchen
Tutorials
News
Anmelden
Kostenlos registrieren
Aktuelles
Suche
Suche
Nur Titel durchsuchen
Von:
Menü
Anmelden
Kostenlos registrieren
App installieren
Installieren
JavaScript ist deaktiviert. Für eine bessere Darstellung aktiviere bitte JavaScript in deinem Browser, bevor du fortfährst.
Du verwendest einen veralteten Browser. Es ist möglich, dass diese oder andere Websites nicht korrekt angezeigt werden.
Du solltest ein Upgrade durchführen oder einen
alternativen Browser
verwenden.
Antworten auf deine Fragen:
Neues Thema erstellen
Start
Forum
Sonstiges
Webdesign, Webentwicklung & Programmierung
C/C++, .NET, Java, Python & andere
Python-Spiel funktioniert nicht ordnungsgemäß
Beitrag
<blockquote data-quote="Ombra" data-source="post: 2741476" data-attributes="member: 605110"><p>Hallo zusammen,</p><p></p><p>ich habe ein Quiz-Spiel erstellt (siehe Code).</p><p>Folgendes sind die Probleme:</p><ul> <li data-xf-list-type="ul">Man muss immer erst einen Klick ins Fenster machen bis das volle GUI angezeigt wird.</li> <li data-xf-list-type="ul">Man kann die Antwortmöglichkeiten nicht anklicken</li> <li data-xf-list-type="ul">Die Zeit läuft nicht.</li> </ul><p>Hier der Code:</p><p>[CODE]WIDTH = 1280</p><p>HEIGHT = 720</p><p></p><p>def draw():</p><p> screen.fill("dim grey")</p><p> screen.draw.filled_rect(main_box, "sky blue")</p><p> screen.draw.filled_rect(timer_box, "sky blue")</p><p> </p><p> for box in answer_boxes:</p><p> screen.draw.filled_rect(box, "orange")</p><p> </p><p> screen.draw.textbox(str(time_left), timer_box, color=("black"))</p><p> screen.draw.textbox(question[0], main_box, color=("black"))</p><p> </p><p> index = 1</p><p> for box in answer_boxes:</p><p> screen.draw.textbox(question[index], box, color=("black"))</p><p> index = index + 1</p><p> </p><p> </p><p>def game_over():</p><p> global question, time_left</p><p> message = "Ende. Du hast %s Fragen richtig" % str(score)</p><p> question = [message, "-","-","-","-", 5]</p><p></p><p>def correct_answer():</p><p> global question, score, time_left</p><p> </p><p> score = score + 1</p><p> if questions:</p><p> question = questions.pop(0)</p><p> time_left = 10</p><p> else:</p><p> print("Ende der Fragen")</p><p> game_over()</p><p></p><p>def on_mouse_down(pos):</p><p> index = 1</p><p> for box in answer_boxes:</p><p> if box.collidepoint(pos):</p><p> print("Du hast angeklickt:" + str(index))</p><p> if index == question[5]:</p><p> print("Das ist richtig!")</p><p> correct_answer()</p><p> else:</p><p> game_over()</p><p> index = index + 1</p><p> </p><p> </p><p></p><p>def update_time_left():</p><p> global time_left</p><p> </p><p> if time_left:</p><p> time_left = time_left - 1</p><p> else:</p><p> game_over()</p><p></p><p>main_box = Rect(0, 0, 820, 240)</p><p>timer_box = Rect(0, 0, 240, 240)</p><p>answer_box1 = Rect(0, 0, 495, 165)</p><p>answer_box2 = Rect(0, 0, 495, 165)</p><p>answer_box3 = Rect(0, 0, 495, 165)</p><p>answer_box4 = Rect(0, 0, 495, 165)</p><p></p><p>main_box.move_ip(50, 40)</p><p>timer_box.move_ip(990, 40)</p><p>answer_box1.move_ip(50, 358)</p><p>answer_box2.move_ip(735, 358)</p><p>answer_box3.move_ip(50, 538)</p><p>answer_box4.move_ip(735, 538)</p><p></p><p>answer_boxes = [answer_box1, answer_box2, answer_box3, answer_box4]</p><p></p><p>score = 0</p><p>time_left = 10</p><p></p><p>q1 = ["Die Hauptstadt von Frankreich ist ...?", "London", "Paris", "Berlin", "Tokio", 2]</p><p>q2 = ["Was ist 5+7?", "12", "10","14","8", 1]</p><p>q3 = ["Was ist der siebte Monat?", "April", "Mai", "Juni", "Juli", 4]</p><p>q4 = ["Welcher Planet ist der kleinste?", "Saturn", "Neptun", "Merkur", "Venus", 3]</p><p>q5 = ["Wo steht der schiefe Turm?", "Mailand", "Pisa", "Florenz", "Rom", 2]</p><p></p><p>questions = [q1, q2, q3, q4, q5]</p><p>question = questions.pop(0)</p><p>clock.schedule_interval(update_time_left, 1.0)[/CODE]</p><p></p><p>Vielen Dank im Voraus!</p><p>PS: Ich bin absoluter Anfänger</p></blockquote><p></p>
[QUOTE="Ombra, post: 2741476, member: 605110"] Hallo zusammen, ich habe ein Quiz-Spiel erstellt (siehe Code). Folgendes sind die Probleme: [LIST] [*]Man muss immer erst einen Klick ins Fenster machen bis das volle GUI angezeigt wird. [*]Man kann die Antwortmöglichkeiten nicht anklicken [*]Die Zeit läuft nicht. [/LIST] Hier der Code: [CODE]WIDTH = 1280 HEIGHT = 720 def draw(): screen.fill("dim grey") screen.draw.filled_rect(main_box, "sky blue") screen.draw.filled_rect(timer_box, "sky blue") for box in answer_boxes: screen.draw.filled_rect(box, "orange") screen.draw.textbox(str(time_left), timer_box, color=("black")) screen.draw.textbox(question[0], main_box, color=("black")) index = 1 for box in answer_boxes: screen.draw.textbox(question[index], box, color=("black")) index = index + 1 def game_over(): global question, time_left message = "Ende. Du hast %s Fragen richtig" % str(score) question = [message, "-","-","-","-", 5] def correct_answer(): global question, score, time_left score = score + 1 if questions: question = questions.pop(0) time_left = 10 else: print("Ende der Fragen") game_over() def on_mouse_down(pos): index = 1 for box in answer_boxes: if box.collidepoint(pos): print("Du hast angeklickt:" + str(index)) if index == question[5]: print("Das ist richtig!") correct_answer() else: game_over() index = index + 1 def update_time_left(): global time_left if time_left: time_left = time_left - 1 else: game_over() main_box = Rect(0, 0, 820, 240) timer_box = Rect(0, 0, 240, 240) answer_box1 = Rect(0, 0, 495, 165) answer_box2 = Rect(0, 0, 495, 165) answer_box3 = Rect(0, 0, 495, 165) answer_box4 = Rect(0, 0, 495, 165) main_box.move_ip(50, 40) timer_box.move_ip(990, 40) answer_box1.move_ip(50, 358) answer_box2.move_ip(735, 358) answer_box3.move_ip(50, 538) answer_box4.move_ip(735, 538) answer_boxes = [answer_box1, answer_box2, answer_box3, answer_box4] score = 0 time_left = 10 q1 = ["Die Hauptstadt von Frankreich ist ...?", "London", "Paris", "Berlin", "Tokio", 2] q2 = ["Was ist 5+7?", "12", "10","14","8", 1] q3 = ["Was ist der siebte Monat?", "April", "Mai", "Juni", "Juli", 4] q4 = ["Welcher Planet ist der kleinste?", "Saturn", "Neptun", "Merkur", "Venus", 3] q5 = ["Wo steht der schiefe Turm?", "Mailand", "Pisa", "Florenz", "Rom", 2] questions = [q1, q2, q3, q4, q5] question = questions.pop(0) clock.schedule_interval(update_time_left, 1.0)[/CODE] Vielen Dank im Voraus! PS: Ich bin absoluter Anfänger [/QUOTE]
Bilder bitte
hier hochladen
und danach über das Bild-Icon (Direktlink vorher kopieren) platzieren.
Zitate einfügen…
Authentifizierung
Wenn ▲ = 7, ▼ = 3, ◇ = 2 und die Summe von ▲ und ▼ durch ◇ geteilt wird, was ist das Ergebnis?
Antworten
Start
Forum
Sonstiges
Webdesign, Webentwicklung & Programmierung
C/C++, .NET, Java, Python & andere
Python-Spiel funktioniert nicht ordnungsgemäß
Oben