资讯专栏INFORMATION COLUMN

pythonista cartest2 源码

tigerZH / 2120人阅读

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

class MyScene (Scene):

def setup(self):
    self.carlist=[]
    self.imglist=["img1.png","img2.png","img3.png","img4.png","img5.png","img6.png","img7.png","img8.png","img9.png","img10.png","img11.png"]
    x=100
    y=300
    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.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)
    
def spawn_car(self,x,y):
    car=SpriteNode(random.choice(self.imglist))
    #self.car.anchor_point=(0,0)
    car.position=(x,y)
    self.add_child(car)
    self.carlist.append(car)
    return car
    
    
        
    
    


def did_change_size(self):
    pass

def update(self):
    if self.a.bbox.intersects(self.b.bbox):
        print(1)
        print(self.a.bbox.intersection(self.b.bbox))
    """for car in self.carlist:
        act=A.repeat(A.rotate_by(math.pi/2,1),-1)
        car.run_action(act)"""

def touch_began(self, touch):
    pass

def touch_moved(self, touch):
    pass

def touch_ended(self, touch):
    pass

if name == "__main__":

run(MyScene(), show_fps=True)

"""display_width=800
display_height=600

black=(0,0,0)
white=(255,255,255)
red=(255,0,0)
green=(0,255,0)
purple=(238,130,238)

x=0
y=200

car(x,y-199,0)
car(x+199,y-199,0)
car(x+398,y-199,0)

car(x+597,y-199)

car1=car(x,y,0)
car2=car(x+199,y,4)
car(x+398,y,0)

car(x+597,y)

car5=car(x,y+199,0)
car(x+199,y+199,0)
car(x+398,y+199,0)

car(x+597,y+199)

"""

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/42811.html

相关文章

  • Pythonista 容易忽略的python编程方式

    摘要:字典是内置的数据结构,在写程序时会经常用到。这里介绍一下它的方法和方法。在获取中的数据时,我们一般使用的方式,但是如果不存在的时候会抛出。 Python 之禅 The Zen of Python, by Tim Peters Beautiful is better than ugly. 优美胜于丑陋(Python以编写优美的代码为目标) Explicit is be...

    wendux 评论0 收藏0
  • pythonista去掉图片背景色是哪条语句?

    pygame里的setcolorkey(black),同样功能怎么实现,有大佬来解答一下吗?

    muddyway 评论0 收藏0
  • Python又把GUI界面攻下了,今天就告诉你怎么玩

    摘要:引言学这么久了,一直想做个界面出来,最近发现有个内置库,利用它可以很轻松做出一些简易的界面,首先来看官方对的说明从上面描述中我们不难看出,不管你是系统,还是系统,它都可以生成相对应的操作界面,这就是所谓的跨平台。 showImg(https://segmentfault.com/img/remote/1460000018532942?w=1078&h=1076); 0.引言 学Pyth...

    SunZhaopeng 评论0 收藏0
  • [原] Python 开发者如何正确使用 RStudio 编辑器

    摘要:工程师也用过快速开发面向消费者的网站以响应一日三变的用户需求。硬件工程师在树莓派上用来调试一个人脸检测的功能,以较低的成本完成核心功能的调试。另一方面,通过在任何一个浏览器中就可以直接前往服务器现场,不论是一台甚至是树莓派。 概述 资深Python工程师可以选择的编辑器有很多,比如 Rodeo,Spider,Eclipse,Vim,Visual Studio,Atom,Sublime ...

    el09xccxy 评论0 收藏0
  • pythonista ipad游戏代码保存

    摘要: from scene import *import soundimport randomimport mathimport osA = Action class MyScene (Scene): def setup(self): self.background_color=white self.carlist=[] x=100 y=...

    bbbbbb 评论0 收藏0

发表评论

0条评论

最新活动
阅读需要支付1元查看
<