Python苹果机游戏pygame版
前言
前段时间写过print()版的,发现很难玩,操作起来相当繁琐,只能供新手了解基础代码的运用。对于游戏本身没什么可玩性。
提示:以下是本篇文章正文内容,下面案例可供参考
现在写了个pygame版,相对前面那个版本操作性大大提升。
同样复制代码就能玩。希望大家有什么问题多多交流。
游戏代码
代码如下(示例):
# 复制代码就能运行,如果无法运行就可能是下面两种情况
# 1:没装pygame插件
# 解决:运行此代码 安装
# pip3 install pygame -i https://pypi.tuna.tsinghua.edu.cn/simple
# 2: pip 版本太低
# 解决:运行此代码 升级pip
# python -m pip install --upgrade pip import pygame,sys,random,pygame
from pygame.locals import *def print_text(font,x,y,text,color=(255,255,255)): imgText = font.render(text,True,color) # 文字screen.blit(imgText,(x,y)) # 显示def scores (bomb_y,speed,end): # 得分函数 score = 0if bomb_y == 100:score += stake_1*5if bomb_y == 200:score += stake_1*2if bomb_y == 300: score += stake_3*10if bomb_y == 400: score += stake_5*20if bomb_y == 500:score += stake_5*2if bomb_y == 600:if end == 5:score += speedspeed = 0else:score += 0 if bomb_y == 700:score += stake_1*5if bomb_y == 800:score += stake_2*2if bomb_y == 900:score += stake_2*10if bomb_y == 1000:score += stake_4*10if bomb_y == 1100:score += stake_6*2if bomb_y == 1200:score += stake_6*20if bomb_y == 1300:score += stake_1*5if bomb_y == 1400:score += stake_3*2if bomb_y == 1500:score += stake_3*10if bomb_y == 1600:score += stake_7*20if bomb_y == 1700:score += stake_7*2if bomb_y == 1900:score += stake_1*5if bomb_y == 2000:score += stake_4*2if bomb_y == 2100:score += stake_2*10if bomb_y == 2200:score += stake_4*10if bomb_y == 2300:score += stake_8*50if bomb_y == 2400:score += stake_8*100if bomb_y == 1800 and rans == 0: # 大四喜赔率score = score+stake_1*5*4 if bomb_y == 1800 and rans == 1: # 小三元赔率score = score+stake_2*10+stake_3*10+stake_4*10 if bomb_y == 1800 and rans == 2: # 大三元赔率score = score+stake_5*20+stake_6*20+stake_7*20 if bomb_y == 1800 and rans == 3: # 小熊猫赔率score += stake_8*50if bomb_y == 1800 and rans == 4: # 大熊猫赔率score += stake_8*100if bomb_y == 1800 and rans == 5: # 大满贯赔率score += stake_1*5*4+stake_1*2+stake_2*10*2+stake_2*2+stake_3*10*2+stake_3*2+stake_4*10*2+stake_4*2+stake_5*20+stake_5*2+stake_6*20+stake_6*2+stake_7*20+stake_7*2+stake_8*50+stake_8*100 return score # 赔率def implement(stake_1,stake_2,stake_3,stake_4,stake_5,stake_6,stake_7,stake_8): # 重复押注函数lis_c=[]lis_c.append(stake_1)lis_c.append(stake_2)lis_c.append(stake_3)lis_c.append(stake_4)lis_c.append(stake_5)lis_c.append(stake_6)lis_c.append(stake_7)lis_c.append(stake_8)return lis_cpygame.init() # 游戏
screen = pygame.display.set_mode((600,700)) # 窗口
pygame.display.set_caption("苹果游戏机") # 标题
font1 = pygame.font.SysFont("方正粗黑宋简体",24) # 字体
font2 = pygame.font.SysFont("方正粗黑宋简体",20) # 字体# pygame.mouse.set_visible(False) # 隐藏鼠标箭头
white = 255,255,255
yellow = 230,230,50
red = 220,50,50
black = 0,0,0
green = 0,255,0
kss = False
tips = False # 提示
tips_1= False
lives = 1000 # 生命
score = 0 # 得分
score_c = score
game_ove = True # 游戏是否是结束状态
switch = True # 开关是否开启状态
mouse_x = mouse_y = 0
bomb_x = 0
bomb_y = 0
vel_y = 1
variable = 0 # 圈数
speed = 0 # 彩金
and_s = 0 # 随机数字--比大小用的
rans = 0
end = 0stake_1 = 0 # 押注 苹果
stake_2 = 0 # 押注 橘子
stake_3 = 0 # 押注 芒果
stake_4 = 0 # 押注 铃铛
stake_5 = 0 # 押注 西瓜
stake_6 = 0 # 押注 双柒
stake_7 = 0 # 押注 双星
stake_8 = 0 # 押注 熊猫
lis = [0,0,0,0,0,0,0,0]rand = 0while True:for event in pygame.event.get():if event.type == QUIT:sys.exit()elif event.type == MOUSEMOTION: # 定义鼠标事件,x,ymouse_x,mouse_y = event.pos # 鼠标当前位置move_x,move_y = event.rel # 鼠标移动格数elif event.type == MOUSEBUTTONUP and 520<mouse_x<570 and 530<mouse_y<560: # 单点开始if game_ove:if kss:if stake_1==0 and stake_2==0 and stake_3==0 and stake_4==0 and stake_5==0 and stake_6==0 and stake_7==0 and stake_8==0:if lives > lis[0]+lis[1]+lis[2]+lis[3]+lis[4]+lis[5]+lis[6]+lis[7]:stake_1 = lis[0]stake_2 = lis[1]stake_3 = lis[2]stake_4 = lis[3]stake_5 = lis[4]stake_6 = lis[5]stake_7 = lis[6]stake_8 = lis[7] lives -= lis[0]+lis[1]+lis[2]+lis[3]+lis[4]+lis[5]+lis[6]+lis[7]tips_1 = Falseelse:if score==0:tips_1 = Truegame_ove = True if stake_1>0 or stake_2>0 or stake_3>0 or stake_4>0 or stake_5>0 or stake_6>0 or stake_7>0 or stake_8>0:if score > 0: tips_1 = False stake_1 = 0stake_2 = 0stake_3 = 0stake_4 = 0stake_5 = 0stake_6 = 0stake_7 = 0stake_8 = 0lives += scorescore = 0if end == 5 and bomb_y == 600:speed = 0else:tips_1 = Falsegame_ove = Falserand = random.randint(1,24)*100rans = random.randint(0,5)end = random.randint(0,5)bomb_x += randif bomb_x > 2400:bomb_x -= 2400if tips == False:speed += 100else:tips = Trueelif event.type == MOUSEBUTTONUP and 30<mouse_x<80 and 530<mouse_y<560: # ALL的操作if lives > score:if score > 0:if switch:if score < lives:lives -= scorescore = score*2switch = Falseelse:score = score+lives lives = 0switch = Falseelse:tips_1 = True elif event.type == MOUSEBUTTONUP and 150<mouse_x<200 and 530<mouse_y<560: # 左移if score > 0 and lives > 0 :if score < score_c*2:score += 1lives -= 1 switch = Falsetips = Falsetips_1 = Falseelif event.type == MOUSEBUTTONUP and 230<mouse_x<280 and 530<mouse_y<560: # 右移if score > 0:score -= 1lives += 1 switch = Falsetips = Falsetips_1 = Falseelif event.type == MOUSEBUTTONUP and 330<mouse_x<380 and 530<mouse_y<560: # 1-6tips = Falsetips_1 = Falseif score > 0:and_s = random.randint(1,13)if and_s in [i for i in range(1,7)]:score = score*2score_c = scoreelif and_s == 7 :score = score*2score_c = scoreelse:score = 0stake_1 = 0stake_2 = 0stake_3 = 0stake_4 = 0stake_5 = 0stake_6 = 0stake_7 = 0stake_8 = 0 switch = True elif event.type == MOUSEBUTTONUP and 430<mouse_x<480 and 530<mouse_y<560: # 8-13tips = Falsetips_1 = Falseif score > 0:and_s = random.randint(1,13)if and_s in [i for i in range(8,14)]:score = score*2score_c = scoreelif and_s == 7 :score = score*2score_c = scoreelse:score = 0 stake_1 = 0stake_2 = 0stake_3 = 0stake_4 = 0stake_5 = 0stake_6 = 0stake_7 = 0stake_8 = 0 switch = Trueelif event.type == MOUSEBUTTONUP and 30<mouse_x<80 and 650<mouse_y<680:kss = Truetips = Falsetips_1 = Falseif lives > 0:if stake_8 < 50 and score == 0:stake_8 += 1 lives -=1else:tips_1 = True elif event.type == MOUSEBUTTONUP and 100<mouse_x<150 and 650<mouse_y<680:kss = Truetips = Falsetips_1 = Falseif stake_7 < 50 and score == 0 and lives > 0:stake_7 += 1 lives -=1 elif event.type == MOUSEBUTTONUP and 170<mouse_x<220 and 650<mouse_y<680:kss =Truetips = Falsetips_1 = Falseif stake_6 < 50 and score == 0 and lives > 0:stake_6 += 1 lives -=1 elif event.type == MOUSEBUTTONUP and 240<mouse_x<290 and 650<mouse_y<680:kss = Truetips = Falsetips_1 = Falseif stake_5 < 50 and score == 0 and lives > 0:stake_5 += 1 lives -=1 elif event.type == MOUSEBUTTONUP and 310<mouse_x<360 and 650<mouse_y<680:kss = Truetips = Falsetips_1 = Falseif stake_4 < 50 and score == 0 and lives > 0:stake_4 += 1 lives -=1 elif event.type == MOUSEBUTTONUP and 380<mouse_x<430 and 650<mouse_y<680:kss = Truetips = Falsetips_1 = Falseif stake_3 < 50 and score == 0 and lives > 0:stake_3 += 1 lives -=1 elif event.type == MOUSEBUTTONUP and 450<mouse_x<500 and 650<mouse_y<680:kss = Truetips = Falsetips_1 = Falseif stake_2 < 50 and score == 0 and lives > 0:stake_2 += 1 lives -=1 elif event.type == MOUSEBUTTONUP and 520<mouse_x<570 and 650<mouse_y<680:kss = Truetips = Falsetips_1 = Falseif stake_1 < 50 and score == 0 and lives > 0:stake_1 += 1 lives -=1 keys = pygame.key.get_pressed() # 键盘所有键的集if keys[K_ESCAPE]: # Esc退出键sys.exit()screen.fill((0,0,100)) # 背景if game_ove: # 未启动的时候if tips:print_text(font1,200,250,"押注后才能启动哦",red)if tips_1:print_text(font1,250,250,"积分不足",red) pygame.draw.circle(screen,yellow,(380,135),8,2)pygame.draw.circle(screen,yellow,(460,135),8,2)pygame.draw.circle(screen,yellow,(560,135),8,2)pygame.draw.circle(screen,yellow,(560,195),8,2)pygame.draw.circle(screen,yellow,(560,255),8,2)pygame.draw.circle(screen,yellow,(560,315),8,2)pygame.draw.circle(screen,yellow,(560,375),8,2)pygame.draw.circle(screen,yellow,(560,435),8,2)pygame.draw.circle(screen,yellow,(560,495),8,2)pygame.draw.circle(screen,yellow,(460,495),8,2)pygame.draw.circle(screen,yellow,(380,495),8,2)pygame.draw.circle(screen,yellow,(300,495),8,2)pygame.draw.circle(screen,yellow,(220,495),8,2)pygame.draw.circle(screen,yellow,(140,495),8,2)pygame.draw.circle(screen,yellow,(40,495),8,2)pygame.draw.circle(screen,yellow,(40,435),8,2)pygame.draw.circle(screen,yellow,(40,375),8,2)pygame.draw.circle(screen,yellow,(40,315),8,2)pygame.draw.circle(screen,yellow,(40,255),8,2)pygame.draw.circle(screen,yellow,(40,195),8,2)pygame.draw.circle(screen,yellow,(40,135),8,2)pygame.draw.circle(screen,yellow,(140,135),8,2)pygame.draw.circle(screen,yellow,(220,135),8,2)pygame.draw.circle(screen,yellow,(300,135),8,2)if bomb_y == 100:pygame.draw.circle(screen,red,(380,135),8,0)if bomb_y == 200:pygame.draw.circle(screen,red,(460,135),8,0)if bomb_y == 300: pygame.draw.circle(screen,red,(560,135),8,0)if bomb_y == 400: pygame.draw.circle(screen,red,(560,195),8,0)if bomb_y == 500:pygame.draw.circle(screen,red,(560,255),8,0)if bomb_y == 600:pygame.draw.circle(screen,red,(560,315),8,0)if end == 5:print_text(font1,260,250,"得彩金"+str(speed),green)if bomb_y == 700:pygame.draw.circle(screen,red,(560,375),8,0)if bomb_y == 800:pygame.draw.circle(screen,red,(560,435),8,0)if bomb_y == 900:pygame.draw.circle(screen,red,(560,495),8,0)if bomb_y == 1000:pygame.draw.circle(screen,red,(460,495),8,0)if bomb_y == 1100:pygame.draw.circle(screen,red,(380,495),8,0)if bomb_y == 1200:pygame.draw.circle(screen,red,(300,495),8,0)if bomb_y == 1300:pygame.draw.circle(screen,red,(220,495),8,0)if bomb_y == 1400:pygame.draw.circle(screen,red,(140,495),8,0)if bomb_y == 1500:pygame.draw.circle(screen,red,(40,495),8,0)if bomb_y == 1600:pygame.draw.circle(screen,red,(40,435),8,0)if bomb_y == 1700:pygame.draw.circle(screen,red,(40,375),8,0)if bomb_y == 1900:pygame.draw.circle(screen,red,(40,255),8,0)if bomb_y == 2000:pygame.draw.circle(screen,red,(40,195),8,0)if bomb_y == 2100:pygame.draw.circle(screen,red,(40,135),8,0)if bomb_y == 2200:pygame.draw.circle(screen,red,(140,135),8,0)if bomb_y == 2300:pygame.draw.circle(screen,red,(220,135),8,0)if bomb_y == 2400 or bomb_y == 0:pygame.draw.circle(screen,red,(300,135),8,0)if bomb_y == 1800:pygame.draw.circle(screen,red,(40,315),8,0) if rans == 0:pygame.draw.circle(screen,red,(380,135),8,0)pygame.draw.circle(screen,red,(560,375),8,0)pygame.draw.circle(screen,red,(220,495),8,0)pygame.draw.circle(screen,red,(40,255),8,0)print_text(font1,260,200,"大四喜",green)if rans == 1: pygame.draw.circle(screen,red,(560,135),8,0) pygame.draw.circle(screen,red,(560,495),8,0)pygame.draw.circle(screen,red,(460,495),8,0)print_text(font1,260,200,"小三元",green)if rans == 2:pygame.draw.circle(screen,red,(560,195),8,0)pygame.draw.circle(screen,red,(300,495),8,0)pygame.draw.circle(screen,red,(40,435),8,0)print_text(font1,260,200,"大三元",green) if rans == 3: pygame.draw.circle(screen,red,(220,135),8,0)print_text(font1,260,200,"小熊猫",green) if rans == 4: pygame.draw.circle(screen,red,(300,135),8,0)print_text(font1,260,200,"大熊猫",green) if rans == 5:pygame.draw.circle(screen,red,(380,135),8,0)pygame.draw.circle(screen,red,(460,135),8,0)pygame.draw.circle(screen,red,(560,135),8,0)pygame.draw.circle(screen,red,(560,195),8,0)pygame.draw.circle(screen,red,(560,255),8,0)pygame.draw.circle(screen,red,(560,315),8,0)pygame.draw.circle(screen,red,(560,375),8,0)pygame.draw.circle(screen,red,(560,435),8,0)pygame.draw.circle(screen,red,(560,495),8,0)pygame.draw.circle(screen,red,(460,495),8,0)pygame.draw.circle(screen,red,(380,495),8,0)pygame.draw.circle(screen,red,(300,495),8,0)pygame.draw.circle(screen,red,(220,495),8,0)pygame.draw.circle(screen,red,(140,495),8,0)pygame.draw.circle(screen,red,(40,495),8,0)pygame.draw.circle(screen,red,(40,435),8,0)pygame.draw.circle(screen,red,(40,375),8,0)pygame.draw.circle(screen,red,(40,315),8,0)pygame.draw.circle(screen,red,(40,255),8,0)pygame.draw.circle(screen,red,(40,195),8,0)pygame.draw.circle(screen,red,(40,135),8,0)pygame.draw.circle(screen,red,(140,135),8,0)pygame.draw.circle(screen,red,(220,135),8,0)pygame.draw.circle(screen,red,(300,135),8,0) print_text(font1,260,200,"大满贯",green) else: # 启动的时候bomb_y += 1if bomb_y > bomb_x+2400:bomb_y -= 2400pygame.draw.circle(screen,yellow,(380,135),8,2)pygame.draw.circle(screen,yellow,(460,135),8,2)pygame.draw.circle(screen,yellow,(560,135),8,2)pygame.draw.circle(screen,yellow,(560,195),8,2)pygame.draw.circle(screen,yellow,(560,255),8,2)pygame.draw.circle(screen,yellow,(560,315),8,2)pygame.draw.circle(screen,yellow,(560,375),8,2)pygame.draw.circle(screen,yellow,(560,435),8,2)pygame.draw.circle(screen,yellow,(560,495),8,2)pygame.draw.circle(screen,yellow,(460,495),8,2)pygame.draw.circle(screen,yellow,(380,495),8,2)pygame.draw.circle(screen,yellow,(300,495),8,2)pygame.draw.circle(screen,yellow,(220,495),8,2)pygame.draw.circle(screen,yellow,(140,495),8,2)pygame.draw.circle(screen,yellow,(40,495),8,2)pygame.draw.circle(screen,yellow,(40,435),8,2)pygame.draw.circle(screen,yellow,(40,375),8,2)pygame.draw.circle(screen,yellow,(40,315),8,2)pygame.draw.circle(screen,yellow,(40,255),8,2)pygame.draw.circle(screen,yellow,(40,195),8,2)pygame.draw.circle(screen,yellow,(40,135),8,2)pygame.draw.circle(screen,yellow,(140,135),8,2)pygame.draw.circle(screen,yellow,(220,135),8,2)pygame.draw.circle(screen,yellow,(300,135),8,2) if 0 < bomb_y < 100 or 0 < bomb_y-2400 < 100:pygame.draw.circle(screen,red,(380,135),8,0)if 100 < bomb_y < 200 or 100 < bomb_y-2400 < 200:pygame.draw.circle(screen,red,(460,135),8,0)if 200 < bomb_y < 300 or 200 < bomb_y-2400 < 300: pygame.draw.circle(screen,red,(560,135),8,0)if 300 < bomb_y < 400 or 300 < bomb_y-2400 < 400: pygame.draw.circle(screen,red,(560,195),8,0)if 400 < bomb_y < 500 or 400 < bomb_y-2400 < 500:pygame.draw.circle(screen,red,(560,255),8,0)if 500 < bomb_y < 600 or 500 < bomb_y-2400 < 600:pygame.draw.circle(screen,red,(560,315),8,0)if 600 < bomb_y < 700 or 600 <bomb_y-2400 < 700:pygame.draw.circle(screen,red,(560,375),8,0)if 700 < bomb_y < 800 or 700 <bomb_y-2400 < 800:pygame.draw.circle(screen,red,(560,435),8,0)if 800 < bomb_y < 900 or 800 <bomb_y-2400 < 900:pygame.draw.circle(screen,red,(560,495),8,0)if 900< bomb_y < 1000 or 900 <bomb_y-2400 < 1000:pygame.draw.circle(screen,red,(460,495),8,0)if 1000 < bomb_y < 1100 or 1000 <bomb_y-2400 < 1100:pygame.draw.circle(screen,red,(380,495),8,0)if 1100 < bomb_y < 1200 or 1100 <bomb_y-2400 < 1200:pygame.draw.circle(screen,red,(300,495),8,0)if 1200 < bomb_y < 1300 or 1200 <bomb_y-2400 < 1300:pygame.draw.circle(screen,red,(220,495),8,0)if 1300 < bomb_y < 1400 or 1300 <bomb_y-2400 < 1400:pygame.draw.circle(screen,red,(140,495),8,0)if 1400 < bomb_y < 1500 or 1400 <bomb_y-2400 < 1500:pygame.draw.circle(screen,red,(40,495),8,0)if 1500 < bomb_y < 1600 or 1500 <bomb_y-2400 < 1600:pygame.draw.circle(screen,red,(40,435),8,0)if 1600 < bomb_y < 1700 or 1600 <bomb_y-2400 < 1700:pygame.draw.circle(screen,red,(40,375),8,0)if 1700 < bomb_y < 1800 or 1700 <bomb_y-2400 < 1800:pygame.draw.circle(screen,red,(40,315),8,0)if 1800 < bomb_y < 1900 or 1800 <bomb_y-2400 < 1900:pygame.draw.circle(screen,red,(40,255),8,0)if 1900 < bomb_y < 2000 or 1900 <bomb_y-2400 < 2000:pygame.draw.circle(screen,red,(40,195),8,0)if 2000 < bomb_y < 2100 or 2000 <bomb_y-2400 < 2100:pygame.draw.circle(screen,red,(40,135),8,0)if 2100 < bomb_y < 2200 or 2100 <bomb_y-2400 < 2200:pygame.draw.circle(screen,red,(140,135),8,0)if 2200 < bomb_y < 2300 or 2200 <bomb_y-2400 < 2300:pygame.draw.circle(screen,red,(220,135),8,0)if 2300 < bomb_y < 2400 or 2300 <bomb_y-2400 < 2400:pygame.draw.circle(screen,red,(300,135),8,0)if bomb_y == bomb_x+2400:bomb_y = bomb_x score = scores(bomb_y,speed,end) # 得分函数lis = implement(stake_1,stake_2,stake_3,stake_4,stake_5,stake_6,stake_7,stake_8) # 搜集押注信息if score == 0: stake_1 = 0stake_2 = 0stake_3 = 0stake_4 = 0stake_5 = 0stake_6 = 0stake_7 = 0stake_8 = 0 score_c = score game_ove = Trueprint_text(font1,50,50,"得分:"+str(score),red)print_text(font1,450,50,"积分:"+str(lives),red)print_text(font1,250,50,"彩金:"+str(speed),red)print_text(font2,10,100,"大橘子")print_text(font2,110,100,"大铃铛")print_text(font2,190,100,"小熊猫")print_text(font2,270,100,"大熊猫")print_text(font2,350,100,"大苹果")print_text(font2,430,100,"小苹果")print_text(font2,530,100,"大芒果")print_text(font2,530,160,"大西瓜")print_text(font2,530,220,"小西瓜")print_text(font2,530,280,"绿彩金")print_text(font2,530,340,"大苹果")print_text(font2,530,400,"小橘子")print_text(font2,530,460,"大橘子")print_text(font2,430,460,"大铃铛")print_text(font2,350,460,"小双柒")print_text(font2,270,460,"大双柒")print_text(font2,190,460,"大苹果")print_text(font2,110,460,"小芒果")print_text(font2,10,460,"大芒果")print_text(font2,10,400,"大双星")print_text(font2,10,340,"小双星")print_text(font2,10,280,"红彩金")print_text(font2,10,220,"大苹果")print_text(font2,10,160,"小铃铛")print_text(font1,295,300,str(and_s),red)if 30<mouse_x<80 and 530<mouse_y<560:print_text(font1,30,530,"ALL",red)else: print_text(font1,30,530,"ALL")if 150<mouse_x<200 and 530<mouse_y<560:print_text(font1,150,530,"←",red)else: print_text(font1,150,530,"←")if 230<mouse_x<280 and 530<mouse_y<560: print_text(font1,230,530,"→",red)else: print_text(font1,230,530,"→")if 330<mouse_x<380 and 530<mouse_y<560: print_text(font1,330,530,"1-6",red)else:print_text(font1,330,530,"1-6")if 430<mouse_x<480 and 530<mouse_y<560: print_text(font1,430,530,"8-13",red)else: print_text(font1,430,530,"8-13")if 520<mouse_x<570 and 530<mouse_y<560:print_text(font1,520,530,"启动",red)else: print_text(font1,520,530,"启动") print_text(font1,50,600,str(stake_8),red)if 30<mouse_x<80 and 650<mouse_y<680:print_text(font1,30,650,"熊猫",red)else:print_text(font1,30,650,"熊猫") print_text(font1,120,600,str(stake_7),red)if 100<mouse_x<150 and 650<mouse_y<680:print_text(font1,100,650,"双星",red)else:print_text(font1,100,650,"双星")print_text(font1,190,600,str(stake_6),red)if 170<mouse_x<220 and 650<mouse_y<680:print_text(font1,170,650,"双柒",red)else:print_text(font1,170,650,"双柒")print_text(font1,260,600,str(stake_5),red)if 240<mouse_x<290 and 650<mouse_y<680:print_text(font1,240,650,"西瓜",red)else: print_text(font1,240,650,"西瓜")print_text(font1,330,600,str(stake_4),red)if 310<mouse_x<360 and 650<mouse_y<680:print_text(font1,310,650,"铃铛",red)else:print_text(font1,310,650,"铃铛")print_text(font1,400,600,str(stake_3),red)if 380<mouse_x<430 and 650<mouse_y<680:print_text(font1,380,650,"芒果",red)else:print_text(font1,380,650,"芒果")print_text(font1,470,600,str(stake_2),red)if 450<mouse_x<500 and 650<mouse_y<680:print_text(font1,450,650,"橘子",red)else:print_text(font1,450,650,"橘子")print_text(font1,540,600,str(stake_1),red)if 520<mouse_x<570 and 650<mouse_y<680:print_text(font1,520,650,"苹果",red)else: print_text(font1,520,650,"苹果")pygame.display.update()
Python苹果机游戏pygame版相关推荐
- 苹果机-游戏,80-90儿时的回忆,python打印print()版,适合初学者。
前段时间看到自己写的一篇苹果机游戏文章,发现很多问题.重新整理了一下在发出来. 代码比较初级,适合初学者,代码后都加了注解,方便同学们理解.留了一快绿色奖励彩灯功能没写,如果有兴趣的同学可以写全.有什 ...
- 用Python做一个游戏——简易版贪吃蛇
前言 今天,我来分享个中等级的简易版贪吃蛇,这次不是用turtle库,而是用pygame库和sys库. 1.导入库 我们需要把游戏所用的库导入进来: import pygame import sys ...
- 幼儿园python_[Python]猜数字游戏AI版的实现(幼儿园智商AI)
代码写得很烂,有兴趣的人可以跑一跑: # /usr/bin/env python # -*- encoding=utf-8 -*- import random from itertools impor ...
- python五子棋游戏说明_python实现五子棋游戏(pygame版)
python实现五子棋游戏(pygame版) 发布时间:2020-10-11 17:05:18 来源:脚本之家 阅读:67 作者:king0964 本文实例为大家分享了python五子棋游戏的具体代码 ...
- [圣诞大礼]Macintosh苹果机精品游戏合集
开篇:很多人求MBP...求到MBP问题马上就来了,mac苹果机上软件已经很不错了,PS.office.AutoCAD都有,问题有什么好游戏呢? 年终给大家很多MAC苹果机游戏希望大家喜欢啊. 感谢Z ...
- python编程入门到实践学习笔记——外星人入侵游戏pygame(一 武装飞船)
python编程--外星人入侵游戏pygame(一) 外星人入侵游戏一:武装飞船 安装Pygame 创建窗口及响应用户输入 更改屏幕背景色 创建设置类 创建ship飞船类 重构game_functio ...
- 编写五子棋的完整python代码_python实现五子棋游戏(pygame版)
本文实例为大家分享了python五子棋游戏的具体代码,供大家参考,具体内容如下 目录 简介 实现过程 结语 简介 使用python实现pygame版的五子棋游戏: 环境:Windows系统+pytho ...
- python五子棋游戏控制台版_python实现五子棋游戏(pygame版)
本文实例为大家分享了python五子棋游戏的具体代码,供大家参考,具体内容如下 目录 简介 实现过程 结语 简介 使用python实现pygame版的五子棋游戏: 环境:Windows系统+pytho ...
- python五子棋游戏15*15_python实现五子棋游戏(pygame版)
分享python 编写的五子棋游戏 分享高手给用python编写一个五子棋游戏,需要代码. .心里知道有这么回事,白天就很正常晚上就胡思乱想,事已至此小编们都该向前走一步了. 请用PYTHON编一个小 ...
最新文章
- hbase shelljava 获取多版本的值
- 征战蓝桥 —— 2013年第四届 —— C/C++A组第6题——逆波兰表达式
- bat文件获取当前时间并格式化输出
- VK Cup 2012 Qualification Round 2 C. String Manipulation 1.0 线段树 or 树状数组+二分
- python单词的含义-python
- android view分析工具栏,如何在Android工具栏中使用SearchView
- 使用Bartend提取K3领料数据以实现发料包装标识批量自动打印
- 关于js的match用法
- html怎么用2个caption不换行,caption怎么用
- 企业与个人必备安全测试工具
- Java解析接口返回的xml数据
- 携手独角兽企业,微软正在用AI打造更美好的未来
- 浅析ip地址的分类及地址范围
- 完全弹性碰撞公式推导
- WEBGIS开发 常用开发功能简介 数据处理 标绘 业务数据可视化 视频融合 Cesium EarthSDK
- 数据挖掘之关联规则分析
- 16春季计算机应用基础,西交16春季《计算机应用基础》在线作业及答案
- 单片机STC89C52
- Java 中添加背景音乐
- 三星电视安装Jellyfin