python大鱼吃小鱼程序代码_pygame大鱼吃小鱼源代码

pygame big fish eat small fish大鱼吃小鱼游戏界面

以下是部分代码预览:

"""pygame大鱼吃小鱼,这是本人曾经制作的一个小练习,现在翻出来以飨读者,以前为了方便学生理解程序,用了些中文变量。"""

import pygame

from pygame.locals import *

import math

from random import randint

pygame.init()

screen = pygame.display.set_mode((480,360))

pygame.display.set_caption("pygame大鱼吃小鱼_作者:李兴球")

class Bigfish():

def __init__(self,rightImageList,leftImageList,x,y):

self.imageindex = 0 # 相当于造型编号

self.direction=0 # 0表示右,1左

self.imageList = [rightImageList,leftImageList]

self.image = self.imageList[self.direction][self.imageindex]

pass

def move(self,mx,my): # mx是鼠标指针的x坐标

dx = self.rect.centerx - mx # dx大于0,表示鱼在鼠标指针右边,这时它的方向为左.

if dx!=0: self.direction= (dx//abs(dx) + 1)//2

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值