Commit d71aeeb7 by BellCodeEditor

auto save

parent d5739bd2
for i in range(10):
for j in range(10):
if i+j==10 and i*2+j*4==30:
print(i,j)
\ No newline at end of file
s=input()
x=s.split(" ")
a=[]
b=[]
n=0
for i in range(0,len(x)):
a.append(int(x[i]))
n+=1
b.append(n)
for i in range(len(a)):
for j in range(i+1,n):
if a[i]>a[j]:
a[i],a[j]=a[j],a[i]
b[i],b[j]=b[j],b[i]
print(a)
print(b)
\ No newline at end of file
import random
a=random.randint(0,20)
b=random.randint(0,20)
if a>=b:
print(a)
else:
print(b)
\ No newline at end of file
class hero:
def __init__(self,name):
self.a = 1
self.name = name
self.c = 200
self.d = 50
class player(hero):
def __init__(self,name,hero_type):
super().__init__(name)
self.a = 200
self.b = 50
self.hero_type = hero_type
print('角色'+self.name+'创建成功,英雄类为:',self.hero_type)
print('当前,血量,攻击力分别为:',self.a,self.b)
y= player('yang','刺客')
print(y.d)
houyi= player('后裔','射手')
yase = hero('jing')
\ No newline at end of file
b=0
for i in range(0,101,2):
b+=i
print(b)
\ No newline at end of file
for i in range(1,10,1):
for j in range(1,10,1):
print(i,"*",j,"=",i*j,end="")
print()
\ No newline at end of file
for a in range(1,1297):
b=a+4
for c in range(1,1296-a-b):
d=c*4
if(b-2==c*2) and (a+b+c+d==1296):
print(a,b,c,d)
\ No newline at end of file
a=input()
b = int(a[:len(a)-1])
print("%.3f"%(b*0.1421))
\ No newline at end of file
s=input()
x=s.split(" ")
a=[]
b=[]
n=0
for i in range(0,len(x)):
a.append(int(x[i]))
n+=1
b.append(n)
for i in range(len(a)):
for j in range(i+1,n):
if a[i]>a[j]:
a[i],a[j]=a[j],a[i]
b[i],b[j]=b[j],b[i]
print(a)
print(b)
\ No newline at end of file
class player(Hero):
def __init__(self,name)
super().__init__(name)
self.a = 200
self.b = 50
import pygame import pygame
import random
from pygame import locals from pygame import locals
score=0
# 初始化pygame,为使用硬件做准备 # 初始化pygame,为使用硬件做准备
pygame.init() pygame.init()
...@@ -16,9 +17,13 @@ body = pygame.image.load('body.png') # 身体 ...@@ -16,9 +17,13 @@ body = pygame.image.load('body.png') # 身体
left = pygame.image.load('left.png') # 头 朝左 left = pygame.image.load('left.png') # 头 朝左
up = pygame.image.load('up.png') # 头 朝上 up = pygame.image.load('up.png') # 头 朝上
down = pygame.image.load('down.png') # 头 朝下 down = pygame.image.load('down.png') # 头 朝下
font = pygame.font.Font('neuropol.ttf',18)
x, y = 240, 120 x, y = 240, 120
position = [(180, 90), (180, 120), (210, 120), (x, y)] food_x=300
food_y=300
position = [(180,30),(180,60),(180, 90), (180, 120), (210, 120), (x, y)]
setheading = "right" setheading = "right"
snake_head = right snake_head = right
...@@ -52,7 +57,14 @@ while True: ...@@ -52,7 +57,14 @@ while True:
else: else:
y += 30 y += 30
position.append((x, y)) position.append((x, y))
position.pop(0) if x==food_x and y==food_y:
d_x=random.randint(1,22)
d_y=random.randint(1,16)
food_x=d_x*30-30
food_y=d_y*30-30
score=score+10
else:
position.pop(0)
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
# 将贪吃蛇的头画上去 # 将贪吃蛇的头画上去
...@@ -60,9 +72,11 @@ while True: ...@@ -60,9 +72,11 @@ while True:
# 将贪吃蛇的身体画上去 # 将贪吃蛇的身体画上去
for i in range(len(position)-1): for i in range(len(position)-1):
screen.blit(body, position[i]) screen.blit(body, position[i])
text='score'+str(score)
fen=font.render(text,True,(0,0,0))
screen.blit(fen,(540,0))
# 将果实画上去 # 将果实画上去
screen.blit(food, (360, 300)) screen.blit(food, (food_x, food_y))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPSCLOCK.tick(3) FPSCLOCK.tick(6)
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment