forked from zyxiaooo/SJTU
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zyxiaooo
authored
Oct 5, 2016
1 parent
6792f0d
commit 653623d
Showing
8 changed files
with
712 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# -*- coding: utf-8 -* | ||
class hintbox: | ||
|
||
def __init__(self,win,p,string): | ||
import graphics | ||
import time | ||
|
||
self.text=graphics.Text(p,string) | ||
self.win=win | ||
def show(self): | ||
import graphics | ||
import time | ||
|
||
self.text.draw(self.win) #提示框闪烁 | ||
time.sleep(0.25) | ||
self.text.undraw() | ||
time.sleep(0.15) | ||
self.text.draw(self.win) | ||
time.sleep(0.25) | ||
self.text.undraw() | ||
time.sleep(0.15) | ||
self.text.draw(self.win) | ||
time.sleep(0.25) | ||
self.text.undraw() | ||
def change(self,newstring): | ||
import graphics | ||
import time | ||
|
||
self.text.setText(newstring) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# -*- coding: utf-8 -* | ||
class circle: | ||
|
||
def __init__(self,window,P1,level): | ||
from graphics import GraphWin,Circle | ||
import random | ||
from time import time | ||
self.p1=P1 | ||
self.window=window | ||
self.cir=Circle(self.p1,0.4) | ||
self.level=level | ||
self.cir.setWidth(0) | ||
|
||
i=random.randrange(6,9+self.level) | ||
self.color=i | ||
if self.color==6: #颜色对应数字 | ||
self.cir.setFill("red") | ||
if self.color==7: | ||
self.cir.setFill("green") | ||
if self.color==8: | ||
self.cir.setFill("black") | ||
if self.color==9: | ||
self.cir.setFill("blue") | ||
if self.color==10: | ||
self.cir.setFill("orange") | ||
for s in range(100): | ||
cirs=Circle(self.p1,0.0+s*0.004) | ||
if self.color==6: | ||
cirs.setFill("red") | ||
if self.color==7: | ||
cirs.setFill("green") | ||
if self.color==8: | ||
cirs.setFill("black") | ||
if self.color==9: | ||
cirs.setFill("blue") | ||
if self.color==10: | ||
cirs.setFill("orange") | ||
cirs.draw(self.window) | ||
empty=0 #空循环控制时间(time间隔太大) | ||
while empty<=30000: | ||
empty=empty+1 | ||
cirs.undraw() | ||
self.cir.draw(self.window) | ||
self.activate=True | ||
|
||
|
||
def click(self,pr): | ||
from graphics import Circle | ||
import time | ||
pd=False | ||
if self.activate==True and (pr.getX()-self.p1.getX())**2+(pr.getY()-self.p1.getY())**2<=0.24: | ||
|
||
for i in range(3): #点击动画 | ||
self.cir.move(0,-0.12/3.0) | ||
time.sleep(0.01) | ||
for i in range(3): | ||
self.cir.move(0,0.12/3.0) | ||
time.sleep(0.01) | ||
for i in range(3): | ||
self.cir.move(0,-0.12/3.0) | ||
time.sleep(0.01) | ||
for i in range(3): | ||
self.cir.move(0,0.12/3.0) | ||
time.sleep(0.01) | ||
pd=True | ||
return pd | ||
|
||
|
||
|
||
def undraw(self): | ||
self.cir.undraw() | ||
def close(self): | ||
self.cir.undraw() | ||
self.activate=False | ||
def move(self,pr): | ||
self.cir.move(pr.getX()-self.p1.getX(),pr.getY()-self.p1.getY()) | ||
self.p1.move(pr.getX()-self.p1.getX(),pr.getY()-self.p1.getY()) | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
class Button: | ||
from graphics import* | ||
def __init__(self,window,P1=Point(20,20),P2=Point(60,40),name=""): | ||
from graphics import* | ||
self.p1=P1 | ||
self.p2=P2 | ||
self.window=window | ||
self.activate=True | ||
self.t=Text(Point((self.p1.getX()+self.p2.getX())/2.0,(self.p1.getY()+self.p2.getY())/2.0),self.name) | ||
def name(self,names): | ||
|
||
self.t.setText(names) | ||
def draw(self): | ||
from graphics import* | ||
|
||
self.rec=Rectangle(self.p1,self.p2) | ||
self.rec.draw(self.window) | ||
self.rec.setFill("gray") | ||
self.t.draw(self.window) | ||
def click(self,pr): | ||
from graphics import* | ||
from time import* | ||
pd=False | ||
if self.activate==True: | ||
|
||
|
||
if pr.getX()>self.p1.getX() and pr.getX()<self.p2.getX() and pr.getY()>self.p1.getY() and pr.getY()<self.p2.getY(): | ||
pd=True | ||
self.rec.setFill("blue") | ||
sleep(0.2) | ||
self.rec.setFill("gray") | ||
return pd | ||
def deactivate(self): | ||
self.activate=False | ||
def activate(self): | ||
self.activate=True | ||
|
||
|
||
|
Oops, something went wrong.