python手机版做小游戏代码大全-python小游戏实现代码

早上逛CSDN首页就见到这么一篇教程。看了一下很有意思,就马上动手实现了一下。看看效果吧:

SouthEast

SouthEast

完整代码:

# -*- coding: utf-8 -*-

# 1 - Import library

import pygame

from pygame.locals import *

import math

import random

# 2 - Initialize the game

keys = [False, False, False, False]

playerpos=[100,100]

acc=[0,0]

arrows=[]

badtimer=100

badtimer1=0

badguys=[[640,100]]

healthvalue=194

pygame.init()

width, height = 640, 480

screen=pygame.display.set_mode((width, height))

pygame.mixer.init()

# 3 - Load images

player = pygame.image.load("resources/images/dude.png")

grass = pygame.image.load("resources/images/grass.png")

castle = pygame.image.load("resources/images/castle.png")

arrow = pygame.image.load("resources/images/bullet.png")

badguyimg1 = pygame.image.load("resources/images/badguy.png")

gameover = pygame.image.load("resources/images/gameover.png")

youwin = pygame.image.load("resources/images/youwin.png")

healthbar = pygame.image.load("resources/images/healthb

  • 2
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值