身展书院骑行运动成功进行

12月11日上午,伴随着温暖的冬阳,和煦的轻风,我院举办的骑行运动以书院骑行驿站正式展开。吾展书院部分部长和新兴干事们一起10不必要人口踊跃地与到这次活动着。

 

本次活动,富有活力且产生意义,参加的各位干事对相互产生重老的认,增进相互之间同学情谊,在普通忙碌的学习生活遭,得到了邻近自然,放松身心的机遇。此次活动为让骑行驿站的作用得到新现,为以后再好地服务同学打下坚实的底子。此次移动为助长了校园文化,对校园文化建设拥有重大意义。日后就骑行驿站的放,希望各位同学也能多多通过骑行驿站开展这样的位移!

import pygame

class Ship():

    def __init__(self, ai_settings, screen):
        self.screen = screen
        self.ai_settings = ai_settings

        # 加载飞船图像并获取其外接矩形
        self.image = pygame.image.load('images/ship.bmp')
        self.rect = self.image.get_rect()
        self.screen_rect = screen.get_rect()

        # 将每艘新飞船放在屏幕底部中央
        self.rect.centerx = self.screen_rect.centerx
        self.rect.bottom = self.screen_rect.bottom

        # 在飞船的属性 center 中存储小数值
        self.center = float(self.rect.centerx)

        # 移动标识
        self.moving_right = False
        self.moving_left = False

    def blitme(self):
        # 屏幕指定位置绘制飞船
        self.screen.blit(self.image, self.rect)

    def update(self):
        if self.moving_right and self.rect.right < self.screen_rect.right:
            self.center += self.ai_settings.ship_speed_factor
        elif self.moving_left and self.rect.left > 0:
            self.center -= self.ai_settings.ship_speed_factor

        # 更新 rect 对象
        self.rect.centerx = self.center

一起臻,骑行队员们在欢歌笑语中,欣赏着路边秋末冬初美之景点,同时为保持着不变的骑行秩序。队员们集合之服及自行车,以及整齐的人马在无形中中形成了扳平志靓丽的风景。与快乐相伴,不一会儿就抵达了瓜渚湖公园。到达以后,队员们停放好车子后,开始以湖边悠闲步行,在苑的林荫小道中漫步交谈,感受着这冬天宇宙独特的优美。步行一段时间后,队员们于绿茵上席地而以,进行相同多样有意味而来意义之小游戏。在同样片温馨愉快的空气中,骑行活动始于接近尾声。队员又以整齐的部队向该校上,骑行活动规范终止。

 

7?l�Pb�tA

  时只做了第一部分:一个界面,有个飞机,可以左右运动,放子弹。

上午9点整,活动参与者们还已早早地集结于书院骑行驿站门口,随后换上统一的服,在驿站中精选适合个人的车子,为稍后底骑行运动蓄力。做好同一层层准备活动过后,大家统一来学校南大门,排列好有序的骑行队伍,正式启幕向目的地—瓜渚湖向前。

import sys

import pygame

from bullet import Bullet


def check_events(ai_settings, screen, ship, bullets):
    # 监听键盘和鼠标的事件
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            sys.exit()
        elif event.type == pygame.KEYDOWN:
            check_keydown_events(event, ai_settings, screen, ship, bullets)
        elif event.type == pygame.KEYUP:
            check_keyup_events(event, ship)


def update_screen(ai_settings, screen, ship, bullets):
    # 每次循环时都重绘屏幕
    screen.fill(ai_settings.bg_color)

    # 在飞船和外星人后面重绘所有子弹
    for bullet in bullets.sprites():
        bullet.draw_bullet()

    ship.blitme()

    # 让最近绘制的屏幕可见
    pygame.display.flip()

def check_keydown_events(event, ai_settings, screen, ship, bullets):
    if event.key == pygame.K_RIGHT:
        ship.moving_right = True
    elif event.key == pygame.K_LEFT:
        ship.moving_left = True
    elif event.key == pygame.K_SPACE:
        # 创建一颗子弹,并将其加入到编组 bullets 中
        fire_bullet(ai_settings, screen, ship, bullets)

def check_keyup_events(event, ship):
    if event.key == pygame.K_RIGHT:
        ship.moving_right = False
    elif event.key == pygame.K_LEFT:
        ship.moving_left = False

def update_bullets(bullets):
    bullets.update()

    # 删除已经消失的子弹
    for bullet in bullets.copy():
        if bullet.rect.bottom <= 0:
            bullets.remove(bullet)

def fire_bullet(ai_settings, screen, ship, bullets):
    if len(bullets) < ai_settings.bullets_allowed:
        new_bullet = Bullet(ai_settings, screen, ship)
        bullets.add(new_bullet)

 

  settings.py

  alien_invasion.py

  GitHub:https://github.com/liqingwen2015/play_plane

  ship.py

import sys

import pygame

from settings import Settings
from ship import Ship
import game_functions as gf
from pygame.sprite import Group

def run_game():
    # 初始化游戏并创建一个屏幕对象
    pygame.init()
    ai_settings = Settings()
    screen = pygame.display.set_mode((ai_settings.screen_width, ai_settings.screnn_height))
    pygame.display.set_caption('Alien Invasion')

    # 创建一艘飞船
    ship = Ship(ai_settings, screen)
    # 创建一个存储的子弹组
    bullets = Group()

    # 设置背景色
    bg_color = (230, 230, 230)

    # 开始游戏的主循环
    while True:
        gf.check_events(ai_settings, screen, ship, bullets)
        ship.update()
        gf.update_bullets(bullets)
        gf.update_screen(ai_settings, screen, ship, bullets)

run_game()
class Settings():

    def __init__(self):
        # 屏幕设置
        self.screen_width = 1200
        self.screnn_height = 800
        self.bg_color = (230, 230, 230)

        self.ship_speed_factor = 1.5

        # 子弹设置
        self.bullet_speed_factor = 1
        self.bullet_width = 3
        self.bullet_height = 15
        self.bullet_color = 60, 60, 60
        self.bullets_allowed = 5

 

  暂无计划举行第二部分。

  game_functions

 

import pygame

from pygame.sprite import Sprite

class Bullet(Sprite):

    def __init__(self, ai_settings, screen, ship):
        super(Bullet, self).__init__()
        self.screen = screen

        self.rect = pygame.Rect(0, 0, ai_settings.bullet_width, ai_settings.bullet_height)
        self.rect.centerx = ship.rect.centerx
        self.rect.top = ship.rect.top

        # 存储用小数表示的子弹位置
        self.y = float(self.rect.y)

        self.color = ai_settings.bullet_color
        self.speed_factor = ai_settings.bullet_speed_factor

    def update(self):
        self.y -= self.speed_factor
        # 更新子弹位置
        self.rect.y = self.y

    def draw_bullet(self):
        pygame.draw.rect(self.screen, self.color, self.rect)

  bullet.py