操作一只小猫在一个大花园里走来走去,配的音乐效果不错。
下面是部分代码预览:
"""本程序操作一只小猫在一个绿色的园林中行走,其实小猫的坐标是不变的,变的是地图坐标""" import time import pygame from pygame.locals import * width,height = 480,360 screen = pygame.display.set_mode((width,height)) pygame.display.set_caption("大地图相对运动scratch小猫过桥 www.lixingqiu.com") pygame.mixer.init() pygame.mixer.music.load("Grandia OST - Delightful Adventure.wav") pygame.mixer.music.play(-1,0) ground = pygame.image.load("地图.png") size = ground.get_size() ground = pygame.transform.scale(ground,(size[0] * 3,size[1] * 3)) # 放大3倍地图 cat = Actor(images_right,images_left) cat.rect.center = width//2,height//2 running = True cat.start_time = time.time() clock = pygame.time.Clock() while running: for event in pygame.event.get(): if event.type == QUIT:running = False ground_rect.move_ip(ground_dx,ground_dy) cat.update() screen.fill((102,226,60)) screen.blit(ground,ground_rect) screen.blit(cat.image,cat.rect) pygame.display.update() clock.tick(60) pygame.quit()
下载完整源代码与素材,请
需要浏览更多吗?
成为会员后,登陆才能继续浏览!联系微信scratch8即可办理会员。
(会员专属:能浏览所有文章,下载所有带链接的Python资源。)