当前位置:网站首页>[pyGame] the classic boss of soul duel is back. Are you ready to defeat them again? (source code attached)
[pyGame] the classic boss of soul duel is back. Are you ready to defeat them again? (source code attached)
2022-07-21 01:03:00 【Programmer pear】
Preface
author :“ Programmer pear ”
** The article brief introduction **: This article is mainly about the use of Turtle I wrote a few small codes for confession ~
** The source code of the article is available for free : In order to thank everyone who pays attention to me, the project source code of each article is none
Compensation sharing drop
Welcome friends give the thumbs-up 、 Collection 、 Leaving a message.
Text
“ When facing a new market , We can no longer simply “ The old ” or “ new ” To define a game .”
Soul Douluo is a classic action shooting game , In the game market at that time , It can be said to be a very challenging tour
Play . After all, the news was blocked at that time , There is no strategy at all , What's more, when I was young , Playing the game is refreshing , Many people don't
Will deliberately study the card position in depth 、 Combat skills, etc , Is the most basic bump 、 Twinkle , So there was N A death experience .
Today, Xiaobian will take you to knock 《 Classic soul duel 》 game . The code version of soul duel will be launched today ~ Everyone is looking forward to ?
The rules of the game : Up, down, left and right, everyone is familiar with ——ASDW key ,K jumping ,J Put the gun .
After fighting a small soldier and a big one boss It was a success . Uh huh —— Super simple , A winning game with hands 23333!
Running environment
The environment used in this article :Python3.6、Pycharm Community Edition 、Pygame What comes with the game module will not be displayed .
pip install -i https://pypi.douban.com/simple/ + Module name
Material preparation
Pixel style mission personas ( Only part )
The background picture shows :
Main character material :( Partial diagram )
Effect display
1)Part 1 Initialization interface 🧛*️
2)Part 2 hit BOSS🧛*️
3)Part 3 victory
Code display
There are too many codes , Show only the main program .
import pygame
import sys
from pygame.locals import *
from settings import Settings
from game_player import Game_Player
import game_functions as gf
from pygame.sprite import Group
from game_stats import GameStats
from game_boss import Game_Boss
from button import Button
def run_game():
bg = pygame.image.load(" picture /map01.jpeg")
game_settings = Settings()
pos_x = 0# The map moves o
pygame.init()
screen = pygame.display.set_mode(
(game_settings.screen_width,game_settings.screen_height))
pygame.display.set_caption(" Classic pixel wind game —— Contra ")
stats = GameStats(game_settings)
player = Game_Player(game_settings,screen)
bullets = Group()
boss = Group()
enemys = Group()
win_button = Button(game_settings,screen,"YOU WIN")
gf.create_legion(game_settings,screen,enemys)
gf.create_boss(game_settings,screen,player,boss)
while True:
pygame.mouse.set_visible(False)
gf.check_events(game_settings,screen,player,bullets)
gf.update_player(game_settings,stats,player,enemys)
gf.update_bullet(game_settings,bullets,screen,enemys,boss)
gf.update_enemys(game_settings,enemys)
gf.update_boss(game_settings,boss)
gf.update_screen(game_settings,bg,pos_x,screen,player,bullets,enemys,boss,win_button)
if player.moving_right and player.center > player.screen_rect.centerx and game_settings.boss_appear == False:
game_settings.screen_rolling = True
pos_x -= 5# Screen scrolling speed
else:
game_settings.screen_rolling = False
run_game()
summary
All right. , This action shooting mobile game 《 Contra 》 Back , See if you can pass the customs side by side ? Be tough this time ! Ha ha ha
An LA ! This is the article , Your support is my biggest motivation , Remember Sanlian ~( It's really hot , This day .jpg)
Follow Xiaobian for more wonderful content ! Remember to click on the portal
Remember Sanlian ! If you need to package the complete source code + Free sharing of materials !! Portal
边栏推荐
- 张量的通俗理解
- 电气成套设备制造企业项目管理难点及解决方案
- ADG备库可以进行数据泵导出吗?不可以
- [leetcode] split the basic template and find the left and right boundaries
- What are the differences and connections between cloud computing and edge computing?
- 液晶ST7302图像缓存结构
- How to use parallel programming to improve task execution efficiency
- 和利时LE5107_LE5106_自由口协议
- 合规视角下的数据安全技术前沿与应用
- Operation of variables in MySQL
猜你喜欢
Qt:Could not find qmake spec ‘default’.Error while parsing file xxx.pro. Giving up
Leetcode- number of occurrences of numbers in the array (single dog problem)
ViT【backbone】
和利时LE5107_LE5106_自由口协议
Unlock high scores | eBay deepens user experience and optimizes large screen device applications
网络流,二分图与图的匹配
Win11暂存文件夹是什么?Win11在线升级暂存文件夹在哪
如何查看Win11可以升级22h2?Win11升级22h2的方法
This domestic conscience software is officially open source!
机械制造企业,如何借助ERP系统解决仓库管理难题?
随机推荐
想低成本保障軟件安全?五大安全任務值得考慮
Main research directions of Intelligent Question Answering
Dynamic memory management + flexible array
Unity中的Animation动画倒播、正播
CCTV news "Shanghai rent quota invoice by hand" news channel_ People's network
QT_嵌入式主界面添加与切换效果
容易被忽视的五个安全环节,比想象中的更危险!
CCTV news "Chongqing opens accommodation quota invoice by hand" news channel_ People's network
Some rules for implicit conversion of SAP ABAP character and string variables
想低成本保障软件安全?五大安全任务值得考虑
CCTV news news "Suzhou restaurant manual tearing quota invoice" news channel_ People's network
tkinter各种控件库控件创建速度比较
Win11暂存文件夹是什么?Win11在线升级暂存文件夹在哪
我的书《Oracle Database In-Memory架构与实践》出版了
程序环境和预处理详解
归并排序及优化
液晶ST7302图像缓存结构
Arduino读取传感器数据存进Excel中
NVIDIA NX usage notes
2022/7/19