Python小游戏-坦克大战(tank war)

前言

这款游戏一直都是我很喜欢的游戏,很童年,太经典啦!也很好玩,所以我来做一做这款游戏。

开发工具

python版本:3.7.3
相关模块:pygame模块;还有相关的自带的模块

环境搭建

python添加到变量,pip安装相关模块

参考资料

https://mp.weixin.qq.com/s/KuktB_f1vxZCNIAHaaXdsQ

效果


原理介绍

游戏规则:

游戏有单人和双人两种模式,己方大本营被破或者己方坦克被歼灭则游戏失败,成功通过所有关卡则游戏胜利。另外,玩家可以通过射击特定的坦克使地图上随机出现一个道具,若己方坦克捡到该道具,则触发一个事件,例如坦克能力的增强。

玩家操作:

玩家一:
wsad键:上下左右;
空格键:射击。
玩家二:
↑↓←→键:上下左右;
小键盘0键:射击。

实现步骤:

主函数部分内容有点长,下面还有一大段没有拿出来,想看的完整版的,可以到我的仓库下载。不过结构还是比较清晰的。

def main():pygame.init()pygame.mixer.init()screen = pygame.display.set_mode((630, 630))pygame.display.set_caption('坦克大战')bg_img = pygame.image.load('./images/others/background.png')# 加载音效add_sound = pygame.mixer.Sound("./audios/add.wav")add_sound.set_volume(1)bang_sound = pygame.mixer.Sound("./audios/bang.wav")bang_sound.set_volume(1)blast_sound = pygame.mixer.Sound("./audios/blast.wav")blast_sound.set_volume(1)fire_sound = pygame.mixer.Sound("./audios/fire.wav")fire_sound.set_volume(1)Gunfire_sound = pygame.mixer.Sound("./audios/Gunfire.wav")Gunfire_sound.set_volume(1)hit_sound = pygame.mixer.Sound("./audios/hit.wav")hit_sound.set_volume(1)start_sound = pygame.mixer.Sound("./audios/start.wav")start_sound.set_volume(1)# 开始界面num_player = show_start_interface(screen, 630, 630)# 播放游戏开始的音乐start_sound.play()# 关卡stage = 0num_stage = 2# 游戏是否结束is_gameover = False# 时钟clock = pygame.time.Clock()# 主循环while not is_gameover:# 关卡stage += 1if stage > num_stage:breakshow_switch_stage(screen, 630, 630, stage)# 该关卡坦克总数量enemytanks_total = min(stage * 18, 80)# 场上存在的敌方坦克总数量enemytanks_now = 0# 场上可以存在的敌方坦克总数量enemytanks_now_max = min(max(stage * 2, 4), 8)# 精灵组,独立运行的动画组tanksGroup = pygame.sprite.Group()mytanksGroup = pygame.sprite.Group()enemytanksGroup = pygame.sprite.Group()bulletsGroup = pygame.sprite.Group()mybulletsGroup = pygame.sprite.Group()enemybulletsGroup = pygame.sprite.Group()myfoodsGroup = pygame.sprite.Group()# 自定义事件#  -生成敌方坦克事件genEnemyEvent = pygame.constants.USEREVENTpygame.time.set_timer(genEnemyEvent, 100)#  -敌方坦克静止恢复事件recoverEnemyEvent = pygame.constants.USEREVENTpygame.time.set_timer(recoverEnemyEvent, 8000)#  -我方坦克无敌恢复事件noprotectMytankEvent = pygame.constants.USEREVENTpygame.time.set_timer(noprotectMytankEvent, 8000)# 关卡地图map_stage = scene.Map(stage)# 我方坦克tank_player1 = tanks.myTank(1)tanksGroup.add(tank_player1)mytanksGroup.add(tank_player1)if num_player > 1:tank_player2 = tanks.myTank(2)tanksGroup.add(tank_player2)mytanksGroup.add(tank_player2)is_switch_tank = Trueplayer1_moving = Falseplayer2_moving = False# 为了轮胎的动画效果time = 0# 敌方坦克for i in range(0, 3):if enemytanks_total > 0:enemytank = tanks.enemyTank(i)tanksGroup.add(enemytank)enemytanksGroup.add(enemytank)enemytanks_now += 1enemytanks_total -= 1# 大本营myhome = home.Home()# 出场特效appearance_img = pygame.image.load("./images/others/appear.png").convert_alpha()appearances = []appearances.append(appearance_img.subsurface((0, 0), (48, 48)))appearances.append(appearance_img.subsurface((48, 0), (48, 48)))appearances.append(appearance_img.subsurface((96, 0), (48, 48)))
  • 坦克类

下面是我方坦克的代码,对方坦克代码类似,详细的内容在GitHub里。


# 我方坦克类
class myTank(pygame.sprite.Sprite):def __init__(self, player):pygame.sprite.Sprite.__init__(self)# 玩家编号(1/2)self.player = player# 不同玩家用不同的坦克(不同等级对应不同的图)if player == 1:self.tanks = ['./images/myTank/tank_T1_0.png', './images/myTank/tank_T1_1.png','./images/myTank/tank_T1_2.png']elif player == 2:self.tanks = ['./images/myTank/tank_T2_0.png', './images/myTank/tank_T2_1.png','./images/myTank/tank_T2_2.png']else:raise ValueError('myTank class -> player value error.')# 坦克等级(初始0)self.level = 0# 载入(两个tank是为了轮子特效)self.tank = pygame.image.load(self.tanks[self.level]).convert_alpha()self.tank_0 = self.tank.subsurface((0, 0), (48, 48))self.tank_1 = self.tank.subsurface((48, 0), (48, 48))self.rect = self.tank_0.get_rect()# 保护罩self.protected_mask = pygame.image.load('./images/others/protect.png').convert_alpha()self.protected_mask1 = self.protected_mask.subsurface((0, 0), (48, 48))self.protected_mask2 = self.protected_mask.subsurface((48, 0), (48, 48))# 坦克方向self.direction_x, self.direction_y = 0, -1# 不同玩家的出生位置不同if player == 1:self.rect.left, self.rect.top = 3 + 24 * 8, 3 + 24 * 24elif player == 2:self.rect.left, self.rect.top = 3 + 24 * 16, 3 + 24 * 24else:raise ValueError('myTank class -> player value error.')# 坦克速度self.speed = 3# 是否存活self.being = True# 有几条命self.life = 3# 是否处于保护状态self.protected = False# 子弹self.bullet = Bullet()# 射击def shoot(self):self.bullet.being = Trueself.bullet.turn(self.direction_x, self.direction_y)if self.direction_x == 0 and self.direction_y == -1:self.bullet.rect.left = self.rect.left + 20self.bullet.rect.bottom = self.rect.top - 1elif self.direction_x == 0 and self.direction_y == 1:self.bullet.rect.left = self.rect.left + 20self.bullet.rect.top = self.rect.bottom + 1elif self.direction_x == -1 and self.direction_y == 0:self.bullet.rect.right = self.rect.left - 1self.bullet.rect.top = self.rect.top + 20elif self.direction_x == 1 and self.direction_y == 0:self.bullet.rect.left = self.rect.right + 1self.bullet.rect.top = self.rect.top + 20else:raise ValueError('myTank class -> direction value error.')if self.level == 0:self.bullet.speed = 8self.bullet.stronger = Falseelif self.level == 1:self.bullet.speed = 12self.bullet.stronger = Falseelif self.level == 2:self.bullet.speed = 12self.bullet.stronger = Trueelif self.level == 3:self.bullet.speed = 16self.bullet.stronger = Trueelse:raise ValueError('myTank class -> level value error.')# 等级提升def up_level(self):if self.level < 3:self.level += 1try:self.tank = pygame.image.load(self.tanks[self.level]).convert_alpha()except:self.tank = pygame.image.load(self.tanks[-1]).convert_alpha()# 等级降低def down_level(self):if self.level > 0:self.level -= 1self.tank = pygame.image.load(self.tanks[self.level]).convert_alpha()# 向上def move_up(self, tankGroup, brickGroup, ironGroup, myhome):self.direction_x, self.direction_y = 0, -1# 先移动后判断self.rect = self.rect.move(self.speed * self.direction_x, self.speed * self.direction_y)self.tank_0 = self.tank.subsurface((0, 0), (48, 48))self.tank_1 = self.tank.subsurface((48, 0), (48, 48))# 是否可以移动is_move = True# 地图顶端if self.rect.top < 3:self.rect = self.rect.move(self.speed * -self.direction_x, self.speed * -self.direction_y)is_move = False# 撞石头/钢墙if pygame.sprite.spritecollide(self, brickGroup, False, None) or \pygame.sprite.spritecollide(self, ironGroup, False, None):self.rect = self.rect.move(self.speed * -self.direction_x, self.speed * -self.direction_y)is_move = False# 撞其他坦克if pygame.sprite.spritecollide(self, tankGroup, False, None):self.rect = self.rect.move(self.speed * -self.direction_x, self.speed * -self.direction_y)is_move = False# 大本营if pygame.sprite.collide_rect(self, myhome):self.rect = self.rect.move(self.speed * -self.direction_x, self.speed * -self.direction_y)is_move = Falsereturn is_move# 向下def move_down(self, tankGroup, brickGroup, ironGroup, myhome):self.direction_x, self.direction_y = 0, 1# 先移动后判断self.rect = self.rect.move(self.speed * self.direction_x, self.speed * self.direction_y)self.tank_0 = self.tank.subsurface((0, 48), (48, 48))self.tank_1 = self.tank.subsurface((48, 48), (48, 48))# 是否可以移动is_move = True# 地图底端if self.rect.bottom > 630 - 3:self.rect = self.rect.move(self.speed * -self.direction_x, self.speed * -self.direction_y)is_move = False# 撞石头/钢墙if pygame.sprite.spritecollide(self, brickGroup, False, None) or \pygame.sprite.spritecollide(self, ironGroup, False, None):self.rect = self.rect.move(self.speed * -self.direction_x, self.speed * -self.direction_y)is_move = False# 撞其他坦克if pygame.sprite.spritecollide(self, tankGroup, False, None):self.rect = self.rect.move(self.speed * -self.direction_x, self.speed * -self.direction_y)is_move = False# 大本营if pygame.sprite.collide_rect(self, myhome):self.rect = self.rect.move(self.speed * -self.direction_x, self.speed * -self.direction_y)is_move = Falsereturn is_move# 向左def move_left(self, tankGroup, brickGroup, ironGroup, myhome):self.direction_x, self.direction_y = -1, 0# 先移动后判断self.rect = self.rect.move(self.speed * self.direction_x, self.speed * self.direction_y)self.tank_0 = self.tank.subsurface((0, 96), (48, 48))self.tank_1 = self.tank.subsurface((48, 96), (48, 48))# 是否可以移动is_move = True# 地图左端if self.rect.left < 3:self.rect = self.rect.move(self.speed * -self.direction_x, self.speed * -self.direction_y)is_move = False# 撞石头/钢墙if pygame.sprite.spritecollide(self, brickGroup, False, None) or \pygame.sprite.spritecollide(self, ironGroup, False, None):self.rect = self.rect.move(self.speed * -self.direction_x, self.speed * -self.direction_y)is_move = False# 撞其他坦克if pygame.sprite.spritecollide(self, tankGroup, False, None):self.rect = self.rect.move(self.speed * -self.direction_x, self.speed * -self.direction_y)is_move = False# 大本营if pygame.sprite.collide_rect(self, myhome):self.rect = self.rect.move(self.speed * -self.direction_x, self.speed * -self.direction_y)is_move = Falsereturn is_move# 向右def move_right(self, tankGroup, brickGroup, ironGroup, myhome):self.direction_x, self.direction_y = 1, 0# 先移动后判断self.rect = self.rect.move(self.speed * self.direction_x, self.speed * self.direction_y)self.tank_0 = self.tank.subsurface((0, 144), (48, 48))self.tank_1 = self.tank.subsurface((48, 144), (48, 48))# 是否可以移动is_move = True# 地图右端if self.rect.right > 630 - 3:self.rect = self.rect.move(self.speed * -self.direction_x, self.speed * -self.direction_y)is_move = False# 撞石头/钢墙if pygame.sprite.spritecollide(self, brickGroup, False, None) or \pygame.sprite.spritecollide(self, ironGroup, False, None):self.rect = self.rect.move(self.speed * -self.direction_x, self.speed * -self.direction_y)is_move = False# 撞其他坦克if pygame.sprite.spritecollide(self, tankGroup, False, None):self.rect = self.rect.move(self.speed * -self.direction_x, self.speed * -self.direction_y)is_move = False# 大本营if pygame.sprite.collide_rect(self, myhome):self.rect = self.rect.move(self.speed * -self.direction_x, self.speed * -self.direction_y)is_move = Falsereturn is_move# 死后重置def reset(self):self.level = 0self.protected = Falseself.tank = pygame.image.load(self.tanks[self.level]).convert_alpha()self.tank_0 = self.tank.subsurface((0, 0), (48, 48))self.tank_1 = self.tank.subsurface((48, 0), (48, 48))self.rect = self.tank_0.get_rect()self.direction_x, self.direction_y = 0, -1if self.player == 1:self.rect.left, self.rect.top = 3 + 24 * 8, 3 + 24 * 24elif self.player == 2:self.rect.left, self.rect.top = 3 + 24 * 16, 3 + 24 * 24else:raise ValueError('myTank class -> player value error.')self.speed = 3
  • 子弹类
# 子弹类
class Bullet(pygame.sprite.Sprite):def __init__(self):pygame.sprite.Sprite.__init__(self)# 子弹四个方向(上下左右)self.bullets = ['./images/bullet/bullet_up.png', './images/bullet/bullet_down.png','./images/bullet/bullet_left.png', './images/bullet/bullet_right.png']# 子弹方向(默认向上)self.direction_x, self.direction_y = 0, -1self.bullet = pygame.image.load(self.bullets[0])self.rect = self.bullet.get_rect()# 在坦克类中再赋实际值self.rect.left, self.rect.right = 0, 0# 速度self.speed = 6# 是否存活self.being = False# 是否为加强版子弹(可碎钢板)self.stronger = False# 改变子弹方向def turn(self, direction_x, direction_y):self.direction_x, self.direction_y = direction_x, direction_yif self.direction_x == 0 and self.direction_y == -1:self.bullet = pygame.image.load(self.bullets[0])elif self.direction_x == 0 and self.direction_y == 1:self.bullet = pygame.image.load(self.bullets[1])elif self.direction_x == -1 and self.direction_y == 0:self.bullet = pygame.image.load(self.bullets[2])elif self.direction_x == 1 and self.direction_y == 0:self.bullet = pygame.image.load(self.bullets[3])else:raise ValueError('Bullet class -> direction value error.')# 移动def move(self):self.rect = self.rect.move(self.speed * self.direction_x, self.speed * self.direction_y)# 到地图边缘后消失if (self.rect.top < 3) or (self.rect.bottom > 630 - 3) or (self.rect.left < 3) or (self.rect.right > 630 - 3):self.being = False
  • 技能类
# 技能类, 用于提升坦克能力
class Food(pygame.sprite.Sprite):def __init__(self):pygame.sprite.Sprite.__init__(self)# 消灭当前所有敌人self.food_boom = './images/food/food_boom.png'# 当前所有敌人静止一段时间self.food_clock = './images/food/food_clock.png'# 使得坦克子弹可碎钢板self.food_gun = './images/food/food_gun.png'# 使得大本营的墙变为钢板self.food_iron = './images/food/food_gun.png'# 坦克获得一段时间的保护罩self.food_protect = './images/food/food_protect.png'# 坦克升级self.food_star = './images/food/food_star.png'# 坦克生命+1self.food_tank = './images/food/food_tank.png'# 所有食物self.foods = [self.food_boom, self.food_clock, self.food_gun, self.food_iron, self.food_protect, self.food_star,self.food_tank]self.kind = Noneself.food = Noneself.rect = None# 是否存在self.being = False# 存在时间self.time = 1000# 生成食物def generate(self):self.kind = random.randint(0, 6)self.food = pygame.image.load(self.foods[self.kind]).convert_alpha()self.rect = self.food.get_rect()self.rect.left, self.rect.top = random.randint(100, 500), random.randint(100, 500)self.being = True
  • 背景类

背景类主要设置了墙、河流、树、冰类。还有每个关卡的地图布局,楼楼偷懒啦,只设置了两个关卡。有兴趣的小伙伴,可以继续补充,设置更多有趣的关卡。

# 场景类(墙、河流、树、冰)
# 地图设置
import pygame
import random# 石头墙
class Brick(pygame.sprite.Sprite):def __init__(self):pygame.sprite.Sprite.__init__(self)self.brick = pygame.image.load('./images/scene/brick.png')self.rect = self.brick.get_rect()self.being = False# 钢墙
class Iron(pygame.sprite.Sprite):def __init__(self):pygame.sprite.Sprite.__init__(self)self.iron = pygame.image.load('./images/scene/iron.png')self.rect = self.iron.get_rect()self.being = False# 冰
class Ice(pygame.sprite.Sprite):def __init__(self):pygame.sprite.Sprite.__init__(self)self.ice = pygame.image.load('./images/scene/ice.png')self.rect = self.ice.get_rect()self.being = False# 河流
class River(pygame.sprite.Sprite):def __init__(self, kind=None):pygame.sprite.Sprite.__init__(self)if kind is None:self.kind = random.randint(0, 1)self.rivers = ['./images/scene/river1.png', './images/scene/river2.png']self.river = pygame.image.load(self.rivers[self.kind])self.rect = self.river.get_rect()self.being = False# 树
class Tree(pygame.sprite.Sprite):def __init__(self):pygame.sprite.Sprite.__init__(self)self.tree = pygame.image.load('./images/scene/tree.png')self.rect = self.tree.get_rect()self.being = False# 地图
class Map():def __init__(self, stage):self.brickGroup = pygame.sprite.Group()self.ironGroup = pygame.sprite.Group()self.iceGroup = pygame.sprite.Group()self.riverGroup = pygame.sprite.Group()self.treeGroup = pygame.sprite.Group()if stage == 1:self.stage1()elif stage == 2:self.stage2()# 关卡一def stage1(self):for x in [2, 3, 6, 7, 18, 19, 22, 23]:for y in [2, 3, 4, 5, 6, 7, 8, 9, 10, 17, 18, 19, 20, 21, 22, 23]:self.brick = Brick()self.brick.rect.left, self.brick.rect.top = 3 + x * 24, 3 + y * 24self.brick.being = Trueself.brickGroup.add(self.brick)for x in [10, 11, 14, 15]:for y in [2, 3, 4, 5, 6, 7, 8, 11, 12, 15, 16, 17, 18, 19, 20]:self.brick = Brick()self.brick.rect.left, self.brick.rect.top = 3 + x * 24, 3 + y * 24self.brick.being = Trueself.brickGroup.add(self.brick)for x in [4, 5, 6, 7, 18, 19, 20, 21]:for y in [13, 14]:self.brick = Brick()self.brick.rect.left, self.brick.rect.top = 3 + x * 24, 3 + y * 24self.brick.being = Trueself.brickGroup.add(self.brick)for x in [12, 13]:for y in [16, 17]:self.brick = Brick()self.brick.rect.left, self.brick.rect.top = 3 + x * 24, 3 + y * 24self.brick.being = Trueself.brickGroup.add(self.brick)for x, y in [(11, 23), (12, 23), (13, 23), (14, 23), (11, 24), (14, 24), (11, 25), (14, 25)]:self.brick = Brick()self.brick.rect.left, self.brick.rect.top = 3 + x * 24, 3 + y * 24self.brick.being = Trueself.brickGroup.add(self.brick)for x, y in [(0, 14), (1, 14), (12, 6), (13, 6), (12, 7), (13, 7), (24, 14), (25, 14)]:self.iron = Iron()self.iron.rect.left, self.iron.rect.top = 3 + x * 24, 3 + y * 24self.iron.being = Trueself.ironGroup.add(self.iron)# 关卡二def stage2(self):for x in [2, 3, 6, 7, 18, 19, 22, 23]:for y in [2, 3, 4, 5, 6, 7, 8, 9, 10, 17, 18, 19, 20, 21, 22, 23]:self.brick = Brick()self.brick.rect.left, self.brick.rect.top = 3 + x * 24, 3 + y * 24self.brick.being = Trueself.brickGroup.add(self.brick)for x in [10, 11, 14, 15]:for y in [2, 3, 4, 5, 6, 7, 8, 11, 12, 15, 16, 17, 18, 19, 20]:self.brick = Brick()self.brick.rect.left, self.brick.rect.top = 3 + x * 24, 3 + y * 24self.brick.being = Trueself.brickGroup.add(self.brick)for x in [4, 5, 6, 7, 18, 19, 20, 21]:for y in [13, 14]:self.brick = Brick()self.brick.rect.left, self.brick.rect.top = 3 + x * 24, 3 + y * 24self.brick.being = Trueself.brickGroup.add(self.brick)for x in [12, 13]:for y in [16, 17]:self.brick = Brick()self.brick.rect.left, self.brick.rect.top = 3 + x * 24, 3 + y * 24self.brick.being = Trueself.brickGroup.add(self.brick)for x, y in [(11, 23), (12, 23), (13, 23), (14, 23), (11, 24), (14, 24), (11, 25), (14, 25)]:self.brick = Brick()self.brick.rect.left, self.brick.rect.top = 3 + x * 24, 3 + y * 24self.brick.being = Trueself.brickGroup.add(self.brick)for x, y in [(0, 14), (1, 14), (12, 6), (13, 6), (12, 7), (13, 7), (24, 14), (25, 14)]:self.iron = Iron()self.iron.rect.left, self.iron.rect.top = 3 + x * 24, 3 + y * 24self.iron.being = Trueself.ironGroup.add(self.iron)def protect_home(self):for x, y in [(11, 23), (12, 23), (13, 23), (14, 23), (11, 24), (14, 24), (11, 25), (14, 25)]:self.iron = Iron()self.iron.rect.left, self.iron.rect.top = 3 + x * 24, 3 + y * 24self.iron.being = Trueself.ironGroup.add(self.iron)
  • 子弹类
# 子弹类
class Bullet(pygame.sprite.Sprite):def __init__(self):pygame.sprite.Sprite.__init__(self)# 子弹四个方向(上下左右)self.bullets = ['./images/bullet/bullet_up.png', './images/bullet/bullet_down.png','./images/bullet/bullet_left.png', './images/bullet/bullet_right.png']# 子弹方向(默认向上)self.direction_x, self.direction_y = 0, -1self.bullet = pygame.image.load(self.bullets[0])self.rect = self.bullet.get_rect()# 在坦克类中再赋实际值self.rect.left, self.rect.right = 0, 0# 速度self.speed = 6# 是否存活self.being = False# 是否为加强版子弹(可碎钢板)self.stronger = False# 改变子弹方向def turn(self, direction_x, direction_y):self.direction_x, self.direction_y = direction_x, direction_yif self.direction_x == 0 and self.direction_y == -1:self.bullet = pygame.image.load(self.bullets[0])elif self.direction_x == 0 and self.direction_y == 1:self.bullet = pygame.image.load(self.bullets[1])elif self.direction_x == -1 and self.direction_y == 0:self.bullet = pygame.image.load(self.bullets[2])elif self.direction_x == 1 and self.direction_y == 0:self.bullet = pygame.image.load(self.bullets[3])else:raise ValueError('Bullet class -> direction value error.')# 移动def move(self):self.rect = self.rect.move(self.speed * self.direction_x, self.speed * self.direction_y)# 到地图边缘后消失if (self.rect.top < 3) or (self.rect.bottom > 630 - 3) or (self.rect.left < 3) or (self.rect.right > 630 - 3):self.being = False
  • 大本营类
# 大本营类
class Home(pygame.sprite.Sprite):def __init__(self):pygame.sprite.Sprite.__init__(self)self.homes = ['./images/home/home1.png', './images/home/home2.png', './images/home/home_destroyed.png']self.home = pygame.image.load(self.homes[0])self.rect = self.home.get_rect()self.rect.left, self.rect.top = (3 + 12 * 24, 3 + 24 * 24)self.alive = True# 大本营置为摧毁状态def set_dead(self):self.home = pygame.image.load(self.homes[-1])self.alive = False

以上是游戏总结的一些模块。首先展示游戏开始界面,玩家在此界面选择游戏模式后进入游戏;在游戏中,需要进行一系列的碰撞检测以及触发碰撞产生的一系列事件,并绘制当前存在的所有物体;最后,若游戏失败,则显示游戏失败界面,若通关,则显示游戏成功界面。

完整源代码和游戏的一些素材都在我的仓库里,自行下载查看即可~

源码地址:https://github.com/NicolasAcci/Python-Game

Python小游戏-坦克大战(tank war)相关推荐

  1. HTML源码小游戏——坦克大战、飞机大战、捕鱼达人

    捕鱼达人小游戏 飞机大战小游戏 坦克大战小游戏        关注公众号"程序员秋田君",回复 坦克大战.飞机大战.捕鱼达人等信息即可获取源码文件.                 ...

  2. python小游戏——兔鼠大战

    python小游戏--兔鼠大战 一.准备环境:更改设置pip 国内镜像 在使用pycharm来制作小游戏写代码的时候需要编译环境,使用pip镜像源,由于pip管理工具安装库文件时,默认使用国外的源文件 ...

  3. c语言编程简单小游戏坦克大战,坦克大战1990(c语言文件版)游戏

    坦克大战1990(c语言文件版)是一款很炫的坦克战争类游戏.游戏设计感很强.敌人千变万化,但是你可别被迷惑哦,将他们通通歼灭吧! 作者的话 经过四五天的奋斗,第一次编的游戏终于完成了,好激动. 首先得 ...

  4. 【Python】Python小游戏--飞机大战

    一.前言 今天已经初四,舒服的在家躺尸的春节也算过去了,又要开始辛勤的(苦逼的)学习和工作了.说点题外话,今年春节的病毒疫情真的弄的人心惶惶,我也在这为国家和武汉加油,也向一线工作人员致敬,希望早日结 ...

  5. Python小游戏——坦克飞机大战(附源码)

    一.学习目标: 1.掌握用Python写自己的小游戏. 2.掌握面向对象编程语言的特点. 3.掌握Python基础 二.学习内容: 1.Python文件操作. 2.Python 类的定义与使用 3.P ...

  6. C++小游戏---坦克大战(一)

    刚开始写的时候想想这个应该是非常好写的,但是写到后面,尤其是遇到很多莫名其妙的bug之后,发现似乎没那么简单.以下是开发过程中的一些想法,在这里做个笔记. 目录 游戏介绍 素材引入 初始化 全局初始化 ...

  7. 火箭工作室c++小游戏——坦克大战(初始版)

    今天第四次写博客,给大家发一个坦克大战的初始版,可以开外挂,要自己去探索 #include<windows.h> #include<conio.h> #include<i ...

  8. 射击类小游戏——坦克大战(java实现)

    项目名称:坦克大战 项目背景:坦克大战是一款非常经典的游戏,也是学习面向对象编程的理想实例.现在面向对象的计算机编程语言很多,很多想法都可以通过编程来实现.本文的坦克大战有完整的界面,能够实现人机大战 ...

  9. python小游戏——飞机大战小游戏(附源码)

    写在前面的一些P话: 大家之前用python编写过飞机大战的部分代码, 只能够展示英雄飞机,背景,敌机和发射子弹, 今天把背景音乐,击毁敌机,爆炸特效,得分等等相关功能一并加入进来, 代码有点长,三百 ...

最新文章

  1. 将一个数组中的字符串用指定字符分割开,分别放到另一个数组中
  2. chrome插件开发
  3. 关于跨域,以及跨域的几种方式
  4. 基于VS2019的Eigen库安装详解
  5. 插入始终是1_OneNote使用小记(1)——针对PPT做笔记及最合适的PPT插入方式
  6. python语言-Python语言介绍
  7. 函数名应用,闭包,装饰器初识
  8. 数据结构之双向链表----Python
  9. 20200518每日一句
  10. HTML5教程书籍电子版30本合集
  11. 买个云服务器搭建自己的ngrok做微信公众号开发
  12. 高通华裔工程师跳楼自杀!中年IT男,为何这么难?
  13. oracle备份显示要启动介质,RMAN备份,出现介质无法恢复的情况
  14. 蓝牙简介 | bluetooth
  15. 用TortoiseGit Git clone时Load Putty Key是灰色的
  16. U-Mail邮件中继功能使用方法
  17. linux安装nginx详细步骤和make编译报错问题(保姆级)
  18. 贴吧顶贴php脚步,【技术贴安卓按键精灵】贴吧顶贴脚本源码分享
  19. Java包名的命名规则
  20. 微信小程序蓝牙连接硬件设备并进行通讯,小程序蓝牙因距离异常断开自动重连,js实现crc校验位

热门文章

  1. 搭建论坛如何选择服务器
  2. Back to Back vs Drop Shipment
  3. DP1363F高度集成的非接触读写芯片 13.56M NFC/RFID读卡器芯片 兼容替代CLRC663
  4. Win11下载和安装T3标准版11.2
  5. 程控仪器标准命令SCPI
  6. 清华p-tuning | GPT也能做NLU?清华推出p-tuning方法解决GPT系列模型fine-tuning效果比BERT差问题
  7. Lua性能优化—Lua内存优化
  8. 小程序Swiper组件做日历(周历)左右滑动动态修改数据
  9. “争议话题”事件营销成败与否的关键
  10. 网卡IP地址信息一键查看工具V1.0-免费版