会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132590个问题
JAVA 全系列/第九阶段:Spring Boot实战/Spring Boot 24136楼
JAVA 全系列/第十一阶段:分布式RPC调用和分布式文件存储/Zookeeper 24138楼

捕获.PNG

老师请问我这个是什么问题啊 server.xml端口也没改 

JAVA 全系列/第二阶段:JAVA 基础深化和提高/手写服务器项目(旧) 24139楼
Python 全系列/第二阶段:Python 深入与提高/文件处理 24140楼
Python 全系列/第二阶段:Python 深入与提高/文件处理 24141楼

vue_shop.zip

后端接口写完了以后,前端页面菜单显示不出来  一片空白

image.png

Python 全系列/第十阶段:Flask百战电商后台项目/Flask百战电商后台项目 24142楼
Python 全系列/第十阶段:Flask百战电商后台项目/Flask百战电商后台项目 24143楼
Python 全系列/第一阶段:Python入门/编程基本概念 24144楼
Python 全系列/第五阶段:数据库编程/mysql的使用 24145楼

xml:

<?xml version="1.0" encoding="UTF-8"?>
<books xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:noNamespaceSchemaLocation="book.xsd">
    <book id="1001">
        <name>java开发实战</name>
        <author>张小三</author>
        <price>98.5</price>

    </book>
    <book id="1002">
        <name>mysql从删库到跑路</name>
        <author>王一一</author>
        <price>89.7</price>

    </book>
</books>

xsd:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" >
    <xs:element name="books">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="book" maxOccurs="unbounded">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="name" type="xs:string"></xs:element>
                            <xs:element name="author" type="xs:string"></xs:element>
                            <xs:element name="price" type="xs:double"></xs:element>
                        </xs:sequence>
                        <xs:attribute name="id" type="xs:positiveInteger" use="required"></xs:attribute>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

Test:

package com.bjsxt;

import org.xml.sax.SAXException;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import java.io.File;
import java.io.IOException;

public class Test {
    public static void main(String[] args) throws SAXException {
        //创建SchemaFactory工厂
        SchemaFactory sch = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema-instance");
        //验证文件对象
        File schemaFile = new File("book.xsd");
        //利用SchemaFactory工厂对象,接收验证的文件对象,生成Schema对象
        Schema schema = sch.newSchema(schemaFile);
        //产生对此Schema的验证器
        Validator validator = schema.newValidator();
        //要验证的数据(准备数据源)
        Source source = new StreamSource("book.xml");
        //开始验证
        try {
            validator.validate(source);
            System.out.println("成功");
        } catch (IOException e) {
            e.printStackTrace();
            System.out.println("失败");
        }
    }
}

文件位置:

image.png

运行时的错误

image.png

JAVA 全系列/第二阶段:JAVA 基础深化和提高/XML 技术(旧) 24146楼
JAVA 全系列/第十八阶段:亿级高并发电商项目_架构/编码(旧)/电商:基于FastDFS+Nginx+Kinkeditor实现商品新增 24147楼
Python 全系列/第二阶段:Python 深入与提高/GUI编程(隐藏) 24149楼

'''
新增功能:
左上角文字绘制:
左上角输出敌方坦克的绘制
'''
'''
1.分清楚哪些类
2.类中的方法
1.类
1.坦克
  射击
  移动
  显示坦克的方法
2.墙壁
  属性:是否可以通过
3.子弹
  移动
  显示子弹的方法
4.爆炸效果
  展示爆炸效果
5.音效
  播放音乐
6.主类
 开始游戏
 结束游戏
'''
'''
新增功能:
加载主窗口
www.pygame.org
'''
'''
新增功能:
   添加事件
   1.点击关闭 关闭窗口
   2.按下键盘时候,判断键盘按下的是什么键'''
#导入pygame模块
import pygame
SCREEN_WIDTH=700
SCREEN_HEIGHT=500
BG_COLOR=pygame.Color(0,0,0)
TEXT_COLOR=pygame.Color(255,0,0)
class MainGame():
    window=None
    def __init__(self):
        pass
    #开始游戏
    def startGame(self):
        #加载主窗口
        #初始化
        pygame.display.init()
        #设置窗口的大小及显示
        MainGame.window=pygame.display.set_mode([SCREEN_WIDTH,SCREEN_HEIGHT])
        #设置窗口的标题
        pygame.display.set_caption('坦克大战1.03')
        while True:
            #给窗口设置填充色
            MainGame.window.fill(BG_COLOR)
            #获取事件
            self.getEvent()
            #绘制文字
            MainGame.window.blit(self.getTextSurface('敌方坦克剩余数量%d'%6),(10,10))
            pygame.display.update()
    #结束游戏
    def endGame(self):
        print('谢谢使用,欢迎再次使用')
        exit()
        #左上角文字的绘制
    def getTextSurface(self):
        #初始化文字绘制
        pygame.font.init()
        #查看所有的字体名称
        #print(pygame.font.get_fonts())
        #获取字体Font对象
        #获取字体的对象
        font=pygame.font.SysFont('georgia',18)
        #绘制文字信息
        font.render(text,True,TEXT_COLOR)
        return textSurface
        #获取事件
    #结束游戏
    def endGame(self):
        pass
    #获取事件
    def getEvent(self):
        #获取所有事件
        eventList=pygame.event.get()
        #遍历事件
        for event in eventList:
            #判断按下的键是关闭还是键盘按下
            #如果按下的是关闭,退出
            if event.type == pygame.QUIT:
                self.endGame()
            #如果是键盘的按下
            if event.type == pygame.KEYDOWN:
                #判断按下的是上下左右
                if event.key == pygame.K_LEFT:
                    print('按下左键,坦克向左移动')
                if event.key == pygame.K_RIGHT:
                    print('按下右键,坦克向右移动')
                if event.key == pygame.K_UP:
                    print('按下上键,坦克向上移动')
                if event.key == pygame.K_DOWN:
                    print('按下下键,坦克向下移动')
class Tank():
    def __init__(self):
        pass
    #射击
    def shot(self):
        pass
    #展示坦克的方法
    def displayTank(self):
        pass
#我方坦克
class MyTank(Tank):
    def __init__(self):
        pass

#敌方坦克
class EnemyTank(Tank):
    def __init__(self):
        pass

#子弹类
class Bullet():
    def __init__(self):
        pass
    #移动
    def move(self):
        pass
    #展示子弹的方法
    def displayBullet(self):
        pass
class Wall():
    def __init__(self):
        pass
    #展示墙壁的方法
    def displayWall(self):
        pass
class Explode():
    def __init__(self):
        pass
    #展示爆炸效果的方法
    def displayExplode(self):
        pass
class Music():
    def __init__(self):
        pass
    #播放音乐的方法
    def play(self):
        pass
if __name__=='__main__':
    #MainGame().startGame()
    #MainGame().getTextSurface()

老师看一帮我看看哪里有问题吗,运行结果是

C:\Users\Lenovo\Anaconda3\python.exe D:/gui/tank01.py

  File "D:/gui/tank01.py", line 155

    


Python 全系列/第二阶段:Python 深入与提高/游戏开发-坦克大战 24150楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637