diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d77905c..7d47cb0 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -14,9 +14,7 @@ jobs: - name: install dependencies shell: bash run: | - pip install PyYAML==5.1.2 - pip install mkdocs==0.16.3 - python setup.py install + pip install mkdocs==1.4.2 python-markdown-math==0.8 - name: build site shell: bash run: mkdocs build --clean diff --git a/README.md b/README.md index 313f5fe..4c87638 100644 --- a/README.md +++ b/README.md @@ -61,11 +61,10 @@ learnopengl.com系列教程的中文翻译,目前正在校对及翻译中。 ## 构建 -首先请安装Python,2和3都可以,之后初始化环境: +首先请安装Python 3.7+,之后初始化环境: ```bash -$ pip install mkdocs -$ python setup.py install +$ pip install mkdocs==1.4.2 python-markdown-math==0.8 ``` 初始化以后,每次构建只需要输入以下指令即可,构建后的文件在`site`文件夹内: diff --git a/docs/06 In Practice/2D-Game/05 Collisions/01 Ball.md b/docs/06 In Practice/2D-Game/05 Collisions/01 Ball.md index 2b768ae..5a319fe 100644 --- a/docs/06 In Practice/2D-Game/05 Collisions/01 Ball.md +++ b/docs/06 In Practice/2D-Game/05 Collisions/01 Ball.md @@ -20,17 +20,17 @@ class BallObject : public GameObject { public: - // 球的状态 + // 球的状态 GLfloat Radius; GLboolean Stuck; - + BallObject(); BallObject(glm::vec2 pos, GLfloat radius, glm::vec2 velocity, Texture2D sprite); glm::vec2 Move(GLfloat dt, GLuint window_width); void Reset(glm::vec2 position, glm::vec2 velocity); -}; +}; ``` BallObject的构造函数不但初始化了其自身的值,而且实际上也潜在地初始化了GameObjectBallObject类拥有一个Move函数,该函数用于根据球的速度来移动球,并检查它是否碰到了场景的任何边界,如果碰到的话就会反转球的速度: @@ -41,7 +41,7 @@ glm::vec2 BallObject::Move(GLfloat dt, GLuint window_width) { // 如果没有被固定在挡板上 if (!this->Stuck) - { + { // 移动球 this->Position += this->Velocity * dt; // 检查是否在窗口边界以外,如果是的话反转速度并恢复到正确的位置 @@ -60,10 +60,10 @@ glm::vec2 BallObject::Move(GLfloat dt, GLuint window_width) this->Velocity.y = -this->Velocity.y; this->Position.y = 0.0f; } - + } return this->Position; -} +} ``` 除了反转球的速度之外,我们还需要把球沿着边界重新放置回来。只有在没有被固定时球才能够移动。 @@ -77,16 +77,16 @@ glm::vec2 BallObject::Move(GLfloat dt, GLuint window_width) - BallObject: [header](https://learnopengl.com/code_viewer.php?code=in-practice/breakout/ball_object_collisions.h), [code](https://learnopengl.com/code_viewer.php?code=in-practice/breakout/ball_object_collisions) -首先我们在游戏中添加球。与玩家挡板相似,我们创建一个球对象并且定义两个用来初始化球的常量。对于球的纹理,我们会使用在LearnOpenGL Breakout游戏中完美适用的一张图片:[球纹理](../../../../img/06/Breakout/05/01/awesomeface.png)。 +首先我们在游戏中添加球。与玩家挡板相似,我们创建一个球对象并且定义两个用来初始化球的常量。对于球的纹理,我们会使用在LearnOpenGL Breakout游戏中完美适用的一张图片:[球纹理](../../../img/06/Breakout/05/01/awesomeface.png)。 ```c++ // 初始化球的速度 const glm::vec2 INITIAL_BALL_VELOCITY(100.0f, -350.0f); // 球的半径 const GLfloat BALL_RADIUS = 12.5f; - -BallObject *Ball; - + +BallObject *Ball; + void Game::Init() { [...] @@ -101,7 +101,7 @@ void Game::Init() void Game::Update(GLfloat dt) { Ball->Move(dt, this->Width); -} +} ``` 除此之外,由于球初始是固定在挡板上的,我们必须让玩家能够从固定的位置重新移动它。我们选择使用空格键来从挡板释放球。这意味着我们必须稍微修改ProcessInput函数: @@ -149,7 +149,7 @@ void Game::Render() [...] Ball->Draw(*Renderer); } -} +} ``` 结果就是球会跟随着挡板,并且当我们按下空格键时球开始自由运动。球会在左侧、右侧和顶部边界合理地反弹,但看起来不会撞击任何的砖块,就像我们可以在下边的视频中看到的那样: diff --git a/docs/08 Effects/01 Fog.md b/docs/08 Effects/01 Fog.md deleted file mode 100644 index b61d28c..0000000 --- a/docs/08 Effects/01 Fog.md +++ /dev/null @@ -1,7 +0,0 @@ -# 雾 - -**未完成** - -这篇教程暂时还没有完成,您可以经常来刷新看看是否有更新的进展。 - - \ No newline at end of file diff --git a/docs/08 Effects/02 Toon shading.md b/docs/08 Effects/02 Toon shading.md deleted file mode 100644 index b479dd6..0000000 --- a/docs/08 Effects/02 Toon shading.md +++ /dev/null @@ -1,7 +0,0 @@ -# 卡通着色 - -**未完成** - -这篇教程暂时还没有完成,您可以经常来刷新看看是否有更新的进展。 - - \ No newline at end of file diff --git a/mdx_math.py b/mdx_math.py deleted file mode 100644 index 3568608..0000000 --- a/mdx_math.py +++ /dev/null @@ -1,64 +0,0 @@ -# -*- coding: utf-8 -*- - -''' -Math extension for Python-Markdown -================================== - -Adds support for displaying math formulas using [MathJax](http://www.mathjax.org/). - -Author: 2015, Dmitry Shachnev . -''' - -import markdown - -class MathExtension(markdown.extensions.Extension): - def __init__(self, *args, **kwargs): - self.config = { - 'enable_dollar_delimiter': [False, 'Enable single-dollar delimiter'], - 'render_to_span': [False, - 'Render to span elements rather than script for fallback'], - } - super(MathExtension, self).__init__(*args, **kwargs) - - def extendMarkdown(self, md, md_globals): - def handle_match_inline(m): - if self.getConfig('render_to_span'): - node = markdown.util.etree.Element('span') - node.set('class', 'tex') - node.text = ("\\\\(" + markdown.util.AtomicString(m.group(3)) + - "\\\\)") - else: - node = markdown.util.etree.Element('script') - node.set('type', 'math/tex') - node.text = markdown.util.AtomicString(m.group(3)) - return node - - def handle_match(m): - node = markdown.util.etree.Element('script') - node.set('type', 'math/tex; mode=display') - if '\\begin' in m.group(2): - node.text = markdown.util.AtomicString(m.group(2) + m.group(4) + m.group(5)) - else: - node.text = markdown.util.AtomicString(m.group(3)) - return node - - inlinemathpatterns = ( - markdown.inlinepatterns.Pattern(r'(? -{% for filename in meta.source %} +{% for filename in page.meta.source %} {{ filename }} {% endfor %} {% endif %} -{{ content }} +{{ page.content }}
- {%- for path in extra_javascript %} diff --git a/yeti/nav-sub.html b/yeti/nav-sub.html index c3549df..795f214 100644 --- a/yeti/nav-sub.html +++ b/yeti/nav-sub.html @@ -1,6 +1,6 @@ {% if not nav_item.children %}
  • - {{ nav_item.title }} + {{ nav_item.title }}
  • {% else %} {% else %}
  • - {{ nav_item.title }} + {{ nav_item.title }}
  • {% endif %} {% endfor %} @@ -44,25 +44,25 @@ 搜索 -
  • -
  • -
  • -
  • - {% if repo_url %} + {% if config.repo_url %}
  • - - {% if repo_name == 'GitHub' %} + + {% if config.repo_name == 'GitHub' %} - {% elif repo_name == 'Bitbucket' %} + {% elif config.repo_name == 'Bitbucket' %} {% endif %} - {{ repo_name }} + {{ config.repo_name }}
  • {% endif %} diff --git a/yeti/toc.html b/yeti/toc.html index bb8fdcd..44c6272 100644 --- a/yeti/toc.html +++ b/yeti/toc.html @@ -1,9 +1,9 @@