91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 9KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-22
  • 語言: Python
  • 標簽: python??

資源簡介

基于python的猜單詞游戲,里面有海龜模塊的調用,也有graphics做圖形界面的例子,可以幫助你們學習游戲開發的基本思路以及部分模塊的調用

資源截圖

代碼片段和文件信息

#?1:?Setup?Your?Python?Program?File?project2.py
#
#?Name:YAHUI?SUN
#?Program:?Project?#2
#?Description:?Guess?Master?2.0?In?this?graphical?veion?of?the?game
#?the?player?must?still?guess?the?letters?in?a?random?word?selected
#?from?the?words.txt?file?however?in?each?round?when?a?player?correctly
#?guesses?all?the?characters?in?a?word?a?new?round?begins?and?they?have
#?a?new?word?to?guess.?Players?earn?points?as?they?win?each?round

from?graphics?import?*
import?sys
from?turtle?import?*


####?Util?methods?to?reduce?duplicated?codes?####
#?from?graphics.graphics?import?Point?Rectangle?GraphWin?Text?Circle?Polygon

def?draw_text(win?pt?text?color=‘black‘?size=16?style=‘normal‘):
????text?=?Text(pt?text)
????text.setTextColor(color)
????text.setstyle(style)
????text.setSize(size)
????text.draw(win)
????return?text


def?draw_circle(win?pt?radius?color):
????circle?=?Circle(pt?radius)
????circle.setFill(color)
????circle.draw(win)
????return?circle


def?draw_rect(win?x?y?width?height?color):
????rect?=?Rectangle(Point(x?y)?Point(x?+?width?y?+?height))
????rect.setFill(color)
????rect.draw(win)
????return?rect


def?draw_poly(win?x1?x2?x3?y1?y2?color):
????‘‘‘Draw?poly:?(x1?y1)?(x2y1)?(x3?y2)?(x3-(x2-x1)?y2)?‘‘‘
????poly?=?Polygon(Point(x1?y1)?Point(x2?y1)?Point(x3?y2)?Point(x3?-?x2?+?x1?y2))
????poly.setFill(color)
????poly.draw(win)
????return?poly


def?is_inside_rect(point?rect):
????if?rect.p1.x?????????if?rect.p1.y?????????????return?True
????return?False


def?is_inside_circle(point?circle):
????center?=?circle.getCenter()
????dx?dy?=?center.getX()?-?point.getX()?center.getY()?-?point.getY()
????dist?radius?=?dx?*?dx?+?dy?*?dy?circle.getRadius()
????return?dist?

#?check?for?mouse?clicks?to?the?hints_rect

#?Check?for?mouse?clicks?in?the?control?panel
def?control_mouse_check(ctrl_win?new_rect?quit_rect?hints_rect):
????click_point?=?ctrl_win.checkMouse()
????if?click_point?is?not?None:
????????if?is_inside_rect(click_point?quit_rect):
????????????return?0
????????elif?is_inside_rect(click_point?new_rect):
????????????return?1
????????elif?is_inside_rect(click_point?hints_rect):
????????????return?2
????return?3


def?draw_score(win?score_text?score):
????if?score_text?is?not?None:
????????score_text.undraw()
????return?draw_text(win?Point(250?20)?‘SCORE:??‘?+?str(score)?‘black‘?16?‘normal‘)


def?draw_secret_char(win?i?secret_word):
????word_len?=?len(secret_word)
????rect_width?pt_y?rect_list?=?50?40?[]
????pt_x?=?250?-?word_len?*?rect_width?/?2
????pt_x?+=?i?*?rect_width
????draw_text(win?Point(pt_x?+?rect_width?/?2?pt_y?+?rect_width?/?2)?secret_word[i]?‘black‘?16?‘normal‘)


#?7:?Win?a?Round
def?win_the_game(game_win?context):
????#?draw?win?the?game
????draw_text(game_win?Point(250?250)?‘YOU?WIN?-?BOILER?UP!‘?‘grey‘?24?‘bold‘)
????draw_text(game_win?Point(250?280)?‘Click?to?continue‘?‘grey

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2019-12-07?17:08??單詞游戲\
?????文件???????14896??2019-12-07?17:06??單詞游戲\project2(1)(1)(1)(1)(1)(2).py
?????文件????????9001??2019-12-06?15:38??單詞游戲\words.txt

評論

共有 條評論