Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added homeworks/A11200/homework1/A11200 华风 day4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added homeworks/A11200/homework2/redapple.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added homeworks/A11200/homework2/redapple1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added homeworks/A11200/homework2/redapple_副本.jpg
155 changes: 155 additions & 0 deletions homeworks/A11200/homework2/test-pygame-snake4-apple 0730.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
# -*- coding: utf-8 -*-
# author:huafeng
#完善 贪吃蛇游戏-重新生成苹果,蛇不能掉头,蛇吃到自己失败,显示图片

import pygame
import random
import os


SCALE = 20 # 屏幕是 20*20 个格子
SIZE = 20 # 每个格子是 20个像素

WIDTH = SCALE * SIZE # 窗口的宽度
HEIGHT = SCALE * SIZE # 窗口的高度
DIRECT = [[0,-1],[-1,0],[0,1],[1,0]] # 定义4个方向,上,左,下,右方便后续
dirt = 1
apple = [10,8] # 定义 苹果的初始位置

snake = [[9,3],[10,3],[11,3]] #定义 蛇的初始化位置

# 蛇前进1格后,插入蛇头新的坐标列表,如果不变长,则删除最后一个列表。变长则不删除。

# 更新蛇的运动状态
def update_snake():
new_body = [0,0] #定义一个蛇的新蛇头列表
new_body[0] = (snake[0][0] + DIRECT[dirt][0]) % SCALE # 新身体的X矩阵坐标为蛇头X+方向X运算,当为-1等时,等于从列表后面向前走。
new_body[1] = (snake[0][1] + DIRECT[dirt][1]) % SCALE # 新身体的X矩阵坐标为蛇头Y+方向Y运算,当为-1等时,等于从列表后面向前走。
if new_body == apple: # 当 蛇头 到达苹果位置时
snake.insert(0,new_body) # 插入新的蛇头
return True
else:
snake.insert(0,new_body) # 插入新的 蛇头
snake.pop() # 删除尾巴最后一个
return False

# 显示窗口蛇身 相关特性
def screen_display(screen): #
screen.fill([255, 255, 255]) #画一个白色的窗口
pygame.draw.rect(screen,[0,0,255],[snake[0][0]*SIZE,snake[0][1]*SIZE,SIZE - 1,SIZE - 1]) # 蛇头标记为蓝色
# index = 1
for body in snake[1:]:
pygame.draw.rect(screen,[0,255,0],[body[0]*SIZE,body[1]*SIZE,SIZE - 1,SIZE - 1]) #方框左,上,宽,厚
img = pygame.image.load('redapple1.jpg') #图片路径,一般和python源文件放在一个目录下
screen.blit(img,[apple[0]*SIZE,apple[1]*SIZE])
pygame.display.flip() #显示到窗口中

def new_apple():
apple[0] = random.randint(0,19)
apple[1] = random.randint(0,19)

# 吃自己
def eat_self():
if snake.count(snake[0]) >= 2:
return True
return False

def gameover(screen):
running = True
while running:
screen.fill([255, 255, 255])
font = pygame.font.Font(None,32)
text = font.render('game over',True,[255,0,0])
screen.blit(text,[7*SIZE,7*SIZE])
pygame.display.flip()
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.quit()


# 按键响应 防止贪吃蛇 掉头
def w_down_cb():
global dirt
if dirt % 2 != 0: # 当前方向 为左 或 右,才方向上
dirt = 0
def s_down_cb(): # # 当前方向 为左 或 右,才方向下
global dirt
if dirt % 2 != 0:
dirt = 2
def a_down_cb(): # # 当前方向 为上 或 下,才方向左
global dirt
if dirt % 2 != 1:
dirt = 1
def d_down_cb(): # # 当前方向 为上 或 下,才方向右
global dirt
if dirt % 2 != 1:
dirt = 3

def main():
pygame.init() # 对Pygame 进行初始化
screen = pygame.display.set_mode([WIDTH, HEIGHT]) # 定义 一定大小的窗口
running = True # 运行条件
# new_apple = [random.randint(1,20),random.randint(1,20)] #随机定义坐标
while running:
pygame.time.delay(200) # 50ms 延迟
if update_snake():
new_apple()

if eat_self():
gameover(screen)
break


screen_display(screen) # 调用显示程序
# update_apple(new_snake,screen,snake,new_apple) #
for event in pygame.event.get(): # 获取键盘响应
if event.type == pygame.QUIT: # 退出 响应
running = False
elif event.type == pygame.KEYDOWN: # 获得键盘响应
if event.key == pygame.K_w: # 上
w_down_cb()
elif event.key == pygame.K_s: # 下
s_down_cb()
elif event.key == pygame.K_a: # 左
a_down_cb()
elif event.key == pygame.K_d: # 右
d_down_cb()
pygame.quit()

if __name__ == '__main__':
main()



# for body in snake:
# body[1] = body[1] + SPEEDy[1]

# def renew_ball():
# if circle[1] > HEIGHT:
# circle[0] = 100
# circle[1] = 100

# def update_ball():
# if circle[1] - RADIUS == 0:
# SPEED[1] *= -1
# if circle[0] + RADIUS == WIDTH or circle[0] - RADIUS == 0:
# SPEED[0] *= -1

# if circle[1] + RADIUS == board.top and circle[0] > board.left and circle[0] < board.right:
# SPEED[1] *= -1

# circle[0] += SPEED[0]
# circle[1] += SPEED[1]


# def draw_surface(screen):
# screen.fill([255, 255, 255]) # R G B white
# pygame.draw.circle(screen, [255, 0, 0], circle, RADIUS)
# pygame.draw.rect(screen, [0, 255, 255], board)
# pygame.display.flip()

# def update_board():
# if MOU_CON:
# (x, y) = pygame.mouse.get_pos()
# board.centerx = x
Binary file added homeworks/A11200/homework3/A11200 华风 0815.jpg
Binary file added homeworks/A11200/homework3/A11200 华风.jpg
23 changes: 23 additions & 0 deletions homeworks/A11200/homework3/test1-image.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html> <!--注释,标注 使用的格式-->
<html> <!--网页开始符号-->
<head> <!--网页 标题,显示在浏览器上的那部分 开始符号-->
<meta charset = 'utf-8'>
<title>菜鸟教程(runoob.com)</title>
</head> <!--网页 标题 结束符号-->
<body> <!--网页 显示内容主体 开始符号-->
body
{
background-color:#doe4fe;
}
p{color:red;text-align:center;}
<h1><b>来吧,大家来相互伤害啊</b></h1> <!--网页 正文 大标题符号-->
<hr> <!--网页 显示一条分隔线-->
<p><b>我是A11200,华风,一个工作党!</b></p>
<img src="zhanlang2.jpg" width="300" height="400" >
<br/>
<p> <br/> </p> <!--网页 显示空一行,一个段落-->

<br/>

</body> <!--网页 显示内容主体 结束符号-->
</html> <!--网页结束符号-->
32 changes: 32 additions & 0 deletions homeworks/A11200/homework3/test1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html> <!--注释,标注 使用的格式-->
<html> <!--网页开始符号-->
<head> <!--网页 标题,显示在浏览器上的那部分 开始符号-->
<meta charset = 'utf-8'>
<title>菜鸟教程(runoob.com)</title>
</head> <!--网页 标题 结束符号-->
<body> <!--网页 显示内容主体 开始符号-->
<h1><b>我的第一个标题</b></h1> <!--网页 正文 大标题符号-->
<hr> <!--网页 显示一条分隔线-->
<h2>my first title </h2>
<h3>my seconder title</h3>>
<p>我的第一个段落。</p> <!--网页 换个段落 符号-->
<p><b>我的第一个段落-加粗。</b></p>
<br/>
<p><strong>我的第一个段落-加粗2-加重语气。</strong></b></p>
<br/>
<big>我的第一个段落-字体放大。</big>
<br/>
<em>我的第一个段落-斜体-着重文字。</em>
<br/>
<i>我的第一个段落-斜体。</i>
<br/>
<img scr="donghua.jpg" width="100" height="400" >
<br/>
<p>主题:<br>注意:::<br>第一个段落。</p> <!--br等于分成了3行 这部分内容 符号-->
<p> <br/> </p> <!--网页 显示空一行,一个段落-->
<hr>
<a herf="http://www.runoob.com/"> 访问这个链接 </a>
<br/>

</body> <!--网页 显示内容主体 结束符号-->
</html> <!--网页结束符号-->
31 changes: 31 additions & 0 deletions homeworks/A11200/homework3/test2-center.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html> <!--注释,标注 使用的格式-->
<html> <!--网页开始符号-->
<head> <!--网页 标题,显示在浏览器上的那部分 开始符号-->
<meta charset = 'utf-8'>
<style>
.head_img{
width: 100px;
height: 100px;
border-radius:50%;
margin: 0 auto;
display: block;
}
</style>
<style type="text/css">
h1 {color:red;}
p {color:blue;}
</style>
<style type="text/css">
h1{text-align:center;}
p{text-align:center;}
</style>
<title>华风个人主页</title>
</head>
<body>
<img class = "head_img"src="zhanlang2.jpg" width="300" height="400" >
<br/>
<h1><b>华风:来吧,大家一起做朋友!</b></h1>
<hr>
<p><b>我是A11200,华风,一个工作党!</b></p>
</body> <!--网页 显示内容主体 结束符号-->
</html> <!--网页结束符号-->
31 changes: 31 additions & 0 deletions homeworks/A11200/homework3/test3-center.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html> <!--注释,标注 使用的格式-->
<html> <!--网页开始符号-->
<head> <!--网页 标题,显示在浏览器上的那部分 开始符号-->
<meta charset = 'utf-8'>
<style>
.head_img{
width: 100px;
height: 100px;
border-radius:50%;
margin: 0 auto;
display: block;
}
</style>
<style type="text/css">
h1 {color:red;}
p {color:blue;}
</style>
<style type="text/css">
h1{text-align:center;}
p{text-align:center;}
</style>
<title>华风个人主页</title>
</head>
<body>
<img class = "head_img"src="wujing.jpg" width="300" height="400" >
<br/>
<h1><b>华风:来吧,大家一起做朋友!</b></h1>
<hr>
<p><b>我是A11200,华风,一个工作党!</b></p>
</body> <!--网页 显示内容主体 结束符号-->
</html> <!--网页结束符号-->
Binary file not shown.
27 changes: 27 additions & 0 deletions homeworks/A11200/homework3/大作业3源代码/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# uband-s2-feng
uband友班编程课程

## 背景


## 需求
### 0.基本信息

头像:


### 1.个人简介

### 2. xxxx



## 发布


## 其他


## 参考资料


59 changes: 59 additions & 0 deletions homeworks/A11200/homework3/大作业3源代码/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
from flask import Flask
from flask import render_template
import json

app = Flask(__name__)

def read_json_file(filepath):
jsonfile = open(filepath,'r+',encoding='utf-8')
jsontext = jsonfile.read()
data = json.loads(jsontext)
return data

@app.route('/')
def shouye():
data = read_json_file('static/data/index.json')
return render_template('index.html', data=data)

@app.route('/details/<string:student_number>')
def look_details(student_number):
data = read_json_file('static/data/index.json')
user_data = {}
for item in data:
if student_number == item['student_number'] :
user_data = item
break
return render_template('details.html', data=user_data)

@app.route('/details/<string:student_number>/materials')
def materials(student_number):
data = read_json_file('static/data/index.json')
user_data = {}
for item in data:
if student_number == item['student_number']:
user_data = item
break
return render_template('materials.html', data= user_data)

@app.route('/details/<string:student_number>/friend')
def friend(student_number):
data = read_json_file('static/data/index.json')
user_data = {}
for item in data:
if student_number == item['student_number']:
user_data = item
break
return render_template('friend.html', data= user_data)

@app.route('/details/<string:student_number>/hotspot')
def hotspot(student_number):
data = read_json_file('static/data/index.json')
user_data = {}
for item in data:
if student_number == item['student_number']:
user_data = item
break
return render_template('hotspot.html', data=user_data)

if __name__== '__main__':
app.run(debug = True)
Loading