python pygame練習7

來源:互聯網
上載者:User
#! /usr/bin/env python2.7# -*- coding:utf-8 -*-#File:PG6.py#Date:2013-8-1#Author:wangyu"""昨天晚上下大雨,一下把我家的玉米弄得一片損毀,剛剛打電話給兄弟,一會回來一起和我在路邊煮玉米,賣玉米,難道我這個暑假要在加賣玉米了?"""import pygamefrom  pygame.locals import *from sys import *from random import *from math import pipygame.init()screen=pygame.display.set_mode((640,480),0,32)points=[]while True:    for event in pygame.event.get():        if event.type ==QUIT:            exit()        if event.type ==KEYDOWN:            points=[]            screen.fill((255,255,255))        if event.type ==MOUSEBUTTONDOWN:            screen.fill((255,255,255))#隨機矩形            rc=(randint(0,255),randint(0,255),randint(0,255))            rp=(randint(0,639),randint(0,479))            rs=(639-randint(rp[0],639),479-randint(rp[1],479))            pygame.draw.rect(screen,rc,Rect(rp,rs))#隨機原型            rc=(randint(0,255),randint(0,255),randint(0,255))            rp=(randint(0,639),randint(0,479))            rr=randint(0,200)            pygame.draw.circle(screen,rc,rp,rr)#獲得當前滑鼠的點擊位置            x,y=pygame.mouse.get_pos()            points.append((x,y))#根據點擊位置畫弧線            angle=(x/639.)*pi*2.            pygame.draw.arc(screen,(0,0,0),(0,0,639,479),0,angle,3)#根據隨機點畫橢圓            pygame.draw.ellipse(screen,(0,255,0),(0,0,x,y))#從左上和右下畫兩根線串連到點擊位置            pygame.draw.line(screen,(0,0,255),(0,0),(x,y))            pygame.draw.line(screen,(255,0,0),(640,480),(x,y))    pygame.display.update()

在python中有很多的函數,甚至有能製造子彈的方法!

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.