fish1.py

这是一个使用Pythonista编写的简单游戏场景实现,包含了场景设置、卡片和汽车的生成、碰撞检测、移动和旋转等操作。玩家可以触摸屏幕选择汽车,尝试让汽车上的牌比鱼牌的点数大,赢取鱼的重量。游戏结束条件为汽车上的牌全部用完或者鱼牌被吃完。
摘要由CSDN通过智能技术生成

from scene import *
import sound
import random
import math
import os
A = Action

class MyScene (Scene):
    def setup(self):
        self.background_color='white'
        
        self.carlist=[]
        self.numlablelist=[]
        
        
        x=200
        y=400
        #self.a=self.spawn_car(x,y-199)
        #self.b=self.spawn_car(x+199,y-199)
        #self.spawn_car(x+398,y-199)
        #self.c=self.spawn_car(x,y)
        #self.spawn_car(x+199,y)
        #self.spawn_car(x+398,y)
        #self.spawn_car(x,y+199)
        #self.spawn_car(x+199,y+199)
        #self.spawn_car(x+398,y+199)
        
        
        self.a=self.spawn_car(x,y-200,0)
        self.b=self.spawn_car(x+200,y-200,0)
        self.c=self.spawn_car(x+400,y-200,0)
        self.d=self.spawn_car(x,y,0)
        self.e=self.spawn_car(x+200,y,4)
        self.f=self.spawn_car(x+400,y,0)
        self.g=self.spawn_car(x,y+200,0)
        self.h=self.spawn_car(x+200,y+200,0)
        self.i=self.spawn_car(x+400,y+200,0)
        
        self.fmcarposition=(0,0)
        
        
        
        self.atcaryes=True
        self.phyes=False
        self.pyyes=False
        self.choosing=False
        self.pickone=False
        
        self.p=self.a.position
        
        self.p1=self.a.position
        self.p2=self.a.position
        
        #self.rot=0
        #self.radian=0
        self.movable=False
        self.overlap=False
        
        #self.eatnum=0
        
        self.rottotalnum=0
        self.fishtweight=0
        
        
        #card5Img='5.png'
        #card1Img='1.png'
        self.cardlistred=['card:DiamondsA','card:Diamonds2','card:Diamonds3','card:Diamonds4','card:Diamonds5','card:Diamonds6','card:Diamonds7','card:Diamonds8','card:Diamonds9','card:Diamonds10','card:DiamondsJ','card:DiamondsQ','card:HeartsK']
        #cardlistred.append(card5Img)
        #cardlistred.append(card1Img)
        
        #card103Img='103.png'
        #card107Img='107.png'
        self.cardlistblack=['card:ClubsA','card:Clubs2','card:Clubs3','card:Clubs4','card:Clubs5','card:Clubs6','card:Clubs7','card:Clubs8','card:Clubs9','card:Clubs10','card:ClubsJ','card:ClubsQ','card:ClubsK']
        #cardlistblack.append(card103Img)
        
        self.card=self.spawn_card(self.cardlistred,self.a)
        self.card2=self.spawn_card(self.cardlistblack,self.d)
        
        self.fishmeat=self.spawn_fishmeat(self.cardlistred,(400,800))
        
        #set car.plusnum
        for car in self.carlist:
            car.plusnum=random.randint(-1,+3)
        
        self.win_lable=LabelNode(text='playing')
        self.win_lable.anchor_point=(-20,0)
        self.win_lable.position=(0,718)
        self.win_lable.color='black'
        self.win_lable.font=('Arial',30)
        self.add_child(self.win_lable)
        
        
        strplusnum=str(self.a.plusnum)
        self.num_lable1=LabelNode(text=strplusnum)
        self.num_lable1.anchor_point=(0,0)
        self.num_lable1.position=self.a.position
        self.num_lable1.color='black'
        self.num_lable1.font=('Arial',30)
        self.add_child(self.num_lable1)
        #self.numlablelist.append(self.num_lable)
        strplusnum=str(self.b.plusnum)
        self.num_lable2=LabelNode(text=strplusnum)
        self.num_lable2.anchor_point=(0,0)
        self.num_lable2.position=self.b.position
        self.num_lable2.color='black'
        self.num_lable2.font=('Arial',30)
        self.add_child(self.num_lable2)
        #self.numlablelist.append(self.num_lable
        strplusnum=str(self.c.plusnum)
        self.num_lable3=LabelNode(text=strplusnum)
        self.num_lable3.anchor_point=(0,0)
        self.num_lable3.position=self.c.position
        self.num_lable3.color='black'
        self.num_lable3.font=('Arial',30)
        self.add_child(self.num_lable3)
        #self.numlablelist.append(self.num_lable
        strplusnum=str(self.d.plusnum)
        self.num_lable4=LabelNode(text=strplusnum)
        self.num_lable4.anchor_point=(0,0)
        self.num_lable4.position=self.d.position
        self.num_lable4.color='black'
        self.num_lable4.font=('Arial',30)
        self.add_child(self.num_lable4)
        #self.numlablelist.append(self.num_lable
        strplusnum=str(self.e.plusnum)
        self.num_lable5=LabelNode(text=strplusnum)
        self.num_lable5.anchor_point=(0,0)
        self.num_lable5.position=self.e.position
        self.num_lable5.color='black'
        self.num_lable5.font=('Arial',30)
        self.add_child(self.num_lable5)
        #self.numlablelist.append(self.num_lable
        strplusnum=str(self.f.plusnum)
        self.num_lable6=LabelNode(text=strplusnum)
        self.num_lable6.anchor_point=(0,0)
        self.num_lable6.position=self.f.position
        self.num_lable6.color='black'
        self.num_lable6.font=('Arial',30)
        self.add_child(self.num_lable6)
        #self.numlablelist.append(self.num_lable
        strplusnum=str(self.g.plusnum)
        self.num_lable7=LabelNode(text=strplusnum)
        self.num_lable7.anchor_point=(0,0)
        self.num_lable7.position=self.g.position
        self.num_lable7.color='black'
        self.num_lable7.font=('Arial',30)
        self.add_child(self.num_lable7)
        #self.numlablelist.append(self.num_lable
        strplusnum=str(self.h.plusnum)
        self.num_lable8=LabelNode(text=strplusnum)
        self.num_lable8.anchor_point=(0,0)
        self.num_lable8.position=self.h.position
        self.num_lable8.color='black'
        self.num_lable8.font=('Arial',30)
        self.add_child(self.num_lable8)
        #self.numlablelist.append(self.num_lable
        strplusnum=str(self.i.plusnum)
        self.num_lable9=LabelNode(text=strplusnum)
        self.num_lable9.anchor_point=(0,0)
        self.num_lable9.position=self.i.position
        self.num_lable9.color='black'
        self.num_lable9.font=('Arial',30)
        self.add_child(self.num_lable9)
        #self.numlablelist.append(self.num_lable
        
        #self.fmlable=self.spawn_fmlable(self.e)
        
        
    
        
        
        
        #self.run_action(A.sequence(A.call(self.movecard),A.wait(1)))
        #self.run_action(A.sequence(A.call(self.movecard),A.wait(1)))
        #self.run_action(A.sequence(A.call(self.movecard),A.wait(1)))
    def newmap(self):
        for car in self.carlist:
            car.remove_from_parent()
        self.carlist=[]
        #print(self.carlist)
        self.card.remove_from_parent()
        self.card2.remove_from_parent()
        
        
        #x=100
        #y=300
        x=200
        y=400
        #self.a=self.spawn_car(x,y-199)
        #self.b=self.spawn_car(x+199,y-199)
        #self.spawn_car(x+398,y-199)
        #self.c=self.spawn_car(x,y)
        #self.spawn_car(x+199,y)
        #self.spawn_car(x+398,y)
        #self.spawn_car(x,y+199)
        #self.spawn_car(x+199,y+199)
        #self.spawn_car(x+398,y+199)
        
        self.a=self.spawn_car(x,y-200,0)
        self.b=self.spawn_car(x+200,y-200,0)
        self.c=self.spawn_car(x+400,y-200,0)
        self.d=self.spawn_car(x,y,0)

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值