From c2714b591c89c4c4d4e60f784d9cadeb7801f14c Mon Sep 17 00:00:00 2001
From: Gabriel-Araujo12 <85949953+Gabriel-Araujo12@users.noreply.github.com>
Date: Sat, 9 Oct 2021 20:13:02 -0300
Subject: [PATCH 01/81] Update pt_BR curriculum.po
---
docs/locale/pt_BR/LC_MESSAGES/curriculum.po | 40 ++++++++++-----------
1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/docs/locale/pt_BR/LC_MESSAGES/curriculum.po b/docs/locale/pt_BR/LC_MESSAGES/curriculum.po
index c7ab7a9c..585e777e 100644
--- a/docs/locale/pt_BR/LC_MESSAGES/curriculum.po
+++ b/docs/locale/pt_BR/LC_MESSAGES/curriculum.po
@@ -9,7 +9,7 @@ msgstr ""
"Project-Id-Version: Free Python Games 2.3.2\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-08-24 21:25-0300\n"
-"PO-Revision-Date: 2021-10-09 12:12-0300\n"
+"PO-Revision-Date: 2021-10-09 20:11-0300\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
@@ -105,7 +105,7 @@ msgstr "Jogos"
#: ../../curriculum.rst:32
msgid ":doc:`guess`.py - Guess number within range."
-msgstr ""
+msgstr ":doc:`guess`.py - Adivinhar um número dentro de um intervalo."
#: ../../curriculum.rst:34
msgid "Explain: from random import randint"
@@ -149,7 +149,7 @@ msgstr "Discuta o método de adivinhação. Isso é um algoritmo!"
#: ../../curriculum.rst:45
msgid ":doc:`snake`.py - Classic arcade game."
-msgstr ""
+msgstr ":doc:`snake`.py - Jogo clássico de arcade."
#: ../../curriculum.rst:48 ../../curriculum.rst:97 ../../curriculum.rst:139
#: ../../curriculum.rst:166 ../../curriculum.rst:191
@@ -210,7 +210,7 @@ msgstr "Módulos: turtle"
#: ../../curriculum.rst:72
msgid ":doc:`crypto`.py - Encrypt, decrypt and decode messages."
-msgstr ""
+msgstr ":doc:`crypto`.py - Criptografar, descriptografar e decodificar mensagens."
#: ../../curriculum.rst:74
msgid "ord function and chr function"
@@ -218,7 +218,7 @@ msgstr "função ord e função chr"
#: ../../curriculum.rst:75
msgid "modulo operator"
-msgstr "operador de módulo"
+msgstr "módulo operador"
#: ../../curriculum.rst:76
msgid "Write decode function"
@@ -230,7 +230,7 @@ msgstr "Criptografar números"
#: ../../curriculum.rst:79
msgid ":doc:`paint`.py - Draw shapes."
-msgstr ""
+msgstr ":doc:`paint`.py - Desenhe formas."
#: ../../curriculum.rst:81
msgid "Draw line"
@@ -285,7 +285,7 @@ msgstr "Escrever função polígono(lados, comprimento)"
#: ../../curriculum.rst:94
msgid ":doc:`flappy`.py - Flappy Bird inspired game."
-msgstr ""
+msgstr ":doc:`flappy`.py - Jogo inspirado em Flappy Bird."
#: ../../curriculum.rst:99
msgid "Genesis 6:5-22 - God the Engineer (Noah)"
@@ -325,7 +325,7 @@ msgstr "Funções: onscreenclick, onkey, ontimer"
#: ../../curriculum.rst:117
msgid ":doc:`bagels`.py - Digit guessing puzzle."
-msgstr ""
+msgstr ":doc:`bagels`.py - Quebra-cabeça de adivinhação de dígitos."
#: ../../curriculum.rst:118
msgid "Animation"
@@ -353,7 +353,7 @@ msgstr "hideturtle(); marcador(False); polígono(4, 200); atualização()"
#: ../../curriculum.rst:126
msgid ":doc:`tictactoe`.py - Tic-tac-toe."
-msgstr ""
+msgstr ":doc:`tictactoe`.py - Jogo da velha."
#: ../../curriculum.rst:128
msgid "line(...)"
@@ -381,11 +381,11 @@ msgstr "onscreenclick(goto)"
#: ../../curriculum.rst:135
msgid ":doc:`simonsays`.py - Simon Says"
-msgstr ""
+msgstr ":doc:`simonsays`.py - Simon Says"
#: ../../curriculum.rst:136
msgid ":doc:`cannon`.py - Hitting targets with projectiles."
-msgstr ""
+msgstr ":doc:`cannon`.py - Atingir alvos com projéteis."
#: ../../curriculum.rst:141
msgid "Mark 1:1-18 - God the Programmer (\"fishers of people\")"
@@ -397,7 +397,7 @@ msgstr "O que Isaías disse que aconteceria?"
#: ../../curriculum.rst:144
msgid "What did John the Baptist say would happen?"
-msgstr "What did John the Baptist say would happen?"
+msgstr "O que João Batista disse que aconteceria?"
#: ../../curriculum.rst:145
msgid "What did God say about Jesus? When?"
@@ -425,23 +425,23 @@ msgstr "Tipos de dados: list, dict, vector"
#: ../../curriculum.rst:159
msgid ":doc:`bounce`.py - Simple animation demo."
-msgstr ""
+msgstr ":doc:`bounce`.py - Demonstração de animação simples."
#: ../../curriculum.rst:160
msgid ":doc:`pong`.py - Classic arcade game."
-msgstr ""
+msgstr ":doc:`pong`.py - Jogo clássico de arcade."
#: ../../curriculum.rst:161
msgid ":doc:`ant`.py - Simple animation demo."
-msgstr ""
+msgstr ":doc:`ant`.py - Demonstração de animação simples."
#: ../../curriculum.rst:162
msgid ":doc:`tron`.py - Classic arcade game."
-msgstr ""
+msgstr ":doc:`tron`.py - Jogo clássico de arcade."
#: ../../curriculum.rst:163
msgid ":doc:`tiles`.py - Puzzle game of number shuffling."
-msgstr ""
+msgstr ":doc:`tiles`.py - Jogo de quebra-cabeça de embaralhamento de números."
#: ../../curriculum.rst:168
msgid "John 9:1-33 - God the Debugger (Blind Man and Jesus)"
@@ -481,15 +481,15 @@ msgstr "Resposta: O que vem a seguir?"
#: ../../curriculum.rst:186
msgid ":doc:`connect`.py - Connect Four"
-msgstr ""
+msgstr ":doc:`connect`.py - Conecte quatro"
#: ../../curriculum.rst:187
msgid ":doc:`memory`.py - Puzzle game of number pairs."
-msgstr ""
+msgstr ":doc:`memory`.py - Jogo de quebra-cabeça de pares de números."
#: ../../curriculum.rst:188
msgid ":doc:`pacman`.py - Classic arcade game."
-msgstr ""
+msgstr ":doc:`pacman`.py - Jogo clássico de arcade."
#: ../../curriculum.rst:193
msgid "Revelation 21 - God the Restorer (New Heaven and New Earth)"
From c0ce2420a69409e7ce58da5306edba7a21095a9d Mon Sep 17 00:00:00 2001
From: Pedro-Henriquebg7 <85884290+Pedro-Henriquebg7@users.noreply.github.com>
Date: Mon, 11 Oct 2021 16:17:09 -0300
Subject: [PATCH 02/81] Update index.po
---
docs/locale/pt_BR/LC_MESSAGES/index.po | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/locale/pt_BR/LC_MESSAGES/index.po b/docs/locale/pt_BR/LC_MESSAGES/index.po
index b431ba6a..ff32650c 100644
--- a/docs/locale/pt_BR/LC_MESSAGES/index.po
+++ b/docs/locale/pt_BR/LC_MESSAGES/index.po
@@ -20,7 +20,7 @@ msgstr ""
#: ../../../README.rst:2
msgid "Free Python Games"
-msgstr ""
+msgstr "Free Python Games"
#: ../../../README.rst:4
msgid ""
From 0ac169d7d6650d7959e0e87a2057175c6b32b82f Mon Sep 17 00:00:00 2001
From: Pedro-Henriquebg7 <85884290+Pedro-Henriquebg7@users.noreply.github.com>
Date: Mon, 11 Oct 2021 16:38:26 -0300
Subject: [PATCH 03/81] Update index.po
---
docs/locale/pt_BR/LC_MESSAGES/index.po | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/docs/locale/pt_BR/LC_MESSAGES/index.po b/docs/locale/pt_BR/LC_MESSAGES/index.po
index ff32650c..cfa4b609 100644
--- a/docs/locale/pt_BR/LC_MESSAGES/index.po
+++ b/docs/locale/pt_BR/LC_MESSAGES/index.po
@@ -29,6 +29,11 @@ msgid ""
"Python code and designed for experimentation and changes. Simplified "
"versions of several classic arcade games are included."
msgstr ""
+"`Free Python Games`_ é uma coleção de jogos gratuita feita em Python "
+"destinados à educação e à diversão licenciada com Apache2. Os jogos "
+"são escritos em códigos simples de Python e projetados para experimentação "
+"e mudanças. Estão inclusas versões simplificadas de vários jogos de arcade "
+"clássicos."
#: ../../../README.rst:9
msgid ""
From ef51958241858a2a4fae2ff485a17ec1781d05fc Mon Sep 17 00:00:00 2001
From: Pedro-Henriquebg7 <85884290+Pedro-Henriquebg7@users.noreply.github.com>
Date: Tue, 12 Oct 2021 14:08:03 -0300
Subject: [PATCH 04/81] Update index.po-introduction
---
docs/locale/pt_BR/LC_MESSAGES/index.po | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/docs/locale/pt_BR/LC_MESSAGES/index.po b/docs/locale/pt_BR/LC_MESSAGES/index.po
index cfa4b609..38a43499 100644
--- a/docs/locale/pt_BR/LC_MESSAGES/index.po
+++ b/docs/locale/pt_BR/LC_MESSAGES/index.po
@@ -46,6 +46,14 @@ msgid ""
" by Wally Feurzig and Seymour Papert in 1966. All of the games in `Free "
"Python Games`_ are implemented using Python and its Turtle module."
msgstr ""
+"Python é uma das cinco linguagens de programação mais populares do mundo "
+"e está disponível gratuitamente em `Python.org. "
+"`_. Python inclui uma ampla biblioteca "
+" padrão distribuída com sua instalação. A biblioteca padrão tem um módulo "
+"chamado Turtle, que é uma forma popular de apresentar programação às crianças. "
+"Turtle fazia parte da linguagem de programação Logo original, desenvolvida"
+" por Wally Feurzig e Seymor Papert em 1966. Todos os jogos em `Free "
+"Python Games`_ são implementados usando Python e seu módulo Turtle."
#: ../../../README.rst:17
msgid ""
@@ -54,6 +62,10 @@ msgid ""
"much as it was to learn. Since then the games have been improved and used"
" in a variety of settings ranging from classrooms to summer day-camps."
msgstr ""
+"A partir de 2012, `Free Python Games`_ começou como um programa pós-escola "
+"para ensinar programação aos jovens do centro da cidade. O objetivo era "
+"se divertir tanto quanto aprender. Desde então, os jogos foram melhorados e usados"
+" em uma variedade de ambientes que vão de salas de aulas a acampamentos de verão."
#: ../../../README.rst:22
msgid ""
@@ -63,6 +75,11 @@ msgid ""
"grades 6th-12th have enjoyed learning about topics such as encryption and"
" projectile motion through games."
msgstr ""
+"Os jogos são executados em qualquer lugar que o Python possa ser instalado, "
+"o que inclui computadores desktop com Windows, Mac OS ou Linux e hardware "
+"mais “velhos” e de baixa potência, como Raspberry Pi. Crianças nos Estados Unidos, "
+"da 6ª à 12ª série, gostaram de aprender tópicos sobre criptografia e movimento de"
+" projétil através dos jogos."
#: ../../../README.rst:27
msgid ""
@@ -72,6 +89,11 @@ msgid ""
" a new feature or behavior! You never know which games students will "
"engage with best."
msgstr ""
+"Cada jogo é inteiramente independente dos outros e inclui comentários "
+"com uma lista de exercícios para trabalhar com os estudantes. Criatividade "
+"e flexibilidade são importantes. Não há forma certa ou errada de implementar"
+" uma nova característica ou comportamento! Você nunca sabe com quais jogos os "
+"estudantes se engajarão melhor."
#: ../../../README.rst:36
msgid "Testimonials"
From 39b3e9ead1025f4d34ad9d15877db54f3f57a6bc Mon Sep 17 00:00:00 2001
From: Pedro-Henriquebg7 <85884290+Pedro-Henriquebg7@users.noreply.github.com>
Date: Tue, 12 Oct 2021 15:28:22 -0300
Subject: [PATCH 05/81] Update index.po-testimonials
---
docs/locale/pt_BR/LC_MESSAGES/index.po | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/docs/locale/pt_BR/LC_MESSAGES/index.po b/docs/locale/pt_BR/LC_MESSAGES/index.po
index 38a43499..2c0eab40 100644
--- a/docs/locale/pt_BR/LC_MESSAGES/index.po
+++ b/docs/locale/pt_BR/LC_MESSAGES/index.po
@@ -97,17 +97,19 @@ msgstr ""
#: ../../../README.rst:36
msgid "Testimonials"
-msgstr ""
+msgstr "Relatos"
#: ../../../README.rst:38
msgid ""
"*\"I love Free Python Games because the games are fun and they're easy to"
" understand and change. I like making my own games now.\"*"
msgstr ""
+"*\"Eu amo Free Python Games porque os jogos são divertidos e eles são fáceis"
+" de entender e mudar. Eu gosto de fazer meus próprios jogos agora. \"*"
#: ../../../README.rst:41
msgid "-- Luke Martin, Student"
-msgstr ""
+msgstr "-- Luke Martin, estudante"
#: ../../../README.rst:43
msgid ""
@@ -115,40 +117,49 @@ msgid ""
"Thank you so much for exposing him to coding. He is having so much "
"fun!\"*"
msgstr ""
+"*\"Free Python Games inspirou e introduziu um novo passatempo para o "
+"nosso filho. Muito obrigada por apresentar ele à programação. Ele está "
+se divertindo bastante!\"*"
#: ../../../README.rst:46
msgid "-- Mary Lai, Parent"
-msgstr ""
+msgstr "-- Mary Lai, mãe"
#: ../../../README.rst:48
msgid ""
"*\"Free Python Games are great because they really engage students and "
"let them learn at their own pace.\"*"
msgstr ""
+"*\"Free Python Games é ótimo por envolver os alunos e permitir que "
+"aprendam em seu próprio ritmo.\"*"
#: ../../../README.rst:51
msgid "-- Rick Schertle, Teacher, Steindorf STEAM School"
-msgstr ""
+msgstr "-- Rick Schertle, professor da Steindorf STEAM School"
#: ../../../README.rst:53
msgid ""
"*\"Free Python Games combines play and learning in a flexible environment"
" that reduces the stress of a difficult topic like programming.\"*"
msgstr ""
+"*\"Free Python Games combina brincadeira e aprendizagem em um ambiente flexível"
+" que reduz o estresse de um tópico difícil como a programação.\"*"
#: ../../../README.rst:56
msgid "-- Brett Bymaster, Youth Pastor, The River Church Community"
-msgstr ""
+msgstr "-- Brett Bymaster, Pastor de jovens, Comunidade da The River Church"
#: ../../../README.rst:58
msgid ""
"*\"Free Python Games is great for students, is highly organized and "
"flexible, and seeks to unleash inquiry and understanding.\"*"
msgstr ""
+"*\"Free Python Games é ótimo para estudantes, é altamente organizado e "
+"flexível e procura liberar a investigação e a compreensão.\"*"
#: ../../../README.rst:61
msgid "-- Terri Furton, Principal, Downtown College Prep"
-msgstr ""
+msgstr "-- Terri Furton, Diretor da Downton College Prep"
#: ../../../README.rst:65
msgid "Features"
From 379c3733e3189eba98249e231d4dd343d6c4f03d Mon Sep 17 00:00:00 2001
From: Pedro-Henriquebg7 <85884290+Pedro-Henriquebg7@users.noreply.github.com>
Date: Tue, 12 Oct 2021 15:43:51 -0300
Subject: [PATCH 06/81] Update index.po-Features
---
docs/locale/pt_BR/LC_MESSAGES/index.po | 28 +++++++++++++-------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/docs/locale/pt_BR/LC_MESSAGES/index.po b/docs/locale/pt_BR/LC_MESSAGES/index.po
index 2c0eab40..41337305 100644
--- a/docs/locale/pt_BR/LC_MESSAGES/index.po
+++ b/docs/locale/pt_BR/LC_MESSAGES/index.po
@@ -119,7 +119,7 @@ msgid ""
msgstr ""
"*\"Free Python Games inspirou e introduziu um novo passatempo para o "
"nosso filho. Muito obrigada por apresentar ele à programação. Ele está "
-se divertindo bastante!\"*"
+"se divertindo bastante!\"*"
#: ../../../README.rst:46
msgid "-- Mary Lai, Parent"
@@ -163,55 +163,55 @@ msgstr "-- Terri Furton, Diretor da Downton College Prep"
#: ../../../README.rst:65
msgid "Features"
-msgstr ""
+msgstr "Características"
#: ../../../README.rst:67
msgid "Fun to play!"
-msgstr ""
+msgstr "Divertido de jogar"
#: ../../../README.rst:68
msgid "Simple Python code"
-msgstr ""
+msgstr "Código de Python simples"
#: ../../../README.rst:69
msgid "Easy to install"
-msgstr ""
+msgstr "Fácil de instalar"
#: ../../../README.rst:70
msgid "Designed for education"
-msgstr ""
+msgstr "Projetado para educação"
#: ../../../README.rst:71
msgid "Depends only on the Python Standard Library"
-msgstr ""
+msgstr "Depende apenas da biblioteca padrão de Python"
#: ../../../README.rst:72
msgid "Used in hundreds of hours of classroom instruction"
-msgstr ""
+msgstr "Usado em centenas de horas de instrução em sala de aula"
#: ../../../README.rst:73
msgid "Fully Documented"
-msgstr ""
+msgstr "Completamente documentado"
#: ../../../README.rst:74
msgid "100% Test Coverage"
-msgstr ""
+msgstr "100% de cobertura de teste"
#: ../../../README.rst:75
msgid "Developed on Python 3.7"
-msgstr ""
+msgstr "Desenvolvido em Python 3.7"
#: ../../../README.rst:76
msgid "Tested on CPython 2.7, 3.4, 3.5, 3.6, and 3.7"
-msgstr ""
+msgstr "Testado em CPython 2.7, 3.4, 3.5, 3.6 e 3.7"
#: ../../../README.rst:77
msgid "Tested on Windows, Mac OS X, Raspbian (Raspberry Pi), and Linux"
-msgstr ""
+msgstr "Testado em Windows, Mac OS X, Raspbian (Raspberry Pi) e Linux"
#: ../../../README.rst:78
msgid "Tested using Travis CI and AppVeyor CI"
-msgstr ""
+msgstr "Testado usando Travis CI and AppVeyor CI"
#: ../../../README.rst:88
msgid "Quickstart"
From 6f24a789df2ee157bf952ad6e1454c795c99bb60 Mon Sep 17 00:00:00 2001
From: Gabriel-Araujo12 <85949953+Gabriel-Araujo12@users.noreply.github.com>
Date: Tue, 12 Oct 2021 17:13:21 -0300
Subject: [PATCH 07/81] Update pt_BR development.po
---
docs/locale/pt_BR/LC_MESSAGES/development.po | 99 ++++++++++++--------
1 file changed, 62 insertions(+), 37 deletions(-)
diff --git a/docs/locale/pt_BR/LC_MESSAGES/development.po b/docs/locale/pt_BR/LC_MESSAGES/development.po
index 2dd074d9..b166218b 100644
--- a/docs/locale/pt_BR/LC_MESSAGES/development.po
+++ b/docs/locale/pt_BR/LC_MESSAGES/development.po
@@ -4,162 +4,187 @@
# package.
# FIRST AUTHOR , 2021.
#
-#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Free Python Games 2.3.2\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-08-24 21:25-0300\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME \n"
-"Language-Team: LANGUAGE \n"
+"PO-Revision-Date: 2021-10-12 14:17-0300\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.9.1\n"
+"Last-Translator: \n"
+"Language-Team: \n"
+"Language: pt_BR\n"
+"X-Generator: Poedit 3.0\n"
#: ../../development.rst:2
msgid "Free Python Games Development"
-msgstr ""
+msgstr "Desenvolvimento de Free Python Games"
#: ../../development.rst:4
msgid ""
":doc:`Free Python Games ` development is lead by Grant Jenks "
"."
msgstr ""
+":doc:O desenvolvimento de `Free Python Games ` é liderado por Grant "
+"Jenks ."
#: ../../development.rst:8
msgid "Collaborators Welcome"
-msgstr ""
+msgstr "Colaboradores são bem-vindos"
#: ../../development.rst:10
msgid "Search issues or open a new issue to start a discussion around a bug."
msgstr ""
+"Pesquise issues ou abra uma nova issue para iniciar uma discussão sobre um "
+"bug."
#: ../../development.rst:11
msgid "Fork the `GitHub repository`_ and make your changes in a new branch."
msgstr ""
+"Faça um fork do `repositório no GitHub`_ e faça suas alterações em um novo "
+"branch."
#: ../../development.rst:12
msgid "Write a test which shows the bug was fixed."
-msgstr ""
+msgstr "Escreva um teste que mostre que o bug foi corrigido."
#: ../../development.rst:13
msgid ""
-"Send a pull request and message the development lead until its merged and"
-" published."
+"Send a pull request and message the development lead until its merged and "
+"published."
msgstr ""
+"Envie um pull request e uma mensagem ao líder de desenvolvimento até que "
+"seja mesclado e publicado."
#: ../../development.rst:19
msgid "Requests for Contributions"
-msgstr ""
+msgstr "Pedidos de contribuições"
#: ../../development.rst:21
msgid "Simplifications to existing games."
-msgstr ""
+msgstr "Simplificações de jogos existentes."
#: ../../development.rst:22
msgid "Refactoring to simplify games."
-msgstr ""
+msgstr "Refatoração para simplificar os jogos."
#: ../../development.rst:23
msgid "Improved documentation."
-msgstr ""
+msgstr "Melhoria da documentação."
#: ../../development.rst:24
msgid "Additional games. Requirements for new games:"
-msgstr ""
+msgstr "Jogos adicionais. Requisitos para novos jogos:"
#: ../../development.rst:26
msgid "Fun to play."
-msgstr ""
+msgstr "Divertido de jogar."
#: ../../development.rst:27
msgid "Matching code style."
-msgstr ""
+msgstr "Estilo de código correspondente."
#: ../../development.rst:28
msgid "Limited Python feature set."
-msgstr ""
+msgstr "Conjunto limitado de recursos do Python."
#: ../../development.rst:29
msgid "Short (less than 100 lines of code)."
-msgstr ""
+msgstr "Curto (menos de 100 linhas de código)."
#: ../../development.rst:32
msgid "Get the Code"
-msgstr ""
+msgstr "Obtenha o código"
#: ../../development.rst:34
msgid ""
":doc:`Free Python Games ` is actively developed in a `GitHub "
"repository`_."
msgstr ""
+":doc:`Free Python Games ` é desenvolvido ativamente em um "
+"`repositório no GitHub`_."
#: ../../development.rst:37
msgid "You can either clone the public repository::"
-msgstr ""
+msgstr "Você pode clonar o repositório público::"
#: ../../development.rst:41
msgid ""
-"Download the `tarball `_::"
+"Download the `tarball `_::"
msgstr ""
+"Baixe o `tarball `_::"
#: ../../development.rst:45
msgid ""
-"Or, download the `zipball `_::"
+"Or, download the `zipball `_::"
msgstr ""
+"Ou, faça o download do `zipball `_::"
#: ../../development.rst:50
msgid "Installing Dependencies"
-msgstr ""
+msgstr "Instalação de dependências"
#: ../../development.rst:52
msgid ""
-"Install development dependencies with `pip `_::"
+"Install development dependencies with `pip `_::"
msgstr ""
+"Instale as dependências de desenvolvimento com `pip `_::"
#: ../../development.rst:56
msgid ""
"All packages for running tests and building documentation will be "
"installed."
msgstr ""
+"Todos os pacotes para a execução de testes e documentação de construção "
+"serão instalados."
#: ../../development.rst:59
msgid "Testing"
-msgstr ""
+msgstr "Testando"
#: ../../development.rst:61
msgid ""
-":doc:`Free Python Games ` currently tests against three versions "
-"of Python:"
+":doc:`Free Python Games ` currently tests against three versions of "
+"Python:"
msgstr ""
+":doc:`Free Python Games ` é atualmente testado em três versões do "
+"Python:"
#: ../../development.rst:64
msgid "CPython 3.4"
-msgstr ""
+msgstr "CPython 3.4"
#: ../../development.rst:65
msgid "CPython 3.5"
-msgstr ""
+msgstr "CPython 3.5"
#: ../../development.rst:66
msgid "CPython 3.6"
-msgstr ""
+msgstr "CPython 3.6"
#: ../../development.rst:68
msgid ""
-"Testing uses `tox `_. If you don't want"
-" to install all the development requirements, then, after downloading, "
-"you can simply run::"
+"Testing uses `tox `_. If you don't want "
+"to install all the development requirements, then, after downloading, you "
+"can simply run::"
msgstr ""
+"Os testes usam `tox `_. Se você não "
+"deseja instalar todos os requisitos de desenvolvimento, então, após o "
+"download, você pode simplesmente executar::"
#: ../../development.rst:74
msgid ""
"The test argument to setup.py will download a minimal testing "
"infrastructure and run the tests."
msgstr ""
-
+"O argumento de teste para setup.py irá baixar uma infraestrutura mínima de "
+"testes e executar os testes."
From 99ca5a6cf11e37a5512a91321dae0b5571517460 Mon Sep 17 00:00:00 2001
From: Pedro-Henriquebg7 <85884290+Pedro-Henriquebg7@users.noreply.github.com>
Date: Tue, 12 Oct 2021 17:28:24 -0300
Subject: [PATCH 08/81] Update index.po-Quickstart
---
docs/locale/pt_BR/LC_MESSAGES/index.po | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/docs/locale/pt_BR/LC_MESSAGES/index.po b/docs/locale/pt_BR/LC_MESSAGES/index.po
index 41337305..4e3e67b6 100644
--- a/docs/locale/pt_BR/LC_MESSAGES/index.po
+++ b/docs/locale/pt_BR/LC_MESSAGES/index.po
@@ -215,25 +215,31 @@ msgstr "Testado usando Travis CI and AppVeyor CI"
#: ../../../README.rst:88
msgid "Quickstart"
-msgstr ""
+msgstr "Começo rápido"
#: ../../../README.rst:90
msgid ""
"Installing Free Python Games is simple with `pip "
"`_::"
msgstr ""
+"Instalar o Free Python Games é simples com `pip:"
+"`_::"
#: ../../../README.rst:95
msgid ""
"Free Python Games supports a command-line interface (CLI). Help for the "
"CLI is available using::"
msgstr ""
+"Free Python Games oferece suporte a uma interface de linha de comandos "
+"(CLI - Command Line Interface). A ajuda para a CLI está disponível usando::"
#: ../../../README.rst:100
msgid ""
"The CLI supports three commands: list, copy, and show. For a list of all "
"games run::"
msgstr ""
+"A CLI suporta três comandos: list, copy e show. Para obter uma lista "
+"de todos os jogos, execute::"
#: ../../../README.rst:105
msgid ""
@@ -241,6 +247,9 @@ msgid ""
" the command-line. To reference the Python module, combine \"freegames\" "
"with the name of the game. For example, to play the \"snake\" game run::"
msgstr ""
+"Qualquer um dos jogos listados pode ser jogado executando-se o módulo"
+" Python na linha de comando. Para fazer referência ao módulo Python, "
+"combine \"freegames\" com o nome do jogo. Por exemplo, para jogar o jogo \"snake\" execute::"
#: ../../../README.rst:111
msgid ""
@@ -248,6 +257,9 @@ msgid ""
" create a Python file in your local directory which you can edit. For "
"example, to copy and play the \"snake\" game run::"
msgstr ""
+"Os jogos podem ser modificados copiando-se seu código fonte. O comando copy"
+" criará um arquivo Python, em seu diretório local, que você pode editar. "
+"Por exemplo, para copiar e jogar o jogo \"snake\" execute::"
#: ../../../README.rst:118
msgid ""
@@ -255,12 +267,17 @@ msgid ""
"Python code. To launch the editor and make changes to the \"snake\" game "
"run::"
msgstr ""
+"Python inclui um editor de texto integrado chamado IDLE, que também pode executar "
+"código Python. Para iniciar o editor e fazer alterações no jogo \"snake\" execute::"
#: ../../../README.rst:123
msgid ""
"You can also access documentation in the interpreter with Python's built-"
"in help function::"
msgstr ""
+"Você também pode acessar a documentação no interpretador com a função "
+"embutida no Python help::"
+
#: ../../../README.rst:131
msgid "Free Games"
From 8cb1d0903af8135258fee719fe2664b3c9f59c4e Mon Sep 17 00:00:00 2001
From: Pedro-Henriquebg7 <85884290+Pedro-Henriquebg7@users.noreply.github.com>
Date: Tue, 12 Oct 2021 17:32:28 -0300
Subject: [PATCH 09/81] Update index.po-Free Games
---
docs/locale/pt_BR/LC_MESSAGES/index.po | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/locale/pt_BR/LC_MESSAGES/index.po b/docs/locale/pt_BR/LC_MESSAGES/index.po
index 4e3e67b6..e41fe7b8 100644
--- a/docs/locale/pt_BR/LC_MESSAGES/index.po
+++ b/docs/locale/pt_BR/LC_MESSAGES/index.po
@@ -281,7 +281,7 @@ msgstr ""
#: ../../../README.rst:131
msgid "Free Games"
-msgstr ""
+msgstr "Jogos Livres"
#: ../../../README.rst:134
msgid "Paint"
From 4cd9b9295051db0ab3ed0db1b735d62aedffd5ac Mon Sep 17 00:00:00 2001
From: Gabriel-Araujo12 <85949953+Gabriel-Araujo12@users.noreply.github.com>
Date: Tue, 12 Oct 2021 17:35:08 -0300
Subject: [PATCH 10/81] Update pt_BR api.po
---
docs/locale/pt_BR/LC_MESSAGES/api.po | 80 ++++++++++++++++------------
1 file changed, 46 insertions(+), 34 deletions(-)
diff --git a/docs/locale/pt_BR/LC_MESSAGES/api.po b/docs/locale/pt_BR/LC_MESSAGES/api.po
index 5d143791..a2f829f0 100644
--- a/docs/locale/pt_BR/LC_MESSAGES/api.po
+++ b/docs/locale/pt_BR/LC_MESSAGES/api.po
@@ -4,118 +4,130 @@
# package.
# FIRST AUTHOR , 2021.
#
-#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Free Python Games 2.3.2\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-08-24 21:25-0300\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME \n"
-"Language-Team: LANGUAGE \n"
+"PO-Revision-Date: 2021-10-11 19:47-0300\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.9.1\n"
+"Last-Translator: \n"
+"Language-Team: \n"
+"Language: pt_BR\n"
+"X-Generator: Poedit 3.0\n"
#: ../../api.rst:2
msgid "Free Python Games API Reference"
-msgstr ""
+msgstr "Referência da API do Free Python Games"
#: ../../api.rst:4
msgid ""
-":doc:`Free Python Games ` includes a few helpful utilities. The "
-"best way to expose beginners to these functions is with Python's built-in"
-" help function. Learners should be able to understand and write the "
-"drawing functions themselves."
+":doc:`Free Python Games ` includes a few helpful utilities. The best "
+"way to expose beginners to these functions is with Python's built-in help "
+"function. Learners should be able to understand and write the drawing "
+"functions themselves."
msgstr ""
+":doc:`Free Python Games ` inclui alguns utilitários úteis. A melhor "
+"maneira de expor os iniciantes a essas funções é com a função de ajuda "
+"integrada do Python. Os alunos devem ser capazes de compreender e escrever as "
+"funções de desenho por si mesmos."
#: ../../api.rst:13
msgid "Drawing Functions"
-msgstr ""
+msgstr "Funções de Desenho"
#: freegames.utils.line:1 of
msgid "Draw line from `(a, b)` to `(x, y)`."
-msgstr ""
+msgstr "Desenhe uma linha de (a, b) a (x, y)."
#: freegames.utils.square:1 of
msgid "Draw square at `(x, y)` with side length `size` and fill color `name`."
msgstr ""
+"Desenhe um quadrado em (x, y) com o `tamanho` do comprimento lateral e "
+"preencha o `nome` da cor."
#: freegames.utils.square:3 of
msgid "The square is oriented so the bottom left corner is at (x, y)."
msgstr ""
+"O quadrado é orientado de forma que o canto esquerdo inferior esteja em (x, y)."
#: ../../api.rst:20
msgid "Helper Functions"
-msgstr ""
+msgstr "Funções de ajuda"
#: freegames.utils.floor:1 of
msgid "Floor of `value` given `size` and `offset`."
-msgstr ""
+msgstr "Piso de `valor` dado `tamanho` e `deslocamento`."
#: freegames.utils.floor:3 of
msgid "The floor function is best understood with a diagram of the number line::"
-msgstr ""
+msgstr "A função do piso é melhor compreendida com um diagrama da reta numérica:"
#: freegames.utils.floor:8 of
msgid ""
-"The number line shown has offset 200 denoted by the left-hand tick mark "
-"at -200 and size 100 denoted by the tick marks at -100, 0, 100, and 200. "
-"The floor of a value is the left-hand tick mark of the range where it "
-"lies. So for the points show above: ``floor(x)`` is -200, ``floor(y)`` is"
-" 0, and ``floor(z)`` is 100."
-msgstr ""
+"The number line shown has offset 200 denoted by the left-hand tick mark at "
+"-200 and size 100 denoted by the tick marks at -100, 0, 100, and 200. The "
+"floor of a value is the left-hand tick mark of the range where it lies. So for "
+"the points show above: ``floor(x)`` is -200, ``floor(y)`` is 0, and "
+"``floor(z)`` is 100."
+msgstr ""
+"A linha de número mostrada tem deslocamento 200 denotado pela marca de escala "
+"à esquerda em -200 e o tamanho 100 indicado pelas marcas de escala em -100, 0, "
+"100 e 200. O piso de um valor é a marca de escala à esquerda do intervalo onde "
+"se encontra. Portanto, para os pontos mostrados acima: o ``piso(x)`` é -200, o "
+"``piso(y)`` é 0 e o ``piso(z)`` é 100."
#: freegames.utils.path:1 of
msgid "Return full path to `filename` in freegames module."
-msgstr ""
+msgstr "Retorna o caminho completo para o `nome do arquivo` no módulo freegames."
#: ../../api.rst:27
msgid "Vectors"
-msgstr ""
+msgstr "Vetores"
#: freegames.utils.vector:1 of
msgid "Two-dimensional vector."
-msgstr ""
+msgstr "Vetor bidimensional."
#: freegames.utils.vector:3 of
msgid "Vectors can be modified in-place."
-msgstr ""
+msgstr "Os vetores podem ser modificados no local."
#: freegames.utils.vector.__init__:1 of
msgid "Initialize vector with coordinates: x, y."
-msgstr ""
+msgstr "Inicialize o vetor com as coordenadas: x, y."
#: freegames.utils.vector.__add__:1 of
msgid "v.__add__(w) -> v + w"
-msgstr ""
+msgstr "v.__add__(w) -> v + w"
#: freegames.utils.vector.__mul__:1 of
msgid "v.__mul__(w) -> v * w"
-msgstr ""
+msgstr "v.__mul__(w) -> v * w"
#: freegames.utils.vector.copy:1 of
msgid "Return copy of vector."
-msgstr ""
+msgstr "Retorna a cópia do vetor."
#: freegames.utils.vector.move:1 of
msgid "Move vector by other (in-place)."
-msgstr ""
+msgstr "Move o vetor por outro (no local)."
#: freegames.utils.vector.rotate:1 of
msgid "Rotate vector counter-clockwise by angle (in-place)."
-msgstr ""
+msgstr "Gire o vetor no sentido anti-horário pelo ângulo (no local)."
#: freegames.utils.vector.scale:1 of
msgid "Scale vector by other (in-place)."
-msgstr ""
+msgstr "Escala o vetor por outro (no local)."
#: freegames.vector.x:1 of
msgid "X-axis component of vector."
-msgstr ""
+msgstr "Componente do eixo X do vetor."
#: freegames.vector.y:1 of
msgid "Y-axis component of vector."
-msgstr ""
-
+msgstr "Componente do eixo Y do vetor."
From 2f0215a7ed2e408b1eebe452d0fab2c76800f159 Mon Sep 17 00:00:00 2001
From: Pedro-Henriquebg7 <85884290+Pedro-Henriquebg7@users.noreply.github.com>
Date: Tue, 12 Oct 2021 17:46:22 -0300
Subject: [PATCH 11/81] Update index.po Paint
---
docs/locale/pt_BR/LC_MESSAGES/index.po | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/docs/locale/pt_BR/LC_MESSAGES/index.po b/docs/locale/pt_BR/LC_MESSAGES/index.po
index e41fe7b8..2e7f6379 100644
--- a/docs/locale/pt_BR/LC_MESSAGES/index.po
+++ b/docs/locale/pt_BR/LC_MESSAGES/index.po
@@ -285,7 +285,7 @@ msgstr "Jogos Livres"
#: ../../../README.rst:134
msgid "Paint"
-msgstr ""
+msgstr "Paint"
#: ../../../README.rst:136
msgid ""
@@ -293,9 +293,12 @@ msgid ""
"of a shape and click again to mark its end. Different shapes and colors "
"can be selected using the keyboard."
msgstr ""
+"`Paint`_ -- desenhe linhas e formas na tela. Clique para marcar o início "
+"e uma forma e clique novamente para marcar o seu final. Diferentes formas "
+"e cores podem ser selecionadas usando o teclado."
msgid "Paint Free Python Game"
-msgstr ""
+msgstr "Paint Free Python Game"
#: ../../../README.rst:146
msgid "Snake"
From 8a851d2b2cd43d3e9cc74bb089608c1111f152ab Mon Sep 17 00:00:00 2001
From: Pedro-Henriquebg7 <85884290+Pedro-Henriquebg7@users.noreply.github.com>
Date: Tue, 12 Oct 2021 17:52:21 -0300
Subject: [PATCH 12/81] Update index.po-Snake
---
docs/locale/pt_BR/LC_MESSAGES/index.po | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/docs/locale/pt_BR/LC_MESSAGES/index.po b/docs/locale/pt_BR/LC_MESSAGES/index.po
index 2e7f6379..fe917bd0 100644
--- a/docs/locale/pt_BR/LC_MESSAGES/index.po
+++ b/docs/locale/pt_BR/LC_MESSAGES/index.po
@@ -302,7 +302,7 @@ msgstr "Paint Free Python Game"
#: ../../../README.rst:146
msgid "Snake"
-msgstr ""
+msgstr "Snake"
#: ../../../README.rst:148
msgid ""
@@ -310,9 +310,12 @@ msgid ""
"the green food. Each time the food is consumed, the snake grows one "
"segment longer. Avoid eating yourself or going out of bounds!"
msgstr ""
+"`Snake`_ -- jogo de arcade clássico. Use as setas do teclado para navegar e comer "
+"a comida verde. Cada vez que o alimento é consumido, a cobra cresce um "
+"segmento a mais. Evite comer você mesmo ou bater nas bordas!"
msgid "Snake Free Python Game"
-msgstr ""
+msgstr "Snake Free Python Game"
#: ../../../README.rst:158
msgid "Pacman"
From dc79f60faf304bd88f02e9d9cb7c4c3a3380d850 Mon Sep 17 00:00:00 2001
From: Pedro-Henriquebg7 <85884290+Pedro-Henriquebg7@users.noreply.github.com>
Date: Tue, 12 Oct 2021 17:55:19 -0300
Subject: [PATCH 13/81] Update index.po-Pacman
---
docs/locale/pt_BR/LC_MESSAGES/index.po | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/docs/locale/pt_BR/LC_MESSAGES/index.po b/docs/locale/pt_BR/LC_MESSAGES/index.po
index fe917bd0..d8444e2b 100644
--- a/docs/locale/pt_BR/LC_MESSAGES/index.po
+++ b/docs/locale/pt_BR/LC_MESSAGES/index.po
@@ -319,16 +319,18 @@ msgstr "Snake Free Python Game"
#: ../../../README.rst:158
msgid "Pacman"
-msgstr ""
+msgstr "Pacman"
#: ../../../README.rst:160
msgid ""
"`Pacman`_ -- classic arcade game. Use the arrow keys to navigate and eat "
"all the white food. Watch out for red ghosts that roam the maze."
msgstr ""
+"`Pacman`_ -- jogo de arcade clássico. Use as setas do teclado para navegar e comer "
+"toda a comida branca. Cuidado com os fantasmas vermelhos que vagam pelo labirinto."
msgid "Pacman Free Python Game"
-msgstr ""
+msgstr "Pacman Free Python Game"
#: ../../../README.rst:169
msgid "Cannon"
From 1ce5b18992ab9f478f39c4d207ed4b4d2e0572c0 Mon Sep 17 00:00:00 2001
From: Pedro-Henriquebg7 <85884290+Pedro-Henriquebg7@users.noreply.github.com>
Date: Tue, 12 Oct 2021 17:59:40 -0300
Subject: [PATCH 14/81] Update index.po-Cannon
---
docs/locale/pt_BR/LC_MESSAGES/index.po | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/docs/locale/pt_BR/LC_MESSAGES/index.po b/docs/locale/pt_BR/LC_MESSAGES/index.po
index d8444e2b..a4b839f2 100644
--- a/docs/locale/pt_BR/LC_MESSAGES/index.po
+++ b/docs/locale/pt_BR/LC_MESSAGES/index.po
@@ -334,7 +334,7 @@ msgstr "Pacman Free Python Game"
#: ../../../README.rst:169
msgid "Cannon"
-msgstr ""
+msgstr "Canhão"
#: ../../../README.rst:171
msgid ""
@@ -342,9 +342,12 @@ msgid ""
"cannnonball. The cannonball pops blue balloons in its path. Pop all the "
"balloons before they can cross the screen."
msgstr ""
+"`Canhão`_ -- movimento de projétil. Clique na tela para disparar sua bala de canhão."
+"A bala de canhão estoura balões azuis em seu caminho. Estoure todos os balões "
+"antes que eles possam cruzar a tela."
msgid "Cannon Free Python Game"
-msgstr ""
+msgstr "Canhão Free Python Game"
#: ../../../README.rst:181
msgid "Connect"
From 1032017fc5b7f1cbf32f1694e2d85612b83cd7b4 Mon Sep 17 00:00:00 2001
From: Pedro-Henriquebg7 <85884290+Pedro-Henriquebg7@users.noreply.github.com>
Date: Tue, 12 Oct 2021 18:10:17 -0300
Subject: [PATCH 15/81] Update index.po-Connect 4
---
docs/locale/pt_BR/LC_MESSAGES/index.po | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/docs/locale/pt_BR/LC_MESSAGES/index.po b/docs/locale/pt_BR/LC_MESSAGES/index.po
index a4b839f2..3f86525e 100644
--- a/docs/locale/pt_BR/LC_MESSAGES/index.po
+++ b/docs/locale/pt_BR/LC_MESSAGES/index.po
@@ -351,7 +351,7 @@ msgstr "Canhão Free Python Game"
#: ../../../README.rst:181
msgid "Connect"
-msgstr ""
+msgstr "Connect"
#: ../../../README.rst:183
msgid ""
@@ -359,9 +359,11 @@ msgid ""
"player to connect four discs vertically, horizontally, or diagonally "
"wins!"
msgstr ""
+"`Connect`_ -- Jogo Ligue 4. Clique em uma linha para soltar um disco. O primeiro"
+"jogador a conectar quatro discos verticalmente, horizontalmente ou diagonalmente vence!"
msgid "Connect 4 Free Python Game"
-msgstr ""
+msgstr "Connect 4 Free Python Game"
#: ../../../README.rst:192
msgid "Flappy"
From d7d11220bd4db8848e7e9d6e669262157eb4add5 Mon Sep 17 00:00:00 2001
From: Pedro-Henriquebg7 <85884290+Pedro-Henriquebg7@users.noreply.github.com>
Date: Tue, 12 Oct 2021 18:15:21 -0300
Subject: [PATCH 16/81] Update index.po-Flappy
---
docs/locale/pt_BR/LC_MESSAGES/index.po | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/docs/locale/pt_BR/LC_MESSAGES/index.po b/docs/locale/pt_BR/LC_MESSAGES/index.po
index 3f86525e..91cfa8bf 100644
--- a/docs/locale/pt_BR/LC_MESSAGES/index.po
+++ b/docs/locale/pt_BR/LC_MESSAGES/index.po
@@ -367,16 +367,18 @@ msgstr "Connect 4 Free Python Game"
#: ../../../README.rst:192
msgid "Flappy"
-msgstr ""
+msgstr "Flappy"
#: ../../../README.rst:194
msgid ""
"`Flappy`_ -- Flappy-bird inspired game. Click the screen to flap your "
"wings. Watch out for black ravens as you fly across the screen."
msgstr ""
+"`Flappy`_ -- Jogo inspirado em Flappy-bird. Clique na tela para "
+"bater suas asas. Cuidado com os corvos negros enquanto voa pela tela."
msgid "Flappy Bird Free Python Game"
-msgstr ""
+msgstr "Flappy Bird Free Python Game"
#: ../../../README.rst:203
msgid "Memory"
From 93992242a12f3737acfbba070c9db9c625211933 Mon Sep 17 00:00:00 2001
From: Pedro-Henriquebg7 <85884290+Pedro-Henriquebg7@users.noreply.github.com>
Date: Tue, 12 Oct 2021 18:18:40 -0300
Subject: [PATCH 17/81] Update index.po-Memory
---
docs/locale/pt_BR/LC_MESSAGES/index.po | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/docs/locale/pt_BR/LC_MESSAGES/index.po b/docs/locale/pt_BR/LC_MESSAGES/index.po
index 91cfa8bf..6a3ee454 100644
--- a/docs/locale/pt_BR/LC_MESSAGES/index.po
+++ b/docs/locale/pt_BR/LC_MESSAGES/index.po
@@ -382,7 +382,7 @@ msgstr "Flappy Bird Free Python Game"
#: ../../../README.rst:203
msgid "Memory"
-msgstr ""
+msgstr "Memória"
#: ../../../README.rst:205
msgid ""
@@ -390,9 +390,11 @@ msgid ""
"number. Match two numbers and the tiles will disappear to reveal an "
"image."
msgstr ""
+"`Memória`_ -- jogo de quebra-cabeça de pares de números. Clique em um ladrilho para "
+"revelar um número. Combine dois números e as peças desaparecerão para revelar uma imagem."
msgid "Memory Free Python Game"
-msgstr ""
+msgstr "Memória Free Python Game"
#: ../../../README.rst:214
msgid "Pong"
From 69b859a8bef79ec37818bb510958c9b714ecb839 Mon Sep 17 00:00:00 2001
From: Pedro-Henriquebg7 <85884290+Pedro-Henriquebg7@users.noreply.github.com>
Date: Tue, 12 Oct 2021 18:22:00 -0300
Subject: [PATCH 18/81] Update index.po-Pong
---
docs/locale/pt_BR/LC_MESSAGES/index.po | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/docs/locale/pt_BR/LC_MESSAGES/index.po b/docs/locale/pt_BR/LC_MESSAGES/index.po
index 6a3ee454..81d1192d 100644
--- a/docs/locale/pt_BR/LC_MESSAGES/index.po
+++ b/docs/locale/pt_BR/LC_MESSAGES/index.po
@@ -398,16 +398,18 @@ msgstr "Memória Free Python Game"
#: ../../../README.rst:214
msgid "Pong"
-msgstr ""
+msgstr "Pong"
#: ../../../README.rst:216
msgid ""
"`Pong`_ -- classic arcade game. Use the keyboard to move your paddle up "
"and down. The first player to miss the ball loses."
msgstr ""
+"`Pong`_ -- jogo de arcade clássico. Use o teclado para mover a raquete para "
+"cima e para baixo. O primeiro jogador a perder a bola perde."
msgid "Pong Free Python Game"
-msgstr ""
+msgstr "Pong Free Python Game"
#: ../../../README.rst:225
msgid "Simon Says"
From 181a928ade1c1ec79c8e716115d2c1b9036bdcd4 Mon Sep 17 00:00:00 2001
From: Pedro-Henriquebg7 <85884290+Pedro-Henriquebg7@users.noreply.github.com>
Date: Tue, 12 Oct 2021 18:25:23 -0300
Subject: [PATCH 19/81] Update index.po-Simon Says
---
docs/locale/pt_BR/LC_MESSAGES/index.po | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/docs/locale/pt_BR/LC_MESSAGES/index.po b/docs/locale/pt_BR/LC_MESSAGES/index.po
index 81d1192d..bf5af11c 100644
--- a/docs/locale/pt_BR/LC_MESSAGES/index.po
+++ b/docs/locale/pt_BR/LC_MESSAGES/index.po
@@ -413,7 +413,7 @@ msgstr "Pong Free Python Game"
#: ../../../README.rst:225
msgid "Simon Says"
-msgstr ""
+msgstr "Simon Says"
#: ../../../README.rst:227
msgid ""
@@ -421,9 +421,12 @@ msgid ""
"Watch the pattern and then click the tiles in the same order. Each time "
"you get the sequence right the pattern gets one step longer."
msgstr ""
+"`Simon Says`_ -- jogo clássico de quebra-cabeça de memória. Clique na tela para começar."
+"Observe o padrão e clique nas peças na mesma ordem. Cada vez que você acerta a sequência, "
+"o padrão fica um passo mais longo."
msgid "Simon Says Free Python Game"
-msgstr ""
+msgstr "Simon Says Free Python Game"
#: ../../../README.rst:237
msgid "Tic Tac Toe"
From 4b5f1ff11cec9dece802427d61c3481a321d56a3 Mon Sep 17 00:00:00 2001
From: Pedro-Henriquebg7 <85884290+Pedro-Henriquebg7@users.noreply.github.com>
Date: Tue, 12 Oct 2021 18:28:48 -0300
Subject: [PATCH 20/81] Update index.po-Tic Tac Toe
---
docs/locale/pt_BR/LC_MESSAGES/index.po | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/docs/locale/pt_BR/LC_MESSAGES/index.po b/docs/locale/pt_BR/LC_MESSAGES/index.po
index bf5af11c..8d77dd55 100644
--- a/docs/locale/pt_BR/LC_MESSAGES/index.po
+++ b/docs/locale/pt_BR/LC_MESSAGES/index.po
@@ -430,16 +430,18 @@ msgstr "Simon Says Free Python Game"
#: ../../../README.rst:237
msgid "Tic Tac Toe"
-msgstr ""
+msgstr "Jogo da Velha"
#: ../../../README.rst:239
msgid ""
"`Tic Tac Toe`_ -- classic game. Click the screen to place an X or O. "
"Connect three in a row and you win!"
msgstr ""
+"`Jogo da Velha`_ -- jogo clássico. Clique na tela para colocar um X ou O. "
+"Conecte três em uma linha e você ganha!"
msgid "Tic Tac Toe Free Python Game"
-msgstr ""
+msgstr "Jogo da Velha Free Python Game"
#: ../../../README.rst:248
msgid "Tiles"
From 564089a5480255a73aeb36c7e21ffe71d2452b31 Mon Sep 17 00:00:00 2001
From: Pedro-Henriquebg7 <85884290+Pedro-Henriquebg7@users.noreply.github.com>
Date: Tue, 12 Oct 2021 18:32:43 -0300
Subject: [PATCH 21/81] Update index.po-Tiles
---
docs/locale/pt_BR/LC_MESSAGES/index.po | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/docs/locale/pt_BR/LC_MESSAGES/index.po b/docs/locale/pt_BR/LC_MESSAGES/index.po
index 8d77dd55..9cf1374d 100644
--- a/docs/locale/pt_BR/LC_MESSAGES/index.po
+++ b/docs/locale/pt_BR/LC_MESSAGES/index.po
@@ -445,7 +445,7 @@ msgstr "Jogo da Velha Free Python Game"
#: ../../../README.rst:248
msgid "Tiles"
-msgstr ""
+msgstr "Tiles"
#: ../../../README.rst:250
msgid ""
@@ -453,9 +453,12 @@ msgid ""
"adjacent to the empty square to swap positions. Can you make the tiles "
"count one to fifteen from left to right and bottom to top?"
msgstr ""
+"`Tiles`_ -- jogo de quebra-cabeça de números deslizantes. Clique em um ladrilho "
+"adjacente ao quadrado vazio para trocar de posição. Você pode fazer as "
+"peças contarem de um a quinze da esquerda para a direita e de baixo para cima?"
msgid "Tiles Free Python Game"
-msgstr ""
+msgstr "Tiles Free Python Game"
#: ../../../README.rst:260
msgid "Tron"
From 7aa7bd9e96f8a558182a82a14b3b153b53082354 Mon Sep 17 00:00:00 2001
From: Pedro-Henriquebg7 <85884290+Pedro-Henriquebg7@users.noreply.github.com>
Date: Tue, 12 Oct 2021 18:49:56 -0300
Subject: [PATCH 22/81] Update index.po-Tron
---
docs/locale/pt_BR/LC_MESSAGES/index.po | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/docs/locale/pt_BR/LC_MESSAGES/index.po b/docs/locale/pt_BR/LC_MESSAGES/index.po
index 9cf1374d..c953f293 100644
--- a/docs/locale/pt_BR/LC_MESSAGES/index.po
+++ b/docs/locale/pt_BR/LC_MESSAGES/index.po
@@ -462,16 +462,18 @@ msgstr "Tiles Free Python Game"
#: ../../../README.rst:260
msgid "Tron"
-msgstr ""
+msgstr "Tron"
#: ../../../README.rst:262
msgid ""
"`Tron`_ -- classic arcade game. Use the keyboard to change the direction "
"of your Tron player. Avoid touching the line drawn by your opponent."
msgstr ""
+"`Tron`_ -- jogo clássico de arcade. Utilize o teclado para mudar a direção "
+"do seu jogador em Tron. Evite tocar na linha desenhada pelo seu oponente."
msgid "Tron Free Python Game"
-msgstr ""
+msgstr "Tron Free Python Game"
#: ../../../README.rst:271
msgid "Life"
From 811adbb26f017a9cacecdd83912c596d231adc88 Mon Sep 17 00:00:00 2001
From: Pedro-Henriquebg7 <85884290+Pedro-Henriquebg7@users.noreply.github.com>
Date: Tue, 12 Oct 2021 18:56:14 -0300
Subject: [PATCH 23/81] Update index.po-Life
---
docs/locale/pt_BR/LC_MESSAGES/index.po | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/docs/locale/pt_BR/LC_MESSAGES/index.po b/docs/locale/pt_BR/LC_MESSAGES/index.po
index c953f293..f5bb57ee 100644
--- a/docs/locale/pt_BR/LC_MESSAGES/index.po
+++ b/docs/locale/pt_BR/LC_MESSAGES/index.po
@@ -477,16 +477,18 @@ msgstr "Tron Free Python Game"
#: ../../../README.rst:271
msgid "Life"
-msgstr ""
+msgstr "Jogo da vida"
#: ../../../README.rst:273
msgid ""
"`Life`_ -- Conway's Game of Life. The classic, zero-player, cellular "
"automation created in 1970 by John Conway."
msgstr ""
+"`Life`_ -- Jogo da vida de Conway. A clássica automação celular, zero-player, "
+"criada em 1970 por John Conway."
msgid "Game of Life Free Python Game"
-msgstr ""
+msgstr "Jogo da Vida Free Python Game"
#: ../../../README.rst:282
msgid "Maze"
From 3fc21d6e6d53c6991f39fc65d7b5fb42231b0b18 Mon Sep 17 00:00:00 2001
From: Pedro-Henriquebg7 <85884290+Pedro-Henriquebg7@users.noreply.github.com>
Date: Tue, 12 Oct 2021 19:10:35 -0300
Subject: [PATCH 24/81] Update index.po-Maze
---
docs/locale/pt_BR/LC_MESSAGES/index.po | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/docs/locale/pt_BR/LC_MESSAGES/index.po b/docs/locale/pt_BR/LC_MESSAGES/index.po
index f5bb57ee..c9321b03 100644
--- a/docs/locale/pt_BR/LC_MESSAGES/index.po
+++ b/docs/locale/pt_BR/LC_MESSAGES/index.po
@@ -492,7 +492,7 @@ msgstr "Jogo da Vida Free Python Game"
#: ../../../README.rst:282
msgid "Maze"
-msgstr ""
+msgstr "Maze"
#: ../../../README.rst:284
msgid ""
@@ -500,9 +500,11 @@ msgid ""
"Line of Code with 10 PRINT`_. Tap the screen to trace a path from one "
"side to another."
msgstr ""
+"`Maze`_ -- Mover de um lado para o outro. Inspirado por `A Universe in One "
+"Line of Code with 10 PRINT`_. Toque na tela para traçar um caminho de um lado para o outro."
msgid "Maze Free Python Game"
-msgstr ""
+msgstr "Maze Free Python Game"
#: ../../../README.rst:295
msgid "Fidget"
From 7efe423e68aecf8ddeac0c8b405062d453c50e51 Mon Sep 17 00:00:00 2001
From: Pedro-Henriquebg7 <85884290+Pedro-Henriquebg7@users.noreply.github.com>
Date: Tue, 12 Oct 2021 19:32:47 -0300
Subject: [PATCH 25/81] Update index.po-Fidget
---
docs/locale/pt_BR/LC_MESSAGES/index.po | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/docs/locale/pt_BR/LC_MESSAGES/index.po b/docs/locale/pt_BR/LC_MESSAGES/index.po
index c9321b03..3e5f0c7a 100644
--- a/docs/locale/pt_BR/LC_MESSAGES/index.po
+++ b/docs/locale/pt_BR/LC_MESSAGES/index.po
@@ -508,16 +508,18 @@ msgstr "Maze Free Python Game"
#: ../../../README.rst:295
msgid "Fidget"
-msgstr ""
+msgstr "Fidget"
#: ../../../README.rst:297
msgid ""
"`Fidget`_ -- fidget spinner inspired animation. Click the screen to "
"accelerate the fidget spinner."
msgstr ""
+"`Fidget`_ -- Animação inspirada nos brinquedos fidget spinner. Clique "
+"na tela para acelerar o fidget spinner."
msgid "Fidget Spinner Free Python Game"
-msgstr ""
+msgstr "Fidget Free Python Game"
#: ../../../README.rst:307
msgid "User Guide"
From 459f792fb83643052278957a8c1fad9664b5965a Mon Sep 17 00:00:00 2001
From: Pedro-Henriquebg7 <85884290+Pedro-Henriquebg7@users.noreply.github.com>
Date: Tue, 12 Oct 2021 19:41:16 -0300
Subject: [PATCH 26/81] Update index.po-User Guide
---
docs/locale/pt_BR/LC_MESSAGES/index.po | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/docs/locale/pt_BR/LC_MESSAGES/index.po b/docs/locale/pt_BR/LC_MESSAGES/index.po
index 3e5f0c7a..524efe6b 100644
--- a/docs/locale/pt_BR/LC_MESSAGES/index.po
+++ b/docs/locale/pt_BR/LC_MESSAGES/index.po
@@ -523,29 +523,31 @@ msgstr "Fidget Free Python Game"
#: ../../../README.rst:307
msgid "User Guide"
-msgstr ""
+msgstr "Guia do Usuário"
#: ../../../README.rst:309
msgid ""
"For those wanting more details, this part of the documentation describes "
"curriculum, API, and development."
msgstr ""
+"Para aqueles que procuram mais detalhes, essa parte da documentação descreve "
+"o currículo, API, e desenvolvimento."
#: ../../../README.rst:312
msgid "`Talk: Give the Gift of Python`_"
-msgstr ""
+msgstr "`Palestra: Dê o presente de Python`_"
#: ../../../README.rst:313
msgid "`Free Python Games Curriculum`_"
-msgstr ""
+msgstr "`Currículo Free Python Games`_"
#: ../../../README.rst:314
msgid "`Free Python Games API Reference`_"
-msgstr ""
+msgstr "`Referência da API do Free Python Games`_"
#: ../../../README.rst:315
msgid "`Free Python Games Development`_"
-msgstr ""
+msgstr "`Desenvolvimento do Free Python Games Desenvolvimento`_"
#: ../../../README.rst:324
msgid "References"
From 1f71dcc6b19fabbd902adc830a39e718fd384091 Mon Sep 17 00:00:00 2001
From: Pedro-Henriquebg7 <85884290+Pedro-Henriquebg7@users.noreply.github.com>
Date: Tue, 12 Oct 2021 19:56:04 -0300
Subject: [PATCH 27/81] Update index.po-References
---
docs/locale/pt_BR/LC_MESSAGES/index.po | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/docs/locale/pt_BR/LC_MESSAGES/index.po b/docs/locale/pt_BR/LC_MESSAGES/index.po
index 524efe6b..5429e9e4 100644
--- a/docs/locale/pt_BR/LC_MESSAGES/index.po
+++ b/docs/locale/pt_BR/LC_MESSAGES/index.po
@@ -547,27 +547,27 @@ msgstr "`Referência da API do Free Python Games`_"
#: ../../../README.rst:315
msgid "`Free Python Games Development`_"
-msgstr "`Desenvolvimento do Free Python Games Desenvolvimento`_"
+msgstr "`Desenvolvimento do Free Python Games`_"
#: ../../../README.rst:324
msgid "References"
-msgstr ""
+msgstr "Referências"
#: ../../../README.rst:326
msgid "`Free Python Games Documentation`_"
-msgstr ""
+msgstr "`Documentação do Free Python Games`_ "
#: ../../../README.rst:327
msgid "`Free Python Games at PyPI`_"
-msgstr ""
+msgstr "`Free Python Games no PyPI`_"
#: ../../../README.rst:328
msgid "`Free Python Games at GitHub`_"
-msgstr ""
+msgstr "`Free Python Games no GitHub`_"
#: ../../../README.rst:329
msgid "`Free Python Games Issue Tracker`_"
-msgstr ""
+msgstr "`Rastreador de issues do Free Python Games`_"
#: ../../../README.rst:338
msgid "Free Python Games License"
From 83b7d9ff708699a76319c23cc40a78cab258c0db Mon Sep 17 00:00:00 2001
From: Pedro-Henriquebg7 <85884290+Pedro-Henriquebg7@users.noreply.github.com>
Date: Tue, 12 Oct 2021 20:37:16 -0300
Subject: [PATCH 28/81] Update index.po-Baseboard
---
docs/locale/pt_BR/LC_MESSAGES/index.po | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/docs/locale/pt_BR/LC_MESSAGES/index.po b/docs/locale/pt_BR/LC_MESSAGES/index.po
index 5429e9e4..a4089fc4 100644
--- a/docs/locale/pt_BR/LC_MESSAGES/index.po
+++ b/docs/locale/pt_BR/LC_MESSAGES/index.po
@@ -571,11 +571,11 @@ msgstr "`Rastreador de issues do Free Python Games`_"
#: ../../../README.rst:338
msgid "Free Python Games License"
-msgstr ""
+msgstr "Licença do Free Python Games"
#: ../../../README.rst:340
msgid "Copyright 2017-2020 Grant Jenks"
-msgstr ""
+msgstr "Direitos autorais 2017 - 2020 Grant Jenks"
#: ../../../README.rst:342
msgid ""
@@ -583,10 +583,13 @@ msgid ""
" not use this file except in compliance with the License. You may obtain"
" a copy of the License at"
msgstr ""
+"Licenciado pela licença Apache, Versão 2.0( A \"Licença\"); Você não pode usar"
+" esse documento exceto se estiver em concordância com a Licença. Pode obter a"
+" cópia da licença em"
#: ../../../README.rst:346
msgid "http://www.apache.org/licenses/LICENSE-2.0"
-msgstr ""
+msgstr "http://www.apache.org/licenses/LICENSE-2.0"
#: ../../../README.rst:348
msgid ""
@@ -596,4 +599,8 @@ msgid ""
" See the License for the specific language governing permissions and "
"limitations under the License."
msgstr ""
-
+"A menos que exigido pela lei aplicável ou acordado por escrito, o software "
+"distribuído sob a Licença é distribuído \"COMO ESTÁ\", SEM GARANTÍAS OU CONDIÇÕES DE "
+"QUALQUER TIPO, expressas ou implícitas. Consulte a licença para as permissões e"
+"limitações que regem o idioma específico sob a Licença."
+"
From c83d954ee04c4cd57628f822eacf4ffa56255b85 Mon Sep 17 00:00:00 2001
From: Pedro-Henriquebg7 <85884290+Pedro-Henriquebg7@users.noreply.github.com>
Date: Tue, 12 Oct 2021 21:30:50 -0300
Subject: [PATCH 29/81] Update sphinx.po
---
docs/locale/pt_BR/LC_MESSAGES/sphinx.po | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/docs/locale/pt_BR/LC_MESSAGES/sphinx.po b/docs/locale/pt_BR/LC_MESSAGES/sphinx.po
index fc9b7ced..e64d3329 100644
--- a/docs/locale/pt_BR/LC_MESSAGES/sphinx.po
+++ b/docs/locale/pt_BR/LC_MESSAGES/sphinx.po
@@ -20,19 +20,19 @@ msgstr ""
#: ../../_templates/gumroad.html:1
msgid "Donate"
-msgstr ""
+msgstr "Doações"
#: ../../_templates/gumroad.html:2
msgid "If you or your organization uses Free Games, consider donating:"
-msgstr ""
+msgstr "Se você ou sua organização usa Free Games, considere fazer uma doação:"
#: ../../_templates/gumroad.html:4
msgid "Donate to Free Python Games"
-msgstr ""
+msgstr "Doe para Free Python games"
#: ../../_templates/pagetoc.html:11
msgid "Contents"
-msgstr ""
+msgstr "Conteúdo"
#: ../../_templates/search.html:14 ../../_templates/search.html:17
msgid "Search"
From a734249cc35427b11d47e69dfdd2047487aa557e Mon Sep 17 00:00:00 2001
From: Adorilson Bezerra
Date: Tue, 12 Oct 2021 21:50:15 -0300
Subject: [PATCH 30/81] Update po files
---
docs/locale/pt_BR/LC_MESSAGES/development.po | 36 ++++-
docs/locale/pt_BR/LC_MESSAGES/index.po | 149 +++++++++++--------
docs/locale/pt_BR/LC_MESSAGES/madlibs.po | 28 ++++
3 files changed, 149 insertions(+), 64 deletions(-)
create mode 100644 docs/locale/pt_BR/LC_MESSAGES/madlibs.po
diff --git a/docs/locale/pt_BR/LC_MESSAGES/development.po b/docs/locale/pt_BR/LC_MESSAGES/development.po
index 2dd074d9..a8f506da 100644
--- a/docs/locale/pt_BR/LC_MESSAGES/development.po
+++ b/docs/locale/pt_BR/LC_MESSAGES/development.po
@@ -9,7 +9,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Free Python Games 2.3.2\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2021-08-24 21:25-0300\n"
+"POT-Creation-Date: 2021-10-09 18:46-0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
@@ -83,7 +83,9 @@ msgid "Limited Python feature set."
msgstr ""
#: ../../development.rst:29
-msgid "Short (less than 100 lines of code)."
+msgid ""
+"Short (less than 100 lines of code, or 300 lines in oriented object "
+"version)."
msgstr ""
#: ../../development.rst:32
@@ -163,3 +165,33 @@ msgid ""
"infrastructure and run the tests."
msgstr ""
+#: ../../development.rst:78
+msgid "Translate"
+msgstr ""
+
+#: ../../development.rst:80
+msgid ""
+"Translation files are available in the locale/ directory, if you want to "
+"contribute a translation make changes to its content."
+msgstr ""
+
+#: ../../development.rst:82
+msgid ""
+"if you want to translate to another language, you need to create the lang"
+" folder. To update the lang folder you need to use the command:"
+msgstr ""
+
+#: ../../development.rst:84
+msgid "$ make update-po"
+msgstr ""
+
+#~ msgid "Short (less than 100 lines of code)."
+#~ msgstr ""
+
+#~ msgid ""
+#~ "Translation files are available in the"
+#~ " /locale directory, if you want to"
+#~ " contribute a translation make changes "
+#~ "to its content."
+#~ msgstr ""
+
diff --git a/docs/locale/pt_BR/LC_MESSAGES/index.po b/docs/locale/pt_BR/LC_MESSAGES/index.po
index b431ba6a..82435d24 100644
--- a/docs/locale/pt_BR/LC_MESSAGES/index.po
+++ b/docs/locale/pt_BR/LC_MESSAGES/index.po
@@ -9,7 +9,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Free Python Games 2.3.2\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2021-08-24 21:25-0300\n"
+"POT-Creation-Date: 2021-10-04 21:57-0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
@@ -160,79 +160,79 @@ msgid "100% Test Coverage"
msgstr ""
#: ../../../README.rst:75
-msgid "Developed on Python 3.7"
+msgid "Developed on Python 3.9"
msgstr ""
#: ../../../README.rst:76
-msgid "Tested on CPython 2.7, 3.4, 3.5, 3.6, and 3.7"
+msgid "Tested on CPython 3.6, 3.7, 3.8, 3.9"
msgstr ""
#: ../../../README.rst:77
-msgid "Tested on Windows, Mac OS X, Raspbian (Raspberry Pi), and Linux"
+msgid "Tested on Linux, Mac OS X, and Windows"
msgstr ""
#: ../../../README.rst:78
-msgid "Tested using Travis CI and AppVeyor CI"
+msgid "Tested using GitHub Actions"
msgstr ""
-#: ../../../README.rst:88
+#: ../../../README.rst:85
msgid "Quickstart"
msgstr ""
-#: ../../../README.rst:90
+#: ../../../README.rst:87
msgid ""
"Installing Free Python Games is simple with `pip "
"`_::"
msgstr ""
-#: ../../../README.rst:95
+#: ../../../README.rst:92
msgid ""
"Free Python Games supports a command-line interface (CLI). Help for the "
"CLI is available using::"
msgstr ""
-#: ../../../README.rst:100
+#: ../../../README.rst:97
msgid ""
"The CLI supports three commands: list, copy, and show. For a list of all "
"games run::"
msgstr ""
-#: ../../../README.rst:105
+#: ../../../README.rst:102
msgid ""
"Any of the listed games may be played by executing the Python module from"
" the command-line. To reference the Python module, combine \"freegames\" "
"with the name of the game. For example, to play the \"snake\" game run::"
msgstr ""
-#: ../../../README.rst:111
+#: ../../../README.rst:108
msgid ""
"Games can be modified by copying their source code. The copy command will"
" create a Python file in your local directory which you can edit. For "
"example, to copy and play the \"snake\" game run::"
msgstr ""
-#: ../../../README.rst:118
+#: ../../../README.rst:115
msgid ""
"Python includes a built-in text editor named IDLE which can also execute "
"Python code. To launch the editor and make changes to the \"snake\" game "
"run::"
msgstr ""
-#: ../../../README.rst:123
+#: ../../../README.rst:120
msgid ""
"You can also access documentation in the interpreter with Python's built-"
"in help function::"
msgstr ""
-#: ../../../README.rst:131
+#: ../../../README.rst:128
msgid "Free Games"
msgstr ""
-#: ../../../README.rst:134
+#: ../../../README.rst:131
msgid "Paint"
msgstr ""
-#: ../../../README.rst:136
+#: ../../../README.rst:133
msgid ""
"`Paint`_ -- draw lines and shapes on the screen. Click to mark the start "
"of a shape and click again to mark its end. Different shapes and colors "
@@ -242,25 +242,26 @@ msgstr ""
msgid "Paint Free Python Game"
msgstr ""
-#: ../../../README.rst:146
+#: ../../../README.rst:143
msgid "Snake"
msgstr ""
-#: ../../../README.rst:148
+#: ../../../README.rst:145
msgid ""
"`Snake`_ -- classic arcade game. Use the arrow keys to navigate and eat "
"the green food. Each time the food is consumed, the snake grows one "
-"segment longer. Avoid eating yourself or going out of bounds!"
+"segment longer. Avoid eating yourself or going out of bounds! (`OO "
+"version`_)"
msgstr ""
msgid "Snake Free Python Game"
msgstr ""
-#: ../../../README.rst:158
+#: ../../../README.rst:156
msgid "Pacman"
msgstr ""
-#: ../../../README.rst:160
+#: ../../../README.rst:158
msgid ""
"`Pacman`_ -- classic arcade game. Use the arrow keys to navigate and eat "
"all the white food. Watch out for red ghosts that roam the maze."
@@ -269,11 +270,11 @@ msgstr ""
msgid "Pacman Free Python Game"
msgstr ""
-#: ../../../README.rst:169
+#: ../../../README.rst:167
msgid "Cannon"
msgstr ""
-#: ../../../README.rst:171
+#: ../../../README.rst:169
msgid ""
"`Cannon`_ -- projectile motion. Click the screen to fire your "
"cannnonball. The cannonball pops blue balloons in its path. Pop all the "
@@ -283,11 +284,11 @@ msgstr ""
msgid "Cannon Free Python Game"
msgstr ""
-#: ../../../README.rst:181
+#: ../../../README.rst:179
msgid "Connect"
msgstr ""
-#: ../../../README.rst:183
+#: ../../../README.rst:181
msgid ""
"`Connect`_ -- Connect 4 game. Click a row to drop a disc. The first "
"player to connect four discs vertically, horizontally, or diagonally "
@@ -297,11 +298,11 @@ msgstr ""
msgid "Connect 4 Free Python Game"
msgstr ""
-#: ../../../README.rst:192
+#: ../../../README.rst:190
msgid "Flappy"
msgstr ""
-#: ../../../README.rst:194
+#: ../../../README.rst:192
msgid ""
"`Flappy`_ -- Flappy-bird inspired game. Click the screen to flap your "
"wings. Watch out for black ravens as you fly across the screen."
@@ -310,11 +311,11 @@ msgstr ""
msgid "Flappy Bird Free Python Game"
msgstr ""
-#: ../../../README.rst:203
+#: ../../../README.rst:201
msgid "Memory"
msgstr ""
-#: ../../../README.rst:205
+#: ../../../README.rst:203
msgid ""
"`Memory`_ -- puzzle game of number pairs. Click a tile to reveal a "
"number. Match two numbers and the tiles will disappear to reveal an "
@@ -324,11 +325,11 @@ msgstr ""
msgid "Memory Free Python Game"
msgstr ""
-#: ../../../README.rst:214
+#: ../../../README.rst:212
msgid "Pong"
msgstr ""
-#: ../../../README.rst:216
+#: ../../../README.rst:214
msgid ""
"`Pong`_ -- classic arcade game. Use the keyboard to move your paddle up "
"and down. The first player to miss the ball loses."
@@ -337,11 +338,11 @@ msgstr ""
msgid "Pong Free Python Game"
msgstr ""
-#: ../../../README.rst:225
+#: ../../../README.rst:223
msgid "Simon Says"
msgstr ""
-#: ../../../README.rst:227
+#: ../../../README.rst:225
msgid ""
"`Simon Says`_ -- classic memory puzzle game. Click the screen to start. "
"Watch the pattern and then click the tiles in the same order. Each time "
@@ -351,11 +352,11 @@ msgstr ""
msgid "Simon Says Free Python Game"
msgstr ""
-#: ../../../README.rst:237
+#: ../../../README.rst:235
msgid "Tic Tac Toe"
msgstr ""
-#: ../../../README.rst:239
+#: ../../../README.rst:237
msgid ""
"`Tic Tac Toe`_ -- classic game. Click the screen to place an X or O. "
"Connect three in a row and you win!"
@@ -364,11 +365,11 @@ msgstr ""
msgid "Tic Tac Toe Free Python Game"
msgstr ""
-#: ../../../README.rst:248
+#: ../../../README.rst:246
msgid "Tiles"
msgstr ""
-#: ../../../README.rst:250
+#: ../../../README.rst:248
msgid ""
"`Tiles`_ -- puzzle game of sliding numbers into place. Click a tile "
"adjacent to the empty square to swap positions. Can you make the tiles "
@@ -378,11 +379,11 @@ msgstr ""
msgid "Tiles Free Python Game"
msgstr ""
-#: ../../../README.rst:260
+#: ../../../README.rst:258
msgid "Tron"
msgstr ""
-#: ../../../README.rst:262
+#: ../../../README.rst:260
msgid ""
"`Tron`_ -- classic arcade game. Use the keyboard to change the direction "
"of your Tron player. Avoid touching the line drawn by your opponent."
@@ -391,11 +392,11 @@ msgstr ""
msgid "Tron Free Python Game"
msgstr ""
-#: ../../../README.rst:271
+#: ../../../README.rst:269
msgid "Life"
msgstr ""
-#: ../../../README.rst:273
+#: ../../../README.rst:271
msgid ""
"`Life`_ -- Conway's Game of Life. The classic, zero-player, cellular "
"automation created in 1970 by John Conway."
@@ -404,11 +405,11 @@ msgstr ""
msgid "Game of Life Free Python Game"
msgstr ""
-#: ../../../README.rst:282
+#: ../../../README.rst:280
msgid "Maze"
msgstr ""
-#: ../../../README.rst:284
+#: ../../../README.rst:282
msgid ""
"`Maze`_ -- move from one side to another. Inspired by `A Universe in One "
"Line of Code with 10 PRINT`_. Tap the screen to trace a path from one "
@@ -418,11 +419,11 @@ msgstr ""
msgid "Maze Free Python Game"
msgstr ""
-#: ../../../README.rst:295
+#: ../../../README.rst:293
msgid "Fidget"
msgstr ""
-#: ../../../README.rst:297
+#: ../../../README.rst:295
msgid ""
"`Fidget`_ -- fidget spinner inspired animation. Click the screen to "
"accelerate the fidget spinner."
@@ -431,72 +432,72 @@ msgstr ""
msgid "Fidget Spinner Free Python Game"
msgstr ""
-#: ../../../README.rst:307
+#: ../../../README.rst:305
msgid "User Guide"
msgstr ""
-#: ../../../README.rst:309
+#: ../../../README.rst:307
msgid ""
"For those wanting more details, this part of the documentation describes "
"curriculum, API, and development."
msgstr ""
-#: ../../../README.rst:312
+#: ../../../README.rst:310
msgid "`Talk: Give the Gift of Python`_"
msgstr ""
-#: ../../../README.rst:313
+#: ../../../README.rst:311
msgid "`Free Python Games Curriculum`_"
msgstr ""
-#: ../../../README.rst:314
+#: ../../../README.rst:312
msgid "`Free Python Games API Reference`_"
msgstr ""
-#: ../../../README.rst:315
+#: ../../../README.rst:313
msgid "`Free Python Games Development`_"
msgstr ""
-#: ../../../README.rst:324
+#: ../../../README.rst:322
msgid "References"
msgstr ""
-#: ../../../README.rst:326
+#: ../../../README.rst:324
msgid "`Free Python Games Documentation`_"
msgstr ""
-#: ../../../README.rst:327
+#: ../../../README.rst:325
msgid "`Free Python Games at PyPI`_"
msgstr ""
-#: ../../../README.rst:328
+#: ../../../README.rst:326
msgid "`Free Python Games at GitHub`_"
msgstr ""
-#: ../../../README.rst:329
+#: ../../../README.rst:327
msgid "`Free Python Games Issue Tracker`_"
msgstr ""
-#: ../../../README.rst:338
+#: ../../../README.rst:336
msgid "Free Python Games License"
msgstr ""
-#: ../../../README.rst:340
-msgid "Copyright 2017-2020 Grant Jenks"
+#: ../../../README.rst:338
+msgid "Copyright 2017-2021 Grant Jenks"
msgstr ""
-#: ../../../README.rst:342
+#: ../../../README.rst:340
msgid ""
"Licensed under the Apache License, Version 2.0 (the \"License\"); you may"
" not use this file except in compliance with the License. You may obtain"
" a copy of the License at"
msgstr ""
-#: ../../../README.rst:346
+#: ../../../README.rst:344
msgid "http://www.apache.org/licenses/LICENSE-2.0"
msgstr ""
-#: ../../../README.rst:348
+#: ../../../README.rst:346
msgid ""
"Unless required by applicable law or agreed to in writing, software "
"distributed under the License is distributed on an \"AS IS\" BASIS, "
@@ -505,3 +506,27 @@ msgid ""
"limitations under the License."
msgstr ""
+#~ msgid "Developed on Python 3.7"
+#~ msgstr ""
+
+#~ msgid "Tested on CPython 2.7, 3.4, 3.5, 3.6, and 3.7"
+#~ msgstr ""
+
+#~ msgid "Tested on Windows, Mac OS X, Raspbian (Raspberry Pi), and Linux"
+#~ msgstr ""
+
+#~ msgid "Tested using Travis CI and AppVeyor CI"
+#~ msgstr ""
+
+#~ msgid ""
+#~ "`Snake`_ -- classic arcade game. Use "
+#~ "the arrow keys to navigate and eat"
+#~ " the green food. Each time the "
+#~ "food is consumed, the snake grows "
+#~ "one segment longer. Avoid eating "
+#~ "yourself or going out of bounds!"
+#~ msgstr ""
+
+#~ msgid "Copyright 2017-2020 Grant Jenks"
+#~ msgstr ""
+
diff --git a/docs/locale/pt_BR/LC_MESSAGES/madlibs.po b/docs/locale/pt_BR/LC_MESSAGES/madlibs.po
new file mode 100644
index 00000000..89957903
--- /dev/null
+++ b/docs/locale/pt_BR/LC_MESSAGES/madlibs.po
@@ -0,0 +1,28 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) 2017-2021, Grant Jenks
+# This file is distributed under the same license as the Free Python Games
+# package.
+# FIRST AUTHOR , 2021.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: Free Python Games 2.3.2\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2021-10-04 21:57-0300\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME \n"
+"Language-Team: LANGUAGE \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Generated-By: Babel 2.9.1\n"
+
+#: ../../madlibs.rst:2
+msgid "Mad Libs"
+msgstr ""
+
+#: ../../madlibs.rst:4
+msgid "Create a funny story from a not-so funny story"
+msgstr ""
+
From b8dd4f1232961b5cd68e733c9c98bcd200547e98 Mon Sep 17 00:00:00 2001
From: Adorilson Bezerra
Date: Wed, 13 Oct 2021 09:50:43 -0300
Subject: [PATCH 31/81] Added docs/snake_oop.rst (was missing in previous
commit)
---
docs/snake_oop.rst | 6 ++++++
1 file changed, 6 insertions(+)
create mode 100644 docs/snake_oop.rst
diff --git a/docs/snake_oop.rst b/docs/snake_oop.rst
new file mode 100644
index 00000000..cec22a75
--- /dev/null
+++ b/docs/snake_oop.rst
@@ -0,0 +1,6 @@
+Snake
+=====
+
+Snake, classic arcade game.
+
+.. literalinclude:: ../freegames/snake_oop.py
From 9bcbf8aa280763d82612473d39835e04a8392af6 Mon Sep 17 00:00:00 2001
From: Breno Nascimento de Almeida
<72624554+BrenoNAlmeida@users.noreply.github.com>
Date: Tue, 23 Feb 2021 15:35:27 -0300
Subject: [PATCH 32/81] PR do snake_oop (#3)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* adding the OOP folder and snake_oop file
* adding the oop folder and snakeoop file
* Improvement OO Snake
* Defining more some classes and exercise in OOP Snake game
* remoção do metodo change e adição dos metodos referente a direção
* creation of the object oriented steering system of the snake
* passando a vassoura
* Passando a vassoura pela segunda vez
* limpeza, deixando com 200 linhas
* limpeza, deixando com 200 linhas
* remoção de classe inultilizada
* Delete config.py
* Delete get-pip.py
Co-authored-by: Breno
Co-authored-by: Adorilson Bezerra
---
freegames/oop/snake_oop.py | 197 +++++++++++++++++++++++++++++++++++++
freegames/snake.py | 34 ++++---
2 files changed, 216 insertions(+), 15 deletions(-)
create mode 100644 freegames/oop/snake_oop.py
diff --git a/freegames/oop/snake_oop.py b/freegames/oop/snake_oop.py
new file mode 100644
index 00000000..b4067b4a
--- /dev/null
+++ b/freegames/oop/snake_oop.py
@@ -0,0 +1,197 @@
+"""Snake, classic arcade game.
+
+Exercises
+
+1. How do you make the SnakeFast or SnakeSlow classes?
+2. How do you make a SnakeSmart, that change the direction when collide with edges?
+3. How would you make a new food types? When snake eat them it will more fast or decrease?
+4. How do you create a Actor that will be the Head and Food superclass?
+"""
+
+from turtle import setup, hideturtle, tracer, listen, onkey, done, update, clear, ontimer
+from random import randrange, choice
+from freegames import square, vector
+
+class Head:
+ def __init__(self, x, y):
+ self.position = vector(x, y)
+
+ @property
+ def x(self):
+ return self.position.x
+
+ @property
+ def y(self):
+ return self.position.y
+
+class Food:
+ color = 'Blue'
+ cal = 1
+ def __init__(self, x, y):
+ self.position = vector(x, y)
+
+ @property
+ def x(self):
+ return self.position.x
+
+ @property
+ def y(self):
+ return self.position.y
+
+class Snake:
+ SPEED = 1
+ def __init__(self, x=0, y=0):
+ self.head = Head(x, y)
+ self.body = [vector(10, 0)]
+ self.aim = vector(0*self.SPEED, -10*self.SPEED)
+ self.direction = "SOUTH"
+ self.status = 'LIVE'
+
+ def eat(self, food):
+ print('snake is eating', food.cal)
+ for x in range(food.cal):
+ self.body.append(self.head.position)
+
+ for x in range(food.cal, 0):
+ del self.body[0]
+
+ def move(self):
+ "Move snake forward one segment."
+ self.head = Head(*self.body[-1].copy())
+ self.head.position.move(self.aim)
+
+ if self.is_colliding_with_border():
+ self.on_collision_with_border()
+ elif self.is_eating_himself():
+ self.on_eating_himself()
+ else:
+ self.body.append(self.head.position)
+ self.body.pop(0) # cut the tail
+
+ def on_collision_with_border(self):
+ self.dead()
+
+ def on_eating_himself(self):
+ self.dead()
+
+ def is_eating_himself(self):
+ return (self.head.position in self.body)
+
+ def dead(self):
+ self.status = 'DEAD'
+
+ def alive(self):
+ return self.status != 'DEAD'
+
+ def is_colliding_with_border(self):
+ return not(-200 < self.head.x < 190 and -200 < self.head.y < 190)
+
+ def left(self):
+ if self.direction == "NORTH" :
+ self.aim.x = -10*self.SPEED
+ self.aim.y = 0*self.SPEED
+
+ elif self.direction == "SOUTH":
+ self.aim.x = 10*self.SPEED
+ self.aim.y = 0*self.SPEED
+
+ elif self.direction == "WEST" :
+ self.aim.x = 0*self.SPEED
+ self.aim.y = -10*self.SPEED
+
+ elif self.direction == "EAST":
+ self.aim.x = 0*self.SPEED
+ self.aim.y = 10*self.SPEED
+
+ def right(self):
+ if self.direction == "NORTH" :
+ self.aim.x = 10*self.SPEED
+ self.aim.y = 0*self.SPEED
+
+ elif self.direction == "SOUTH":
+ self.aim.x = -10*self.SPEED
+ self.aim.y = 0*self.SPEED
+
+ elif self.direction == "WEST" :
+ self.aim.x = 0*self.SPEED
+ self.aim.y = 10*self.SPEED
+
+ elif self.direction == "EAST":
+ self.aim.x = 0*self.SPEED
+ self.aim.y = -10*self.SPEED
+
+class GameSnake:
+ def __init__(self):
+ self.food = self.new_food()
+ self.snake = Snake()
+
+ onkey(lambda: self.on_rightkeypressed() , 'Right')
+ onkey(lambda: self.on_leftkeypressed(), 'Left')
+ onkey(lambda: self.on_upkeypressed(), 'Up')
+ onkey(lambda: self.on_downkeypressed(), 'Down')
+
+ def on_rightkeypressed(self):
+ if self.snake.direction == 'NORTH':
+ self.snake.right()
+ elif self.snake.direction == "SOUTH":
+ self.snake.left()
+ self.snake.direction = "EAST"
+
+ def on_leftkeypressed(self):
+ if self.snake.direction == 'NORTH':
+ self.snake.left()
+ elif self.snake.direction == "SOUTH":
+ self.snake.right()
+ self.snake.direction = "WEST"
+
+ def on_upkeypressed(self):
+ if self.snake.direction == 'WEST':
+ self.snake.right()
+ elif self.snake.direction == "EAST":
+ self.snake.left()
+ self.snake.direction = "NORTH"
+
+ def on_downkeypressed (self):
+ if self.snake.direction == 'WEST':
+ self.snake.left()
+ elif self.snake.direction == "EAST":
+ self.snake.right()
+ self.snake.direction = "SOUTH"
+
+ def new_food(self):
+ foods = [Food]
+ type_food = choice(foods)
+ food = type_food(0, 0)
+ food.position = vector(randrange(-15, 15) * 10, randrange(-15, 15) * 10)
+ return food
+
+ def run(self):
+ clear()
+ for body in self.snake.body:
+ square(body.x, body.y, 9, 'black')
+ square(self.food.x, self.food.y, 9, self.food.color)
+ update()
+ self.snake.move()
+
+ if self.snake.head.position == self.food.position:
+ self.snake.eat(self.food)
+ self.food = self.new_food()
+
+ if self.snake.alive():
+ ontimer(self.run, 100)
+ else:
+ print('>>> SNAKE IS DEAD <<<')
+ square(self.snake.head.x, self.snake.head.y, 9, 'red')
+ return
+
+def init():
+ setup(420, 420, 370, 0)
+ hideturtle()
+ tracer(False)
+ listen()
+ game = GameSnake()
+ game.run()
+ done()
+
+if __name__ == '__main__':
+ init()
\ No newline at end of file
diff --git a/freegames/snake.py b/freegames/snake.py
index 3b8c7b43..b7dbd6bb 100644
--- a/freegames/snake.py
+++ b/freegames/snake.py
@@ -7,49 +7,53 @@
3. How would you move the food?
4. Change the snake to respond to arrow keys.
+1. Como você deixa a cobra mais rápida ou mais lenta? FEITO
+2. Como você pode fazer a cobra contornar as bordas?
+3. Como você moveria a comida?
+4. Mude a cobra para responder às teclas de seta FEITO
"""
from turtle import *
from random import randrange
from freegames import square, vector
-food = vector(0, 0)
-snake = [vector(10, 0)]
-aim = vector(0, -10)
+food = vector(0, 0) #posição inicial da comida
+snake = [vector(10, 0)]#posição inicial da cobra
+aim = vector(0,-10) # velocidade/direção da cobra
def change(x, y):
- "Change snake direction."
+ "Change snake direction."#"Mudar a direção da cobra."
aim.x = x
aim.y = y
def inside(head):
- "Return True if head inside boundaries."
+ "Return True if head inside boundaries."#"Retorne True se a cabeça estiver dentro dos limites."
return -200 < head.x < 190 and -200 < head.y < 190
def move():
- "Move snake forward one segment."
+ "Move snake forward one segment." #Mova a cobra um segmento para frente
head = snake[-1].copy()
head.move(aim)
- if not inside(head) or head in snake:
- square(head.x, head.y, 9, 'red')
+ if not inside(head) or head in snake: # caso a cobra encoste nas bordas
+ square(head.x, head.y, 9, 'red')# desenha um dradrado vermelho
update()
return
- snake.append(head)
+ snake.append(head) #adiciona um quadrado na direção aim no vetor snake
if head == food:
print('Snake:', len(snake))
- food.x = randrange(-15, 15) * 10
- food.y = randrange(-15, 15) * 10
+ food.x = randrange(-15, 15) * 10 #novo X da comida no intervalo determinado
+ food.y = randrange(-15, 15) * 10 #novo Y da comida no intervalo determinado
else:
- snake.pop(0)
+ snake.pop(0) # remove o quadrado da posição anterior do vetor snake
clear()
-
+ #tamanho do corpo da cobra em relação ao vetor snake
for body in snake:
square(body.x, body.y, 9, 'black')
-
+ #tamanho da comida
square(food.x, food.y, 9, 'green')
update()
ontimer(move, 100)
@@ -63,4 +67,4 @@ def move():
onkey(lambda: change(0, 10), 'Up')
onkey(lambda: change(0, -10), 'Down')
move()
-done()
+done()
\ No newline at end of file
From 9a21e72d26c6caa3eaa95a21e2bebe2a993f17fd Mon Sep 17 00:00:00 2001
From: Grant Jenks
Date: Mon, 17 May 2021 21:45:53 -0700
Subject: [PATCH 33/81] Update last exercise
---
freegames/snake.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/freegames/snake.py b/freegames/snake.py
index b7dbd6bb..fa6b7c4b 100644
--- a/freegames/snake.py
+++ b/freegames/snake.py
@@ -5,7 +5,7 @@
1. How do you make the snake faster or slower?
2. How can you make the snake go around the edges?
3. How would you move the food?
-4. Change the snake to respond to arrow keys.
+4. Change the snake to respond to mouse clicks.
1. Como você deixa a cobra mais rápida ou mais lenta? FEITO
2. Como você pode fazer a cobra contornar as bordas?
From cf3c9d1ce3912875bf0ca6a85da5540061d11ebf Mon Sep 17 00:00:00 2001
From: David Eynon
Date: Tue, 1 Jun 2021 06:38:57 +0200
Subject: [PATCH 34/81] #55 - added initial mad libs game and initial test.
(#65)
Initial mad libs game and with testing.
---
docs/index.rst | 1 +
docs/madlibs.rst | 6 ++++++
freegames/madlibs.py | 41 +++++++++++++++++++++++++++++++++++++++++
tests/test_madlibs.py | 13 +++++++++++++
4 files changed, 61 insertions(+)
create mode 100644 docs/madlibs.rst
create mode 100644 freegames/madlibs.py
create mode 100644 tests/test_madlibs.py
diff --git a/docs/index.rst b/docs/index.rst
index 41a30183..0af26523 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -27,3 +27,4 @@
memory
pacman
fidget
+ madlibs
diff --git a/docs/madlibs.rst b/docs/madlibs.rst
new file mode 100644
index 00000000..1f0c31f8
--- /dev/null
+++ b/docs/madlibs.rst
@@ -0,0 +1,6 @@
+Mad Libs
+=====
+
+Create a funny story from a not-so funny story
+
+.. literalinclude:: ../freegames/madlibs.py
\ No newline at end of file
diff --git a/freegames/madlibs.py b/freegames/madlibs.py
new file mode 100644
index 00000000..2066abe3
--- /dev/null
+++ b/freegames/madlibs.py
@@ -0,0 +1,41 @@
+""" Mad Libs: Funny Story Creation Game.
+
+Exercises:
+
+1. Can you create functionality to replace the given story?
+2. Can you load the story and template from a file?
+3. Can you add additional parts of speech?
+4. Can you add flexibility in a loaded story template?
+5. Can you adjust for grammar? (past tense, etc.)
+6. Can you fix the bug that occurs if there is a period after the story?
+7. At what point would you need to encapsulate into a function?
+8. Can you use a function for this?
+9. What problems can occur to the expected output if the program were to
+ crash mid-run (ex: due to power failure, unexpected computer freeze etc.)
+10. How could you re-engineer this to allow for more robust retention of
+ the original story and/or the input collected?
+"""
+
+story_template = "The [adj] [adj] [n] [v] over the [adj] [n]"
+# The quick brown fox jumps over the lazy dog
+
+new_story = ""
+
+word_type_key = {
+ "[adj]": "adjective",
+ "[n]": "noun",
+ "[v]": "verb",
+ "[adv]": "adverb"
+}
+
+"Replace word types with user provided words"
+for char_block in story_template.split(' '):
+ if char_block in word_type_key:
+ new_word = input("Please enter a {}: ".format(
+ word_type_key[char_block]))
+ new_story += " {} ".format(new_word)
+ else:
+ new_story += " {} ".format(char_block)
+
+print("Your new story:")
+print(new_story)
diff --git a/tests/test_madlibs.py b/tests/test_madlibs.py
new file mode 100644
index 00000000..56a52508
--- /dev/null
+++ b/tests/test_madlibs.py
@@ -0,0 +1,13 @@
+import random
+import runpy
+import unittest.mock as mock
+
+
+def test_madlibs():
+ random.seed(0)
+ mock_input = mock.Mock()
+ mock_input.side_effect = ["quick", "brown","lazy","brown","dog","car","jumps"]
+ mocks = {'print': lambda *args: None, 'input': mock_input}
+
+ with mock.patch.multiple('builtins', **mocks):
+ runpy.run_module('freegames.madlibs')
\ No newline at end of file
From f76975d1c9d5e4412fcff9561c8548b13a891b34 Mon Sep 17 00:00:00 2001
From: Grant Jenks
Date: Mon, 31 May 2021 21:59:30 -0700
Subject: [PATCH 35/81] Update madlibs game
---
freegames/madlibs.py | 58 ++++++++++++++++++++------------------------
1 file changed, 26 insertions(+), 32 deletions(-)
diff --git a/freegames/madlibs.py b/freegames/madlibs.py
index 2066abe3..68ff46f1 100644
--- a/freegames/madlibs.py
+++ b/freegames/madlibs.py
@@ -1,41 +1,35 @@
-""" Mad Libs: Funny Story Creation Game.
+"""Mad Libs: Funny Story Creation Game
Exercises:
-1. Can you create functionality to replace the given story?
-2. Can you load the story and template from a file?
-3. Can you add additional parts of speech?
-4. Can you add flexibility in a loaded story template?
-5. Can you adjust for grammar? (past tense, etc.)
-6. Can you fix the bug that occurs if there is a period after the story?
-7. At what point would you need to encapsulate into a function?
-8. Can you use a function for this?
-9. What problems can occur to the expected output if the program were to
- crash mid-run (ex: due to power failure, unexpected computer freeze etc.)
-10. How could you re-engineer this to allow for more robust retention of
- the original story and/or the input collected?
-"""
-
-story_template = "The [adj] [adj] [n] [v] over the [adj] [n]"
-# The quick brown fox jumps over the lazy dog
+1. How to replace the story?
+2. How load the story and from a file?
+3. How to add additional parts of speech?
-new_story = ""
+"""
-word_type_key = {
- "[adj]": "adjective",
- "[n]": "noun",
- "[v]": "verb",
- "[adv]": "adverb"
+# The quick brown fox jumps over the lazy dog.
+template = 'The |1| |2| |3| |4| over the |5| |6|.'
+parts = {
+ '1': 'adjective',
+ '2': 'adjective',
+ '3': 'noun',
+ '4': 'verb',
+ '5': 'adjective',
+ '6': 'noun',
}
-"Replace word types with user provided words"
-for char_block in story_template.split(' '):
- if char_block in word_type_key:
- new_word = input("Please enter a {}: ".format(
- word_type_key[char_block]))
- new_story += " {} ".format(new_word)
+chunks = []
+
+for chunk in template.split('|'):
+ if chunk in parts:
+ description = parts[chunk]
+ prompt = 'Enter [{}]: '.format(description)
+ word = input(prompt)
+ chunks.append(word)
else:
- new_story += " {} ".format(char_block)
+ chunks.append(chunk)
-print("Your new story:")
-print(new_story)
+print('=' * 80)
+story = ''.join(chunks)
+print(story)
From 2cbacfa9514c42bab8385ce9a8eb2fc62d5a3d80 Mon Sep 17 00:00:00 2001
From: Grant Jenks
Date: Mon, 14 Jun 2021 17:13:32 -0700
Subject: [PATCH 36/81] Add GitHub workflow action for integration
---
.github/workflows/integration.yml | 50 +++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
create mode 100644 .github/workflows/integration.yml
diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml
new file mode 100644
index 00000000..1e9295c9
--- /dev/null
+++ b/.github/workflows/integration.yml
@@ -0,0 +1,50 @@
+name: integration
+
+on:
+ push:
+ branches:
+ - master
+ pull_request:
+ branches:
+ - master
+
+jobs:
+
+ checks:
+ runs-on: ubuntu-latest
+ strategy:
+ max-parallel: 6
+ matrix:
+ check: [bluecheck, doc8, docs, isortcheck, flake8, rstcheck]
+ steps:
+ - uses: actions/checkout@v2
+ - uses: actions/setup-python@v2
+ with:
+ python-version: 3.9
+ - name: Setup tox
+ run: |
+ pip install --upgrade pip
+ pip install tox
+ - name: Run checks with tox
+ run: |
+ tox -e ${{ matrix.check }}
+
+ tests:
+ needs: checks
+ runs-on: ${{ matrix.os }}
+ strategy:
+ max-parallel: 4
+ matrix:
+ os: [ubuntu-latest]
+ python-version: [3.6, 3.7, 3.8, 3.9]
+ steps:
+ - uses: actions/checkout@v2
+ - uses: actions/setup-python@v2
+ with:
+ python-version: ${{ matrix.python-version }}
+ - name: Setup tox
+ run: |
+ pip install --upgrade pip
+ pip install tox
+ - name: Test with tox
+ run: tox -e py
From 355c2e727e2672013ac0ea9dd6e879d8e28bbbe4 Mon Sep 17 00:00:00 2001
From: Grant Jenks
Date: Mon, 14 Jun 2021 17:19:32 -0700
Subject: [PATCH 37/81] Update readme
---
README.rst | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/README.rst b/README.rst
index 133bde98..3efddd88 100644
--- a/README.rst
+++ b/README.rst
@@ -72,16 +72,13 @@ Features
- Used in hundreds of hours of classroom instruction
- Fully Documented
- 100% Test Coverage
-- Developed on Python 3.7
-- Tested on CPython 2.7, 3.4, 3.5, 3.6, and 3.7
-- Tested on Windows, Mac OS X, Raspbian (Raspberry Pi), and Linux
-- Tested using Travis CI and AppVeyor CI
+- Developed on Python 3.9
+- Tested on CPython 3.6, 3.7, 3.8, 3.9
+- Tested on Linux, Mac OS X, and Windows
+- Tested using GitHub Actions
-.. image:: https://api.travis-ci.org/grantjenks/free-python-games.svg?branch=master
- :target: http://www.grantjenks.com/docs/freegames/
-
-.. image:: https://ci.appveyor.com/api/projects/status/github/grantjenks/free-python-games?branch=master&svg=true
- :target: http://www.grantjenks.com/docs/freegames/
+.. image:: https://github.com/grantjenks/free-python-games/workflows/integration/badge.svg
+ :target: http://www.grantjenks.com/docs/freegames/
Quickstart
From 318e37de4c3ae385b64dc6aa9ba88ee5c34aed00 Mon Sep 17 00:00:00 2001
From: Grant Jenks
Date: Mon, 14 Jun 2021 17:43:57 -0700
Subject: [PATCH 38/81] Delete travis/appveyor, update requirements and tox
---
.travis.yml | 15 ----------
appveyor.yml | 23 ----------------
requirements.txt | 5 +++-
tox.ini | 71 +++++++++++++++++++++++++++++++++++++++++++++++-
4 files changed, 74 insertions(+), 40 deletions(-)
delete mode 100644 .travis.yml
delete mode 100644 appveyor.yml
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index ca04f963..00000000
--- a/.travis.yml
+++ /dev/null
@@ -1,15 +0,0 @@
-sudo: false
-language: python
-install: pip install tox
-script: tox
-matrix:
- include:
- - python: 3.4
- env: TOXENV=py34
- - python: 3.5
- env: TOXENV=py35
- - python: 3.6
- env: TOXENV=py36
- - python: 3.7
- dist: xenial
- env: TOXENV=py37
diff --git a/appveyor.yml b/appveyor.yml
deleted file mode 100644
index b8f2abfd..00000000
--- a/appveyor.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-environment:
-
- matrix:
-
- - PYTHON: "C:\\Python34"
- - PYTHON: "C:\\Python35"
- - PYTHON: "C:\\Python36"
- - PYTHON: "C:\\Python37"
- - PYTHON: "C:\\Python34-x64"
- - PYTHON: "C:\\Python35-x64"
- - PYTHON: "C:\\Python36-x64"
- - PYTHON: "C:\\Python37-x64"
-
-install:
-
- - "%PYTHON%\\python.exe -m pip install pytest"
-
-build: off
-
-test_script:
-
- - set PYTHONPATH=C:\projects\free-python-games;C:\projects\free-python-games\tests
- - "%PYTHON%\\python.exe -m pytest -v tests"
diff --git a/requirements.txt b/requirements.txt
index eccc7a5b..d845935a 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,6 +1,9 @@
+-e .
+blue
coverage
doc8
-gj
+flake8
+isort
pylint
pytest
pytest-cov
diff --git a/tox.ini b/tox.ini
index 57a6a7c6..2ac9f335 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,6 @@
[tox]
-envlist=py34,py35,py36,py37
+envlist=bluecheck,doc8,docs,isortcheck,flake8,rstcheck,py36,py37,py38,py39
+skip_missing_interpreters=True
[testenv]
deps=
@@ -9,3 +10,71 @@ deps=
commands=python -m pytest -v --cov freegames --cov-report term-missing tests
setenv=
PYTHONPATH={toxinidir}:{toxinidir}/tests
+
+[testenv:blue]
+commands=blue {toxinidir}/setup.py {toxinidir}/freegames {toxinidir}/tests
+deps=blue
+
+[testenv:bluecheck]
+commands=blue --check {toxinidir}/setup.py {toxinidir}/freegames {toxinidir}/tests
+deps=blue
+
+[testenv:doc8]
+deps=doc8
+commands=doc8 docs --ignore-path docs/_build
+
+[testenv:docs]
+allowlist_externals=make
+changedir=docs
+commands=make html
+deps=
+ sphinx
+
+[testenv:flake8]
+commands=flake8 {toxinidir}/setup.py {toxinidir}/freegames {toxinidir}/tests
+deps=flake8
+
+[testenv:isort]
+commands=isort {toxinidir}/setup.py {toxinidir}/freegames {toxinidir}/tests
+deps=isort
+
+[testenv:isortcheck]
+commands=isort --check {toxinidir}/setup.py {toxinidir}/freegames {toxinidir}/tests
+deps=isort
+
+[testenv:rstcheck]
+commands=rstcheck {toxinidir}/README.rst
+deps=rstcheck
+
+[testenv:uploaddocs]
+allowlist_externals=rsync
+changedir=docs
+commands=
+ rsync -azP --stats --delete _build/html/ \
+ grantjenks.com:/srv/www/www.grantjenks.com/public/docs/freegames/
+
+[isort]
+multi_line_output = 3
+include_trailing_comma = True
+force_grid_wrap = 0
+use_parentheses = True
+ensure_newline_before_comments = True
+line_length = 79
+
+[pytest]
+addopts=
+ -n auto
+ --cov-branch
+ --cov-fail-under=100
+ --cov-report=term-missing
+ --cov=freegames
+ --doctest-glob="*.rst"
+ --doctest-modules
+ --import-mode append
+testpaths=docs freegames tests README.rst
+
+[doc8]
+# ignore=D000
+
+[flake8]
+max-line-length=120
From 1741a28159863a4c2138f07e4853ea57976279ed Mon Sep 17 00:00:00 2001
From: Grant Jenks
Date: Mon, 14 Jun 2021 17:52:05 -0700
Subject: [PATCH 39/81] First pass with blue
---
freegames/__main__.py | 2 ++
freegames/ant.py | 3 +++
freegames/bounce.py | 4 ++++
freegames/cannon.py | 5 +++++
freegames/connect.py | 3 +++
freegames/crypto.py | 5 +++++
freegames/fidget.py | 4 ++++
freegames/flappy.py | 5 +++++
freegames/guess.py | 10 +++++-----
freegames/life.py | 5 ++++-
freegames/maze.py | 3 +++
freegames/memory.py | 6 ++++++
freegames/pacman.py | 6 ++++++
freegames/paint.py | 8 ++++++++
freegames/pong.py | 6 ++++++
freegames/simonsays.py | 6 ++++++
freegames/snake.py | 4 ++++
freegames/tictactoe.py | 7 +++++++
freegames/tiles.py | 5 +++++
freegames/tron.py | 3 +++
freegames/utils.py | 3 +++
setup.py | 2 ++
tests/mockturtle.py | 8 ++++++++
tests/test_bagels.py | 1 +
tests/test_cannon.py | 4 +---
tests/test_crypto.py | 4 ++++
tests/test_flappy.py | 8 ++------
tests/test_madlibs.py | 12 ++++++++++--
tests/test_main.py | 3 +++
tests/test_tron.py | 11 +++--------
tests/test_utils.py | 2 ++
31 files changed, 133 insertions(+), 25 deletions(-)
diff --git a/freegames/__main__.py b/freegames/__main__.py
index e92a46ce..b083f70a 100644
--- a/freegames/__main__.py
+++ b/freegames/__main__.py
@@ -8,6 +8,7 @@
directory = os.path.dirname(os.path.realpath(__file__))
contents = os.listdir(directory)
+
def game_file(name):
"Return True if filename represents a game."
return (
@@ -16,6 +17,7 @@ def game_file(name):
and name != 'utils.py'
)
+
games = sorted(name[:-3] for name in contents if game_file(name))
parser = argparse.ArgumentParser(
diff --git a/freegames/ant.py b/freegames/ant.py
index ae388d0d..2d03bf7c 100644
--- a/freegames/ant.py
+++ b/freegames/ant.py
@@ -16,10 +16,12 @@
ant = vector(0, 0)
aim = vector(2, 0)
+
def wrap(value):
"Wrap value around -200 and 200."
return value # TODO
+
def draw():
"Move ant and draw screen."
ant.move(aim)
@@ -36,6 +38,7 @@ def draw():
if running:
ontimer(draw, 100)
+
setup(420, 420, 370, 0)
hideturtle()
tracer(False)
diff --git a/freegames/bounce.py b/freegames/bounce.py
index be92e587..7c9fcabb 100644
--- a/freegames/bounce.py
+++ b/freegames/bounce.py
@@ -14,13 +14,16 @@
from turtle import *
from freegames import vector
+
def value():
"Randomly generate value between (-5, -3) or (3, 5)."
return (3 + random() * 2) * choice([1, -1])
+
ball = vector(0, 0)
aim = vector(value(), value())
+
def draw():
"Move ball and draw game."
ball.move(aim)
@@ -40,6 +43,7 @@ def draw():
ontimer(draw, 50)
+
setup(420, 420, 370, 0)
hideturtle()
tracer(False)
diff --git a/freegames/cannon.py b/freegames/cannon.py
index ed21b771..e90ab986 100644
--- a/freegames/cannon.py
+++ b/freegames/cannon.py
@@ -17,6 +17,7 @@
speed = vector(0, 0)
targets = []
+
def tap(x, y):
"Respond to screen tap."
if not inside(ball):
@@ -25,10 +26,12 @@ def tap(x, y):
speed.x = (x + 200) / 25
speed.y = (y + 200) / 25
+
def inside(xy):
"Return True if xy within screen."
return -200 < xy.x < 200 and -200 < xy.y < 200
+
def draw():
"Draw ball and targets."
clear()
@@ -43,6 +46,7 @@ def draw():
update()
+
def move():
"Move ball and targets."
if randrange(40) == 0:
@@ -72,6 +76,7 @@ def move():
ontimer(move, 50)
+
setup(420, 420, 370, 0)
hideturtle()
up()
diff --git a/freegames/connect.py b/freegames/connect.py
index 9da2bcd3..5fcf8e8d 100644
--- a/freegames/connect.py
+++ b/freegames/connect.py
@@ -16,6 +16,7 @@
turns = {'red': 'yellow', 'yellow': 'red'}
state = {'player': 'yellow', 'rows': [0] * 8}
+
def grid():
"Draw Connect Four grid."
bgcolor('light blue')
@@ -31,6 +32,7 @@ def grid():
update()
+
def tap(x, y):
"Draw red or yellow circle in tapped row."
player = state['player']
@@ -50,6 +52,7 @@ def tap(x, y):
rows[row] = count + 1
state['player'] = turns[player]
+
setup(420, 420, 370, 0)
hideturtle()
tracer(False)
diff --git a/freegames/crypto.py b/freegames/crypto.py
index 0d7311e8..f89e52ac 100644
--- a/freegames/crypto.py
+++ b/freegames/crypto.py
@@ -12,6 +12,7 @@
"""
+
def encrypt(message, key):
"Encrypt message with key."
result = ''
@@ -48,14 +49,17 @@ def encrypt(message, key):
return result
+
def decrypt(message, key):
"Decrypt message with key."
return encrypt(message, -key)
+
def decode(message):
"Decode message without key."
pass # TODO
+
def get_key():
"Get key from user."
try:
@@ -66,6 +70,7 @@ def get_key():
print('Invalid key. Using key: 0.')
return 0
+
print('Do you wish to encrypt, decrypt, or decode a message?')
choice = input()
diff --git a/freegames/fidget.py b/freegames/fidget.py
index 6f649d53..e425acd5 100644
--- a/freegames/fidget.py
+++ b/freegames/fidget.py
@@ -13,6 +13,7 @@
state = {'turn': 0}
+
def spinner():
"Draw fidget spinner."
clear()
@@ -32,6 +33,7 @@ def spinner():
right(120)
update()
+
def animate():
"Animate fidget spinner."
if state['turn'] > 0:
@@ -40,10 +42,12 @@ def animate():
spinner()
ontimer(animate, 20)
+
def flick():
"Flick fidget spinner."
state['turn'] += 10
+
setup(420, 420, 370, 0)
hideturtle()
tracer(False)
diff --git a/freegames/flappy.py b/freegames/flappy.py
index cd62c643..1bfd341d 100644
--- a/freegames/flappy.py
+++ b/freegames/flappy.py
@@ -16,15 +16,18 @@
bird = vector(0, 0)
balls = []
+
def tap(x, y):
"Move bird up in response to screen tap."
up = vector(0, 30)
bird.move(up)
+
def inside(point):
"Return True if point on screen."
return -200 < point.x < 200 and -200 < point.y < 200
+
def draw(alive):
"Draw screen objects."
clear()
@@ -42,6 +45,7 @@ def draw(alive):
update()
+
def move():
"Update object positions."
bird.y -= 5
@@ -69,6 +73,7 @@ def move():
draw(True)
ontimer(move, 50)
+
setup(420, 420, 370, 0)
hideturtle()
up()
diff --git a/freegames/guess.py b/freegames/guess.py
index 2edc8149..d7e5738c 100644
--- a/freegames/guess.py
+++ b/freegames/guess.py
@@ -16,17 +16,17 @@
value = randint(start, end)
print(value)
-print("I'm thinking of a number between", start, "and", end)
+print("I'm thinking of a number between", start, 'and', end)
guess = None
while guess != value:
- text = input("Guess the number: ")
+ text = input('Guess the number: ')
guess = int(text)
if guess < value:
- print("Higher.")
+ print('Higher.')
elif guess > value:
- print("Lower.")
+ print('Lower.')
-print("Congratulations! You guessed the right answer:", value)
+print('Congratulations! You guessed the right answer:', value)
diff --git a/freegames/life.py b/freegames/life.py
index cd4d2968..912595cc 100644
--- a/freegames/life.py
+++ b/freegames/life.py
@@ -18,6 +18,7 @@
cells = {}
+
def initialize():
"Randomly initialize the cells."
for x in range(-200, 200, 10):
@@ -28,6 +29,7 @@ def initialize():
for y in range(-50, 50, 10):
cells[x, y] = choice([True, False])
+
def step():
"Compute one step in the Game of Life."
neighbors = {}
@@ -37,7 +39,7 @@ def step():
count = -cells[x, y]
for h in [-10, 0, 10]:
for v in [-10, 0, 10]:
- count += cells[x+h, y+v]
+ count += cells[x + h, y + v]
neighbors[x, y] = count
for cell, count in neighbors.items():
@@ -47,6 +49,7 @@ def step():
elif count == 3:
cells[cell] = True
+
def draw():
"Draw all the squares."
step()
diff --git a/freegames/maze.py b/freegames/maze.py
index 9fe41bf6..24a23bf0 100644
--- a/freegames/maze.py
+++ b/freegames/maze.py
@@ -12,6 +12,7 @@
from random import random
from freegames import line
+
def draw():
"Draw maze."
color('black')
@@ -26,6 +27,7 @@ def draw():
update()
+
def tap(x, y):
"Draw line and dot for screen tap."
if abs(x) > 198 or abs(y) > 198:
@@ -38,6 +40,7 @@ def tap(x, y):
goto(x, y)
dot(4)
+
setup(420, 420, 370, 0)
hideturtle()
tracer(False)
diff --git a/freegames/memory.py b/freegames/memory.py
index 7ff61aa3..f5a0ee5c 100644
--- a/freegames/memory.py
+++ b/freegames/memory.py
@@ -19,6 +19,7 @@
state = {'mark': None}
hide = [True] * 64
+
def square(x, y):
"Draw white square with black outline at (x, y)."
up()
@@ -31,14 +32,17 @@ def square(x, y):
left(90)
end_fill()
+
def index(x, y):
"Convert (x, y) coordinates to tiles index."
return int((x + 200) // 50 + ((y + 200) // 50) * 8)
+
def xy(count):
"Convert tiles count to (x, y) coordinates."
return (count % 8) * 50 - 200, (count // 8) * 50 - 200
+
def tap(x, y):
"Update mark and hidden tiles based on tap."
spot = index(x, y)
@@ -51,6 +55,7 @@ def tap(x, y):
hide[mark] = False
state['mark'] = None
+
def draw():
"Draw image and tiles."
clear()
@@ -75,6 +80,7 @@ def draw():
update()
ontimer(draw, 100)
+
shuffle(tiles)
setup(420, 420, 370, 0)
addshape(car)
diff --git a/freegames/pacman.py b/freegames/pacman.py
index f249a27d..c2fb3ab1 100644
--- a/freegames/pacman.py
+++ b/freegames/pacman.py
@@ -61,6 +61,7 @@ def square(x, y):
path.end_fill()
+
def offset(point):
"Return offset of point in tiles."
x = (floor(point.x, 20) + 200) / 20
@@ -68,6 +69,7 @@ def offset(point):
index = int(x + y * 20)
return index
+
def valid(point):
"Return True if point is valid in tiles."
index = offset(point)
@@ -82,6 +84,7 @@ def valid(point):
return point.x % 20 == 0 or point.y % 20 == 0
+
def world():
"Draw world using path."
bgcolor('black')
@@ -100,6 +103,7 @@ def world():
path.goto(x + 10, y + 10)
path.dot(2, 'white')
+
def move():
"Move pacman and all ghosts."
writer.undo()
@@ -149,12 +153,14 @@ def move():
ontimer(move, 100)
+
def change(x, y):
"Change pacman aim if valid."
if valid(pacman + vector(x, y)):
aim.x = x
aim.y = y
+
setup(420, 420, 370, 0)
hideturtle()
tracer(False)
diff --git a/freegames/paint.py b/freegames/paint.py
index b5fb2f2c..4235abcc 100644
--- a/freegames/paint.py
+++ b/freegames/paint.py
@@ -13,6 +13,7 @@
from turtle import *
from freegames import vector
+
def line(start, end):
"Draw line from start to end."
up()
@@ -20,6 +21,7 @@ def line(start, end):
down()
goto(end.x, end.y)
+
def square(start, end):
"Draw square from start to end."
up()
@@ -33,18 +35,22 @@ def square(start, end):
end_fill()
+
def circle(start, end):
"Draw circle from start to end."
pass # TODO
+
def rectangle(start, end):
"Draw rectangle from start to end."
pass # TODO
+
def triangle(start, end):
"Draw triangle from start to end."
pass # TODO
+
def tap(x, y):
"Store starting point or draw shape."
start = state['start']
@@ -57,10 +63,12 @@ def tap(x, y):
shape(start, end)
state['start'] = None
+
def store(key, value):
"Store value in state at key."
state[key] = value
+
state = {'start': None, 'shape': line}
setup(420, 420, 370, 0)
onscreenclick(tap)
diff --git a/freegames/pong.py b/freegames/pong.py
index 0bdd9685..4e6ec456 100644
--- a/freegames/pong.py
+++ b/freegames/pong.py
@@ -16,18 +16,22 @@
from turtle import *
from freegames import vector
+
def value():
"Randomly generate value between (-5, -3) or (3, 5)."
return (3 + random() * 2) * choice([1, -1])
+
ball = vector(0, 0)
aim = vector(value(), value())
state = {1: 0, 2: 0}
+
def move(player, change):
"Move player position by change."
state[player] += change
+
def rectangle(x, y, width, height):
"Draw rectangle at (x, y) with given width and height."
up()
@@ -41,6 +45,7 @@ def rectangle(x, y, width, height):
left(90)
end_fill()
+
def draw():
"Draw game and move pong ball."
clear()
@@ -79,6 +84,7 @@ def draw():
ontimer(draw, 50)
+
setup(420, 420, 370, 0)
hideturtle()
tracer(False)
diff --git a/freegames/simonsays.py b/freegames/simonsays.py
index e922a4ce..312e74a1 100644
--- a/freegames/simonsays.py
+++ b/freegames/simonsays.py
@@ -21,6 +21,7 @@
vector(-200, -200): ('yellow', 'khaki'),
}
+
def grid():
"Draw grid of tiles."
square(0, 0, 200, 'dark red')
@@ -29,6 +30,7 @@ def grid():
square(-200, -200, 200, 'khaki')
update()
+
def flash(tile):
"Flash tile in grid."
glow, dark = tiles[tile]
@@ -39,6 +41,7 @@ def flash(tile):
update()
sleep(0.5)
+
def grow():
"Grow pattern and flash tiles."
tile = choice(list(tiles))
@@ -50,6 +53,7 @@ def grow():
print('Pattern length:', len(pattern))
guesses.clear()
+
def tap(x, y):
"Respond to screen tap."
onscreenclick(None)
@@ -69,11 +73,13 @@ def tap(x, y):
onscreenclick(tap)
+
def start(x, y):
"Start game."
grow()
onscreenclick(tap)
+
setup(420, 420, 370, 0)
hideturtle()
tracer(False)
diff --git a/freegames/snake.py b/freegames/snake.py
index fa6b7c4b..d31953b6 100644
--- a/freegames/snake.py
+++ b/freegames/snake.py
@@ -21,15 +21,18 @@
snake = [vector(10, 0)]#posição inicial da cobra
aim = vector(0,-10) # velocidade/direção da cobra
+
def change(x, y):
"Change snake direction."#"Mudar a direção da cobra."
aim.x = x
aim.y = y
+
def inside(head):
"Return True if head inside boundaries."#"Retorne True se a cabeça estiver dentro dos limites."
return -200 < head.x < 190 and -200 < head.y < 190
+
def move():
"Move snake forward one segment." #Mova a cobra um segmento para frente
head = snake[-1].copy()
@@ -58,6 +61,7 @@ def move():
update()
ontimer(move, 100)
+
setup(420, 420, 370, 0)
hideturtle()
tracer(False)
diff --git a/freegames/tictactoe.py b/freegames/tictactoe.py
index 8bb9dc2a..8857d59b 100644
--- a/freegames/tictactoe.py
+++ b/freegames/tictactoe.py
@@ -12,6 +12,7 @@
from turtle import *
from freegames import line
+
def grid():
"Draw tic-tac-toe grid."
line(-67, 200, -67, -200)
@@ -19,11 +20,13 @@ def grid():
line(-200, -67, 200, -67)
line(-200, 67, 200, 67)
+
def drawx(x, y):
"Draw X player."
line(x, y, x + 133, y + 133)
line(x, y + 133, x + 133, y)
+
def drawo(x, y):
"Draw O player."
up()
@@ -31,13 +34,16 @@ def drawo(x, y):
down()
circle(62)
+
def floor(value):
"Round value down to grid with square size 133."
return ((value + 200) // 133) * 133 - 200
+
state = {'player': 0}
players = [drawx, drawo]
+
def tap(x, y):
"Draw X or O in tapped square."
x = floor(x)
@@ -48,6 +54,7 @@ def tap(x, y):
update()
state['player'] = not player
+
setup(420, 420, 370, 0)
hideturtle()
tracer(False)
diff --git a/freegames/tiles.py b/freegames/tiles.py
index f7671a82..05083d3d 100644
--- a/freegames/tiles.py
+++ b/freegames/tiles.py
@@ -21,6 +21,7 @@
vector(0, -100),
]
+
def load():
"Load tiles and scramble."
count = 1
@@ -43,6 +44,7 @@ def load():
tiles[mark] = number
mark = spot
+
def square(mark, number):
"Draw white square with black outline and number."
up()
@@ -63,6 +65,7 @@ def square(mark, number):
write(number, font=('Arial', 60, 'normal'))
+
def tap(x, y):
"Swap tile and empty square."
x = floor(x, 100)
@@ -79,12 +82,14 @@ def tap(x, y):
tiles[mark] = None
square(mark, None)
+
def draw():
"Draw all tiles."
for mark in tiles:
square(mark, tiles[mark])
update()
+
setup(420, 420, 370, 0)
hideturtle()
tracer(False)
diff --git a/freegames/tron.py b/freegames/tron.py
index cefcc57c..3f1b69e6 100644
--- a/freegames/tron.py
+++ b/freegames/tron.py
@@ -20,10 +20,12 @@
p2aim = vector(-4, 0)
p2body = set()
+
def inside(head):
"Return True if head inside screen."
return -200 < head.x < 200 and -200 < head.y < 200
+
def draw():
"Advance players and draw game."
p1xy.move(p1aim)
@@ -48,6 +50,7 @@ def draw():
update()
ontimer(draw, 50)
+
setup(420, 420, 370, 0)
hideturtle()
tracer(False)
diff --git a/freegames/utils.py b/freegames/utils.py
index 4665a7d4..103d9899 100644
--- a/freegames/utils.py
+++ b/freegames/utils.py
@@ -48,6 +48,7 @@ def path(filename):
def line(a, b, x, y):
"Draw line from `(a, b)` to `(x, y)`."
import turtle
+
turtle.up()
turtle.goto(a, b)
turtle.down()
@@ -61,6 +62,7 @@ def square(x, y, size, name):
"""
import turtle
+
turtle.up()
turtle.goto(x, y)
turtle.down()
@@ -88,6 +90,7 @@ class vector(collections.Sequence):
vector(-2.0, 1.0)
"""
+
# pylint: disable=invalid-name
PRECISION = 6
diff --git a/setup.py b/setup.py
index addb36b4..645b4d06 100644
--- a/setup.py
+++ b/setup.py
@@ -12,8 +12,10 @@ def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True
+
def run_tests(self):
import tox
+
errno = tox.cmdline(self.test_args)
sys.exit(errno)
diff --git a/tests/mockturtle.py b/tests/mockturtle.py
index 5e7d0572..9bb2b019 100644
--- a/tests/mockturtle.py
+++ b/tests/mockturtle.py
@@ -5,6 +5,7 @@
state = {}
events = []
+
class Turtle:
def __init__(self, visible=True):
pass
@@ -78,6 +79,7 @@ def update(self):
def undo(self):
pass
+
_turtle = Turtle()
goto = _turtle.goto
up = _turtle.up
@@ -103,22 +105,28 @@ def undo(self):
update = _turtle.update
undo = _turtle.undo
+
def setup(width, height, x, y):
pass
+
def listen():
pass
+
def onkey(function, key):
state['key ' + key] = function
+
def ontimer(function, delay):
state['timer'] = function
state['delay'] = delay
+
def onscreenclick(function):
state['click'] = function
+
def done():
for event in events:
name = event[0]
diff --git a/tests/test_bagels.py b/tests/test_bagels.py
index 5b24b8b6..9c631592 100644
--- a/tests/test_bagels.py
+++ b/tests/test_bagels.py
@@ -12,6 +12,7 @@ def test_bagels_pass():
with mock.patch.multiple('builtins', **mocks):
runpy.run_module('freegames.bagels')
+
def test_bagels_fail():
random.seed(0)
mock_input = mock.Mock()
diff --git a/tests/test_cannon.py b/tests/test_cannon.py
index cdcdc615..082c4235 100644
--- a/tests/test_cannon.py
+++ b/tests/test_cannon.py
@@ -10,8 +10,6 @@
def test_cannon():
random.seed(0)
mockturtle.events[:] = (
- [('timer',)] * 300
- + [('click', 0, 0)]
- + [('timer', True)] * 3000
+ [('timer',)] * 300 + [('click', 0, 0)] + [('timer', True)] * 3000
)
runpy.run_module('freegames.cannon')
diff --git a/tests/test_crypto.py b/tests/test_crypto.py
index 16b35ac2..2f3a88f7 100644
--- a/tests/test_crypto.py
+++ b/tests/test_crypto.py
@@ -12,6 +12,7 @@ def test_crypto_encrypt():
with mock.patch.multiple('builtins', **mocks):
runpy.run_module('freegames.crypto')
+
def test_crypto_encrypt_bad_key():
random.seed(0)
mock_input = mock.Mock()
@@ -21,6 +22,7 @@ def test_crypto_encrypt_bad_key():
with mock.patch.multiple('builtins', **mocks):
runpy.run_module('freegames.crypto')
+
def test_crypto_bad_command():
random.seed(0)
mock_input = mock.Mock()
@@ -30,6 +32,7 @@ def test_crypto_bad_command():
with mock.patch.multiple('builtins', **mocks):
runpy.run_module('freegames.crypto')
+
def test_crypto_decrypt():
random.seed(0)
mock_input = mock.Mock()
@@ -39,6 +42,7 @@ def test_crypto_decrypt():
with mock.patch.multiple('builtins', **mocks):
runpy.run_module('freegames.crypto')
+
def test_crypto_decode():
random.seed(0)
mock_input = mock.Mock()
diff --git a/tests/test_flappy.py b/tests/test_flappy.py
index 608da5cf..5e6b0173 100644
--- a/tests/test_flappy.py
+++ b/tests/test_flappy.py
@@ -9,15 +9,11 @@
def test_flappy_outside():
random.seed(0)
- mockturtle.events[:] = (
- [('timer', True)] * 300
- )
+ mockturtle.events[:] = [('timer', True)] * 300
runpy.run_module('freegames.flappy')
def test_flappy_collision():
random.seed(0)
- mockturtle.events[:] = (
- ([('timer', True)] * 6 + [('click', 0, 0)]) * 100
- )
+ mockturtle.events[:] = ([('timer', True)] * 6 + [('click', 0, 0)]) * 100
runpy.run_module('freegames.flappy')
diff --git a/tests/test_madlibs.py b/tests/test_madlibs.py
index 56a52508..7e7c4708 100644
--- a/tests/test_madlibs.py
+++ b/tests/test_madlibs.py
@@ -6,8 +6,16 @@
def test_madlibs():
random.seed(0)
mock_input = mock.Mock()
- mock_input.side_effect = ["quick", "brown","lazy","brown","dog","car","jumps"]
+ mock_input.side_effect = [
+ 'quick',
+ 'brown',
+ 'lazy',
+ 'brown',
+ 'dog',
+ 'car',
+ 'jumps',
+ ]
mocks = {'print': lambda *args: None, 'input': mock_input}
with mock.patch.multiple('builtins', **mocks):
- runpy.run_module('freegames.madlibs')
\ No newline at end of file
+ runpy.run_module('freegames.madlibs')
diff --git a/tests/test_main.py b/tests/test_main.py
index d82eb6d3..f85436cd 100644
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -11,6 +11,7 @@ def test_main_list():
with mock.patch('sys.argv', ['__main__.py', 'list']):
runpy.run_module('freegames.__main__')
+
def test_main_copy():
random.seed(0)
mock_open = mock.Mock()
@@ -20,6 +21,7 @@ def test_main_copy():
with mock.patch('builtins.open', mock_open):
runpy.run_module('freegames.__main__')
+
def test_main_copy_error():
cwd = os.getcwd()
path = os.path.join(cwd, 'guess.py')
@@ -33,6 +35,7 @@ def test_main_copy_error():
finally:
os.remove('guess.py')
+
def test_main_show():
random.seed(0)
diff --git a/tests/test_tron.py b/tests/test_tron.py
index 1e9d7362..12753ace 100644
--- a/tests/test_tron.py
+++ b/tests/test_tron.py
@@ -9,16 +9,11 @@
def test_tron_1():
random.seed(0)
- mockturtle.events[:] = (
- [('key a',), ('key a',)]
- + [('timer', True)] * 600
- )
+ mockturtle.events[:] = [('key a',), ('key a',)] + [('timer', True)] * 600
runpy.run_module('freegames.tron')
+
def test_tron_2():
random.seed(0)
- mockturtle.events[:] = (
- [('key j',), ('key j',)]
- + [('timer', True)] * 600
- )
+ mockturtle.events[:] = [('key j',), ('key j',)] + [('timer', True)] * 600
runpy.run_module('freegames.tron')
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 1b0ef11a..435f4638 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -2,6 +2,7 @@
import freegames.utils as utils
+
def test_change_after_hash():
v = utils.vector(0, 0)
hash(v)
@@ -20,6 +21,7 @@ def test_change_after_hash():
with raises(ValueError):
v.rotate(90)
+
def test_not_implemented_paths():
v = utils.vector(0, 0)
assert not (v == 0)
From 9d51ffe4d57dccb4143222bd423b657abfbe7e71 Mon Sep 17 00:00:00 2001
From: Grant Jenks
Date: Mon, 14 Jun 2021 18:16:36 -0700
Subject: [PATCH 40/81] More blue fixes
---
freegames/pacman.py | 3 +++
tests/test_fidget.py | 7 +++----
tests/test_pacman.py | 7 +++----
tests/test_pong.py | 15 +++++++--------
tests/test_snake.py | 12 ++++++++----
5 files changed, 24 insertions(+), 20 deletions(-)
diff --git a/freegames/pacman.py b/freegames/pacman.py
index c2fb3ab1..58e849ea 100644
--- a/freegames/pacman.py
+++ b/freegames/pacman.py
@@ -25,6 +25,7 @@
[vector(100, 160), vector(0, -5)],
[vector(100, -160), vector(-5, 0)],
]
+# fmt: off
tiles = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
@@ -47,6 +48,8 @@
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
]
+# fmt: on
+
def square(x, y):
"Draw square using path at (x, y)."
diff --git a/tests/test_fidget.py b/tests/test_fidget.py
index 5c48655f..62101c0d 100644
--- a/tests/test_fidget.py
+++ b/tests/test_fidget.py
@@ -9,8 +9,7 @@
def test_fidget():
random.seed(0)
- mockturtle.events[:] = (
- [('timer',), ('key space',)] * 30
- + [('timer',)] * 600
- )
+ mockturtle.events.clear()
+ mockturtle.events += [('timer',), ('key space',)] * 30
+ mockturtle.events += [('timer',)] * 600
runpy.run_module('freegames.fidget')
diff --git a/tests/test_pacman.py b/tests/test_pacman.py
index 2990fe1a..b9f8a45a 100644
--- a/tests/test_pacman.py
+++ b/tests/test_pacman.py
@@ -9,8 +9,7 @@
def test_pacman():
random.seed(0)
- mockturtle.events[:] = (
- [('timer', True), ('key Up',)] * 600
- + [('timer', True)] * 3000
- )
+ mockturtle.events.clear()
+ mockturtle.events += [('timer', True), ('key Up',)] * 600
+ mockturtle.events += [('timer', True)] * 3000
runpy.run_module('freegames.pacman')
diff --git a/tests/test_pong.py b/tests/test_pong.py
index e3a0746c..b2809eb3 100644
--- a/tests/test_pong.py
+++ b/tests/test_pong.py
@@ -9,16 +9,15 @@
def test_pong_1():
random.seed(0)
- mockturtle.events[:] = (
- [('timer',), ('key s',)] * 8
- + [('timer', True)] * 600
- )
+ mockturtle.events.clear()
+ mockturtle.events += [('timer',), ('key s',)] * 8
+ mockturtle.events += [('timer', True)] * 600
runpy.run_module('freegames.pong')
+
def test_pong_2():
random.seed(1)
- mockturtle.events[:] = (
- [('timer',), ('key k',)] * 12
- + [('timer', True)] * 600
- )
+ mockturtle.events.clear()
+ mockturtle.events += [('timer',), ('key k',)] * 12
+ mockturtle.events += [('timer', True)] * 600
runpy.run_module('freegames.pong')
diff --git a/tests/test_snake.py b/tests/test_snake.py
index c6f25a14..d08a954a 100644
--- a/tests/test_snake.py
+++ b/tests/test_snake.py
@@ -9,8 +9,12 @@
def test_snake():
random.seed(0)
- mockturtle.events[:] = (
- [('timer',), ('key Left',), ('timer',), ('key Up',)]
- + [('timer', True)] * 300
- )
+ mockturtle.events.clear()
+ mockturtle.events += [
+ ('timer',),
+ ('key Left',),
+ ('timer',),
+ ('key Up',),
+ ]
+ mockturtle.events += [('timer', True)] * 300
runpy.run_module('freegames.snake')
From 543d675b7122a171484b9a7fcb253a7e80e6decc Mon Sep 17 00:00:00 2001
From: Grant Jenks
Date: Mon, 14 Jun 2021 18:19:16 -0700
Subject: [PATCH 41/81] Fixes for docs
---
docs/madlibs.rst | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/docs/madlibs.rst b/docs/madlibs.rst
index 1f0c31f8..359ffbc5 100644
--- a/docs/madlibs.rst
+++ b/docs/madlibs.rst
@@ -1,6 +1,6 @@
Mad Libs
-=====
+========
Create a funny story from a not-so funny story
-.. literalinclude:: ../freegames/madlibs.py
\ No newline at end of file
+.. literalinclude:: ../freegames/madlibs.py
From dd5e621071b4e17f5a2fea1893a15ed1222aea83 Mon Sep 17 00:00:00 2001
From: Grant Jenks
Date: Mon, 14 Jun 2021 18:20:22 -0700
Subject: [PATCH 42/81] isort fixes
---
freegames/ant.py | 1 +
freegames/bounce.py | 1 +
freegames/cannon.py | 1 +
freegames/connect.py | 1 +
freegames/flappy.py | 1 +
freegames/life.py | 1 +
freegames/maze.py | 3 ++-
freegames/memory.py | 1 +
freegames/minesweeper.py | 1 +
freegames/pacman.py | 1 +
freegames/paint.py | 1 +
freegames/pong.py | 1 +
freegames/simonsays.py | 1 +
freegames/snake.py | 3 ++-
freegames/tictactoe.py | 1 +
freegames/tiles.py | 1 +
freegames/tron.py | 1 +
setup.py | 2 +-
tests/test_bounce.py | 2 +-
19 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/freegames/ant.py b/freegames/ant.py
index 2d03bf7c..030a8a16 100644
--- a/freegames/ant.py
+++ b/freegames/ant.py
@@ -11,6 +11,7 @@
from random import *
from turtle import *
+
from freegames import vector
ant = vector(0, 0)
diff --git a/freegames/bounce.py b/freegames/bounce.py
index 7c9fcabb..64910ca8 100644
--- a/freegames/bounce.py
+++ b/freegames/bounce.py
@@ -12,6 +12,7 @@
from random import *
from turtle import *
+
from freegames import vector
diff --git a/freegames/cannon.py b/freegames/cannon.py
index e90ab986..b42e8410 100644
--- a/freegames/cannon.py
+++ b/freegames/cannon.py
@@ -11,6 +11,7 @@
from random import randrange
from turtle import *
+
from freegames import vector
ball = vector(-200, -200)
diff --git a/freegames/connect.py b/freegames/connect.py
index 5fcf8e8d..a5d103df 100644
--- a/freegames/connect.py
+++ b/freegames/connect.py
@@ -11,6 +11,7 @@
"""
from turtle import *
+
from freegames import line
turns = {'red': 'yellow', 'yellow': 'red'}
diff --git a/freegames/flappy.py b/freegames/flappy.py
index 1bfd341d..4aec8aaf 100644
--- a/freegames/flappy.py
+++ b/freegames/flappy.py
@@ -11,6 +11,7 @@
from random import *
from turtle import *
+
from freegames import vector
bird = vector(0, 0)
diff --git a/freegames/life.py b/freegames/life.py
index 912595cc..8c0bb3aa 100644
--- a/freegames/life.py
+++ b/freegames/life.py
@@ -14,6 +14,7 @@
from random import choice
from turtle import *
+
from freegames import square
cells = {}
diff --git a/freegames/maze.py b/freegames/maze.py
index 24a23bf0..f90b6b9f 100644
--- a/freegames/maze.py
+++ b/freegames/maze.py
@@ -8,8 +8,9 @@
"""
-from turtle import *
from random import random
+from turtle import *
+
from freegames import line
diff --git a/freegames/memory.py b/freegames/memory.py
index f5a0ee5c..80bc62e8 100644
--- a/freegames/memory.py
+++ b/freegames/memory.py
@@ -12,6 +12,7 @@
from random import *
from turtle import *
+
from freegames import path
car = path('car.gif')
diff --git a/freegames/minesweeper.py b/freegames/minesweeper.py
index 87b772ca..44efa68e 100644
--- a/freegames/minesweeper.py
+++ b/freegames/minesweeper.py
@@ -10,6 +10,7 @@
from random import randrange, seed
from turtle import *
+
from freegames import floor, square
seed(0)
diff --git a/freegames/pacman.py b/freegames/pacman.py
index 58e849ea..2bc70d2f 100644
--- a/freegames/pacman.py
+++ b/freegames/pacman.py
@@ -12,6 +12,7 @@
from random import choice
from turtle import *
+
from freegames import floor, vector
state = {'score': 0}
diff --git a/freegames/paint.py b/freegames/paint.py
index 4235abcc..0a7b167e 100644
--- a/freegames/paint.py
+++ b/freegames/paint.py
@@ -11,6 +11,7 @@
"""
from turtle import *
+
from freegames import vector
diff --git a/freegames/pong.py b/freegames/pong.py
index 4e6ec456..faf0efd0 100644
--- a/freegames/pong.py
+++ b/freegames/pong.py
@@ -14,6 +14,7 @@
from random import choice, random
from turtle import *
+
from freegames import vector
diff --git a/freegames/simonsays.py b/freegames/simonsays.py
index 312e74a1..c1aa4733 100644
--- a/freegames/simonsays.py
+++ b/freegames/simonsays.py
@@ -10,6 +10,7 @@
from random import choice
from time import sleep
from turtle import *
+
from freegames import floor, square, vector
pattern = []
diff --git a/freegames/snake.py b/freegames/snake.py
index d31953b6..5b3ce20c 100644
--- a/freegames/snake.py
+++ b/freegames/snake.py
@@ -13,8 +13,9 @@
4. Mude a cobra para responder às teclas de seta FEITO
"""
-from turtle import *
from random import randrange
+from turtle import *
+
from freegames import square, vector
food = vector(0, 0) #posição inicial da comida
diff --git a/freegames/tictactoe.py b/freegames/tictactoe.py
index 8857d59b..b7a4a2d2 100644
--- a/freegames/tictactoe.py
+++ b/freegames/tictactoe.py
@@ -10,6 +10,7 @@
"""
from turtle import *
+
from freegames import line
diff --git a/freegames/tiles.py b/freegames/tiles.py
index 05083d3d..11aef296 100644
--- a/freegames/tiles.py
+++ b/freegames/tiles.py
@@ -11,6 +11,7 @@
from random import *
from turtle import *
+
from freegames import floor, vector
tiles = {}
diff --git a/freegames/tron.py b/freegames/tron.py
index 3f1b69e6..5b4cbb58 100644
--- a/freegames/tron.py
+++ b/freegames/tron.py
@@ -10,6 +10,7 @@
"""
from turtle import *
+
from freegames import square, vector
p1xy = vector(-100, 0)
diff --git a/setup.py b/setup.py
index 645b4d06..c4f12aaa 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,7 @@
import io
-import setuptools as st
import sys
+import setuptools as st
from setuptools.command.test import test as TestCommand
import freegames
diff --git a/tests/test_bounce.py b/tests/test_bounce.py
index d397163c..5cad045a 100644
--- a/tests/test_bounce.py
+++ b/tests/test_bounce.py
@@ -1,7 +1,7 @@
import random
import runpy
-import turtle
import sys
+import turtle
import mockturtle
From ff2d9f340f007921b13168d4e689340819d122d8 Mon Sep 17 00:00:00 2001
From: Grant Jenks
Date: Tue, 15 Jun 2021 14:25:50 -0400
Subject: [PATCH 43/81] Add tests for minesweeper
---
tests/test_minesweeper.py | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
create mode 100644 tests/test_minesweeper.py
diff --git a/tests/test_minesweeper.py b/tests/test_minesweeper.py
new file mode 100644
index 00000000..2c4e5e53
--- /dev/null
+++ b/tests/test_minesweeper.py
@@ -0,0 +1,23 @@
+import random
+import runpy
+import sys
+import unittest.mock as mock
+
+import mockturtle
+
+sys.modules['turtle'] = sys.modules['mockturtle']
+
+
+def test_minesweeper():
+ random.seed(0)
+ mockturtle.events[:] = (
+ ('click', 175, -175),
+ ('click', -75, -75),
+ ('click', 125, 125),
+ )
+
+ try:
+ with mock.patch('time.sleep', lambda delay: None):
+ runpy.run_module('freegames.minesweeper')
+ except SystemExit:
+ pass
From dffc986faf5a7419d798a1c77e2f5aacf518ee76 Mon Sep 17 00:00:00 2001
From: Grant Jenks
Date: Tue, 15 Jun 2021 14:26:01 -0400
Subject: [PATCH 44/81] Simplify ant game
---
freegames/ant.py | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/freegames/ant.py b/freegames/ant.py
index 030a8a16..d83c7168 100644
--- a/freegames/ant.py
+++ b/freegames/ant.py
@@ -36,14 +36,12 @@ def draw():
goto(ant.x, ant.y)
dot(4)
- if running:
- ontimer(draw, 100)
+ ontimer(draw, 100)
setup(420, 420, 370, 0)
hideturtle()
tracer(False)
up()
-running = True
draw()
done()
From b001400f2bc2b9323c1d379a9ea6f394d52b080e Mon Sep 17 00:00:00 2001
From: Grant Jenks
Date: Tue, 15 Jun 2021 14:26:24 -0400
Subject: [PATCH 45/81] Simplify crypto branching
---
freegames/crypto.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/freegames/crypto.py b/freegames/crypto.py
index f89e52ac..92e0805b 100644
--- a/freegames/crypto.py
+++ b/freegames/crypto.py
@@ -30,7 +30,8 @@ def encrypt(message, key):
if letter.isupper():
base = ord('A')
- elif letter.islower():
+ else:
+ assert letter.islower()
base = ord('a')
# The encryption equation:
From 60cbce26729f0906c6597cba1a4ca5cc98fecfe6 Mon Sep 17 00:00:00 2001
From: Grant Jenks
Date: Tue, 15 Jun 2021 14:26:36 -0400
Subject: [PATCH 46/81] Collections abc deprecation warning
---
freegames/utils.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/freegames/utils.py b/freegames/utils.py
index 103d9899..edf96cbe 100644
--- a/freegames/utils.py
+++ b/freegames/utils.py
@@ -3,7 +3,7 @@
"""
# pylint: disable=no-member
-import collections
+import collections.abc
import math
import os
@@ -76,7 +76,7 @@ def square(x, y, size, name):
turtle.end_fill()
-class vector(collections.Sequence):
+class vector(collections.abc.Sequence):
"""Two-dimensional vector.
Vectors can be modified in-place.
From 422fe9e2aa9995b1c9aebcd8ebf484a14cd31295 Mon Sep 17 00:00:00 2001
From: Grant Jenks
Date: Tue, 15 Jun 2021 14:26:50 -0400
Subject: [PATCH 47/81] Test colors
---
tests/test_paint.py | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tests/test_paint.py b/tests/test_paint.py
index 4da7ff7d..492d648f 100644
--- a/tests/test_paint.py
+++ b/tests/test_paint.py
@@ -10,18 +10,23 @@
def test_paint():
random.seed(0)
mockturtle.events[:] = [
+ ('key K',),
('key l',),
('click', 0, 0),
('click', 10, 10),
+ ('key W',),
('key s',),
('click', 20, 20),
('click', 30, 30),
+ ('key G',),
('key c',),
('click', 30, 30),
('click', 40, 40),
+ ('key B',),
('key r',),
('click', 30, 30),
('click', 40, 40),
+ ('key R',),
('key t',),
('click', 30, 30),
('click', 40, 40),
From 4ea8f371c60d20b748b6e6297ece08ced7c05510 Mon Sep 17 00:00:00 2001
From: Grant Jenks
Date: Tue, 15 Jun 2021 14:26:57 -0400
Subject: [PATCH 48/81] Test back-and-forth
---
tests/test_pong.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tests/test_pong.py b/tests/test_pong.py
index b2809eb3..c3500585 100644
--- a/tests/test_pong.py
+++ b/tests/test_pong.py
@@ -10,7 +10,8 @@
def test_pong_1():
random.seed(0)
mockturtle.events.clear()
- mockturtle.events += [('timer',), ('key s',)] * 8
+ mockturtle.events += [('timer',), ('key s',)] * 12
+ mockturtle.events += [('timer',), ('key w',)] * 4
mockturtle.events += [('timer', True)] * 600
runpy.run_module('freegames.pong')
@@ -18,6 +19,7 @@ def test_pong_1():
def test_pong_2():
random.seed(1)
mockturtle.events.clear()
- mockturtle.events += [('timer',), ('key k',)] * 12
+ mockturtle.events += [('timer',), ('key k',)] * 18
+ mockturtle.events += [('timer',), ('key i',)] * 6
mockturtle.events += [('timer', True)] * 600
runpy.run_module('freegames.pong')
From a57e992905615b4b92080f05aa530fb01eebe552 Mon Sep 17 00:00:00 2001
From: Grant Jenks
Date: Tue, 15 Jun 2021 14:27:08 -0400
Subject: [PATCH 49/81] Add test for going in a circle
---
tests/test_snake.py | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tests/test_snake.py b/tests/test_snake.py
index d08a954a..2b12276e 100644
--- a/tests/test_snake.py
+++ b/tests/test_snake.py
@@ -15,6 +15,14 @@ def test_snake():
('key Left',),
('timer',),
('key Up',),
+ ('timer',),
+ ('key Right',),
+ ('timer',),
+ ('key Down',),
+ ('timer',),
+ ('key Left',),
+ ('timer',),
+ ('key Up',),
]
mockturtle.events += [('timer', True)] * 300
runpy.run_module('freegames.snake')
From 5db91c357e049878385f7382ac4404b21a6254b1 Mon Sep 17 00:00:00 2001
From: Grant Jenks
Date: Tue, 15 Jun 2021 14:27:26 -0400
Subject: [PATCH 50/81] Go back-and-forth
---
tests/test_tron.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/tests/test_tron.py b/tests/test_tron.py
index 12753ace..0d871d16 100644
--- a/tests/test_tron.py
+++ b/tests/test_tron.py
@@ -9,11 +9,15 @@
def test_tron_1():
random.seed(0)
- mockturtle.events[:] = [('key a',), ('key a',)] + [('timer', True)] * 600
+ mockturtle.events.clear()
+ mockturtle.events += [('key a',), ('key d',), ('key a',)]
+ mockturtle.events += [('timer', True)] * 600
runpy.run_module('freegames.tron')
def test_tron_2():
random.seed(0)
- mockturtle.events[:] = [('key j',), ('key j',)] + [('timer', True)] * 600
+ mockturtle.events.clear()
+ mockturtle.events += [('key j',), ('key l',), ('key j',)]
+ mockturtle.events += [('timer', True)] * 600
runpy.run_module('freegames.tron')
From 0aad683ddc4282639bdccd234da7d0cf53b4605f Mon Sep 17 00:00:00 2001
From: Grant Jenks
Date: Tue, 15 Jun 2021 14:27:58 -0400
Subject: [PATCH 51/81] Remove flake8 and simplify switches
---
tox.ini | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/tox.ini b/tox.ini
index 2ac9f335..76758969 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
[tox]
-envlist=bluecheck,doc8,docs,isortcheck,flake8,rstcheck,py36,py37,py38,py39
+envlist=bluecheck,doc8,docs,isortcheck,rstcheck,py36,py37,py38,py39
skip_missing_interpreters=True
[testenv]
@@ -7,7 +7,7 @@ deps=
coverage
pytest
pytest-cov
-commands=python -m pytest -v --cov freegames --cov-report term-missing tests
+commands=pytest tests
setenv=
PYTHONPATH={toxinidir}:{toxinidir}/tests
@@ -30,10 +30,6 @@ commands=make html
deps=
sphinx
-[testenv:flake8]
-commands=flake8 {toxinidir}/setup.py {toxinidir}/freegames {toxinidir}/tests
-deps=flake8
-
[testenv:isort]
commands=isort {toxinidir}/setup.py {toxinidir}/freegames {toxinidir}/tests
deps=isort
@@ -43,7 +39,7 @@ commands=isort --check {toxinidir}/setup.py {toxinidir}/freegames {toxinidir}/te
deps=isort
[testenv:rstcheck]
-commands=rstcheck {toxinidir}/README.rst
+commands=rstcheck --report warning {toxinidir}/README.rst
deps=rstcheck
[testenv:uploaddocs]
@@ -63,8 +59,6 @@ line_length = 79
[pytest]
addopts=
- -n auto
- --cov-branch
--cov-fail-under=100
--cov-report=term-missing
--cov=freegames
From a3b91ad37d8de503ee73c5e97c6029c44dcab252 Mon Sep 17 00:00:00 2001
From: Grant Jenks
Date: Tue, 15 Jun 2021 14:34:50 -0400
Subject: [PATCH 52/81] Remove flake8 and test on Windows and MacOS
---
.github/workflows/integration.yml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml
index 1e9295c9..ab2c0aa2 100644
--- a/.github/workflows/integration.yml
+++ b/.github/workflows/integration.yml
@@ -13,9 +13,9 @@ jobs:
checks:
runs-on: ubuntu-latest
strategy:
- max-parallel: 6
+ max-parallel: 5
matrix:
- check: [bluecheck, doc8, docs, isortcheck, flake8, rstcheck]
+ check: [bluecheck, doc8, docs, isortcheck, rstcheck]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
@@ -35,7 +35,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
- os: [ubuntu-latest]
+ os: [ubuntu-latest, windows-latest, macos-latest]
python-version: [3.6, 3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v2
From ffe6c88710d8efb56638b96a4aa414b0dea9b3e4 Mon Sep 17 00:00:00 2001
From: Grant Jenks
Date: Tue, 15 Jun 2021 14:40:33 -0400
Subject: [PATCH 53/81] Update project urls and classifiers
---
setup.py | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/setup.py b/setup.py
index c4f12aaa..ed4ee8c6 100644
--- a/setup.py
+++ b/setup.py
@@ -29,15 +29,22 @@ def run_tests(self):
version=freegames.__version__,
description='Free Games',
long_description=readme,
+ long_description_content_type='text/x-rst',
author='Grant Jenks',
author_email='contact@grantjenks.com',
url='http://www.grantjenks.com/docs/freegames/',
+ license='Apache 2.0',
packages=['freegames'],
include_package_data=True,
tests_require=['tox'],
cmdclass={'test': Tox},
- license='Apache 2.0',
install_requires=[],
+ project_urls={
+ 'Documentation': 'http://www.grantjenks.com/docs/freegames/',
+ 'Funding': 'http://gum.co/freegames',
+ 'Source': 'https://github.com/grantjenks/free-python-games',
+ 'Tracker': 'https://github.com/grantjenks/free-python-games/issues',
+ },
classifiers=(
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Education',
@@ -46,10 +53,10 @@ def run_tests(self):
'Natural Language :: English',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
- 'Programming Language :: Python :: 3.4',
- 'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
+ 'Programming Language :: Python :: 3.8',
+ 'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: Implementation :: CPython',
'Topic :: Games/Entertainment',
'Topic :: Games/Entertainment :: Arcade',
From 23b8eedca0d99ffbf4ae93d844885e6ccf45a92c Mon Sep 17 00:00:00 2001
From: Grant Jenks
Date: Tue, 15 Jun 2021 14:50:05 -0400
Subject: [PATCH 54/81] Windows %$#@!
---
.github/workflows/integration.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml
index ab2c0aa2..88d91c48 100644
--- a/.github/workflows/integration.yml
+++ b/.github/workflows/integration.yml
@@ -35,7 +35,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
- os: [ubuntu-latest, windows-latest, macos-latest]
+ os: [ubuntu-latest]
python-version: [3.6, 3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v2
From 0a3b4a1688ab464e91d05e6226fdbe193f5582d1 Mon Sep 17 00:00:00 2001
From: Grant Jenks
Date: Tue, 15 Jun 2021 14:54:51 -0400
Subject: [PATCH 55/81] Update copyright to 2021
---
README.rst | 2 +-
freegames/__init__.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.rst b/README.rst
index 3efddd88..cef360bf 100644
--- a/README.rst
+++ b/README.rst
@@ -334,7 +334,7 @@ References
Free Python Games License
-------------------------
-Copyright 2017-2020 Grant Jenks
+Copyright 2017-2021 Grant Jenks
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
diff --git a/freegames/__init__.py b/freegames/__init__.py
index 8cc4db82..76449978 100644
--- a/freegames/__init__.py
+++ b/freegames/__init__.py
@@ -67,4 +67,4 @@
__build__ = 0x020302
__author__ = 'Grant Jenks'
__license__ = 'Apache 2.0'
-__copyright__ = '2017-2020, Grant Jenks'
+__copyright__ = '2017-2021, Grant Jenks'
From 31197f005da7fae6cd33780d81bab5f2012c0e73 Mon Sep 17 00:00:00 2001
From: Grant Jenks
Date: Tue, 15 Jun 2021 14:57:16 -0400
Subject: [PATCH 56/81] Add replit file for support
---
.replit | 2 ++
1 file changed, 2 insertions(+)
create mode 100644 .replit
diff --git a/.replit b/.replit
new file mode 100644
index 00000000..fc2fa361
--- /dev/null
+++ b/.replit
@@ -0,0 +1,2 @@
+language = "python3"
+run = ""
From a7a3604637aee026edf656641d495729fc2ca8b4 Mon Sep 17 00:00:00 2001
From: Grant Jenks
Date: Tue, 15 Jun 2021 14:59:44 -0400
Subject: [PATCH 57/81] Remove replit, don't want to grant GitHub access
---
.replit | 2 --
1 file changed, 2 deletions(-)
delete mode 100644 .replit
diff --git a/.replit b/.replit
deleted file mode 100644
index fc2fa361..00000000
--- a/.replit
+++ /dev/null
@@ -1,2 +0,0 @@
-language = "python3"
-run = ""
From 2f4358b11bc5953fdaeb3662436a6b5f402182b3 Mon Sep 17 00:00:00 2001
From: Grant Jenks
Date: Tue, 15 Jun 2021 15:09:21 -0400
Subject: [PATCH 58/81] Align isort and blue line lengths
---
tox.ini | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tox.ini b/tox.ini
index 76758969..91a15c5b 100644
--- a/tox.ini
+++ b/tox.ini
@@ -55,7 +55,7 @@ include_trailing_comma = True
force_grid_wrap = 0
use_parentheses = True
ensure_newline_before_comments = True
-line_length = 79
+line_length = 80
[pytest]
addopts=
From dcb2e3b92e54fe126ad6c6ef5889ceb4757cdc28 Mon Sep 17 00:00:00 2001
From: Adorilson Bezerra
Date: Wed, 13 Oct 2021 11:33:05 -0300
Subject: [PATCH 59/81] Update documentation about Pacman OO version
---
README.rst | 3 ++-
docs/index.rst | 1 +
docs/pacman_oop.rst | 6 ++++++
3 files changed, 9 insertions(+), 1 deletion(-)
create mode 100644 docs/pacman_oop.rst
diff --git a/README.rst b/README.rst
index cef360bf..659ad5ff 100644
--- a/README.rst
+++ b/README.rst
@@ -155,12 +155,13 @@ Pacman
......
`Pacman`_ -- classic arcade game. Use the arrow keys to navigate and eat all
-the white food. Watch out for red ghosts that roam the maze.
+the white food. Watch out for red ghosts that roam the maze. (`OO version`_)
.. image:: http://www.grantjenks.com/docs/freegames/_static/pacman.gif
:alt: Pacman Free Python Game
.. _`Pacman`: http://www.grantjenks.com/docs/freegames/pacman.html
+.. _`OO version`: pacman_oop.html
Cannon
......
diff --git a/docs/index.rst b/docs/index.rst
index 0af26523..65ac44c7 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -26,5 +26,6 @@
connect
memory
pacman
+ pacman_oop
fidget
madlibs
diff --git a/docs/pacman_oop.rst b/docs/pacman_oop.rst
new file mode 100644
index 00000000..de3fbc06
--- /dev/null
+++ b/docs/pacman_oop.rst
@@ -0,0 +1,6 @@
+Pacman
+======
+
+Pacman, classic arcade game.
+
+.. literalinclude:: ../freegames/pacman_oop.py
From f4a1329e5d978e6c3d6ee3bad92a85dd694ebe3b Mon Sep 17 00:00:00 2001
From: Breno
Date: Sat, 27 Feb 2021 16:58:51 -0300
Subject: [PATCH 60/81] addition of pacman_oop.py
---
freegames/pacman_oop.py | 192 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 192 insertions(+)
create mode 100644 freegames/pacman_oop.py
diff --git a/freegames/pacman_oop.py b/freegames/pacman_oop.py
new file mode 100644
index 00000000..fb9f6e48
--- /dev/null
+++ b/freegames/pacman_oop.py
@@ -0,0 +1,192 @@
+"""Pacman, classic arcade game.
+
+Exercises
+
+1. Change the board.
+2. Change the number of ghosts.
+3. Change where pacman starts.
+4. Make the ghosts faster/slower.
+5. Make the ghosts smarter.
+
+"""
+
+from random import choice
+from turtle import bgcolor, clear, up, down, goto, Turtle, dot, update, ontimer, setup, hideturtle, tracer, listen, onkey, done
+from freegames import floor, vector
+
+class Pacman:
+ def __init__(self):
+ self.aim = vector(5, 0)
+ self.direction = "WEST"
+ self.position = vector(-40, -80)#PACMAM
+
+ def offset(self,point):
+ "Return offset of point in tiles."
+ "Retorne o deslocamento do ponto nos blocos."
+ x = (floor(point.x, 20) + 200) / 20
+ y = (180 - floor(point.y, 20)) / 20
+ index = int(x + y * 20)
+ return index
+
+ def valid(self,point):
+ "Return True if point is valid in tiles."
+ "Retorne True se o ponto for válido em tiles."
+ index = offset(point)
+
+ if tiles[index] == 0:
+ return False
+
+ index = offset(point + 19)
+
+ if tiles[index] == 0:
+ return False
+
+ return point.x % 20 == 0 or point.y % 20 == 0
+
+ def move_pacma(self):
+ "Move pacman and all ghosts."
+ "Mova Pacman e todos os fantasmas."
+ writer.undo() # desfaz o que foi feito anteriormente
+ writer.write(state['score'])#update do score
+
+ clear()
+ # move-se se nao houver parede
+ if valid(pacman + aim):
+ pacman.move(aim)
+
+ index = offset(pacman)
+ # verifica o caminho e move-se adiante
+ if tiles[index] == 1:
+ tiles[index] = 2
+ state['score'] += 1
+ x = (index % 20) * 20 - 200
+ y = 180 - (index // 20) * 20
+ square(x, y)
+
+ up()
+ goto(pacman.x + 10, pacman.y + 10)
+ dot(20, 'yellow')#desenha um circulo
+
+
+
+class Ghosts:
+ def __init__(self):
+ self.position = [vector(-180, 160), vector(5, 0)]
+
+ def move_ghosts(self):
+ for point, course in ghosts:
+ if valid(point + course):
+ point.move(course)
+ else:
+ options = [
+ vector(5, 0),
+ vector(-5, 0),
+ vector(0, 5),
+ vector(0, -5),
+ ]
+ plan = choice(options)
+ course.x = plan.x
+ course.y = plan.y
+
+ up()
+ goto(point.x + 10, point.y + 10)
+ dot(20, 'red')
+
+ update()
+
+class GamePacman:
+
+ def __init__(self):
+ self.state = {'score': 0} #GAME
+ self.path = Turtle(visible=False) #caminho
+ self.writer = Turtle(visible=False)#estritor ?
+ self.pacman = Pacman()
+ self.ghosts = Ghosts()
+
+ onkey(lambda: change(5, 0), 'Right')
+ onkey(lambda: change(-5, 0), 'Left')
+ onkey(lambda: change(0, 5), 'Up')
+ onkey(lambda: change(0, -5), 'Down')
+
+ tiles = [
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
+ 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0,
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
+ 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0,
+ 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0,
+ 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
+ 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0,
+ 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
+ 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0,
+ 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0,
+ 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
+ 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
+ 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0,
+ 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0,
+ 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0,
+ 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ ]
+
+ def world():
+ "Draw world using path."
+ "Desenhe o mundo usando o caminho."
+ bgcolor('black')
+ path.color('blue')
+
+ for index in range(len(tiles)):
+ tile = tiles[index]
+
+ if tile > 0:
+ x = (index % 20) * 20 - 200
+ y = 180 - (index // 20) * 20
+ square(x, y)
+
+ if tile == 1:
+ path.up()
+ path.goto(x + 10, y + 10)
+ path.dot(2, 'white')
+ def square(x, y):
+ "Draw square using path at (x, y)."
+ "Desenhe um quadrado usando o caminho em (x, y)."
+ path.up()
+ path.goto(x, y)#move o pincel ate a posição
+ path.down()
+ path.begin_fill()#chamado antes de desenhar uma forma
+
+ for count in range(4):
+ path.forward(20)
+ path.left(90)
+
+ path.end_fill()
+ update()
+
+ for point, course in ghosts:
+ if abs(pacman - point) < 20:
+ return
+
+ ontimer(move, 100)
+ def change(x, y):
+ "Change pacman aim if valid."
+ "Mude o objetivo do pacman se for válido."
+ if valid(pacman + vector(x, y)):
+ aim.x = x
+ aim.y = y
+def init():
+ setup(420, 420, 370, 0)
+ hideturtle()
+ tracer(False)
+ game = GamePacman()
+ game.writer.goto(160, 160)
+ game.writer.color('white')
+ game.writer.write(state['score'])
+ listen()
+ game.world()
+ #move()
+ done()
+
+if __name__ == '__main__':
+ init()
From 1c21ca5f73ee206bace66178dac62595b7a938b5 Mon Sep 17 00:00:00 2001
From: Breno
Date: Thu, 11 Mar 2021 16:49:52 -0300
Subject: [PATCH 61/81] part two refactoring in pacman_oop.py
---
freegames/pacman_oop.py | 218 +++++++++++++++++++---------------------
1 file changed, 106 insertions(+), 112 deletions(-)
diff --git a/freegames/pacman_oop.py b/freegames/pacman_oop.py
index fb9f6e48..477ebe9f 100644
--- a/freegames/pacman_oop.py
+++ b/freegames/pacman_oop.py
@@ -14,66 +14,23 @@
from turtle import bgcolor, clear, up, down, goto, Turtle, dot, update, ontimer, setup, hideturtle, tracer, listen, onkey, done
from freegames import floor, vector
+
class Pacman:
def __init__(self):
self.aim = vector(5, 0)
self.direction = "WEST"
- self.position = vector(-40, -80)#PACMAM
-
- def offset(self,point):
- "Return offset of point in tiles."
- "Retorne o deslocamento do ponto nos blocos."
- x = (floor(point.x, 20) + 200) / 20
- y = (180 - floor(point.y, 20)) / 20
- index = int(x + y * 20)
- return index
-
- def valid(self,point):
- "Return True if point is valid in tiles."
- "Retorne True se o ponto for válido em tiles."
- index = offset(point)
-
- if tiles[index] == 0:
- return False
+ self.position = vector(-40, -80)
+ self.status = "ALIVE"
- index = offset(point + 19)
-
- if tiles[index] == 0:
- return False
-
- return point.x % 20 == 0 or point.y % 20 == 0
-
- def move_pacma(self):
- "Move pacman and all ghosts."
- "Mova Pacman e todos os fantasmas."
- writer.undo() # desfaz o que foi feito anteriormente
- writer.write(state['score'])#update do score
-
- clear()
- # move-se se nao houver parede
- if valid(pacman + aim):
- pacman.move(aim)
-
- index = offset(pacman)
- # verifica o caminho e move-se adiante
- if tiles[index] == 1:
- tiles[index] = 2
- state['score'] += 1
- x = (index % 20) * 20 - 200
- y = 180 - (index // 20) * 20
- square(x, y)
-
- up()
- goto(pacman.x + 10, pacman.y + 10)
- dot(20, 'yellow')#desenha um circulo
-
-
-
-class Ghosts:
+ def move(self,aim):
+ "Change pacman aim if valid."
+ self.position.move(aim)
+class Ghost:
def __init__(self):
self.position = [vector(-180, 160), vector(5, 0)]
- def move_ghosts(self):
+ def move(self):
+
for point, course in ghosts:
if valid(point + course):
point.move(course)
@@ -87,28 +44,21 @@ def move_ghosts(self):
plan = choice(options)
course.x = plan.x
course.y = plan.y
-
- up()
- goto(point.x + 10, point.y + 10)
- dot(20, 'red')
+ up()
+ goto(point.x + 10, point.y + 10)
+ dot(20, 'red')
update()
class GamePacman:
-
def __init__(self):
- self.state = {'score': 0} #GAME
- self.path = Turtle(visible=False) #caminho
- self.writer = Turtle(visible=False)#estritor ?
+ self.state = {'score': 0}
+ self.path = Turtle(visible=False)
+ self.writer = Turtle(visible=False)
self.pacman = Pacman()
- self.ghosts = Ghosts()
-
- onkey(lambda: change(5, 0), 'Right')
- onkey(lambda: change(-5, 0), 'Left')
- onkey(lambda: change(0, 5), 'Up')
- onkey(lambda: change(0, -5), 'Down')
-
- tiles = [
+ self.ghost = Ghost()
+ self.aim = vector(5,0)
+ self.tiles = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0,
@@ -129,64 +79,108 @@ def __init__(self):
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- ]
+ ]
+
+ onkey(lambda: self.change(5,0), 'Right')
+ onkey(lambda: self.change(-5, 0), 'Left')
+ onkey(lambda: self.change(0, 5), 'Up')
+ onkey(lambda: self.change(0, -5), 'Down')
+ def square(self,x,y):
+ self.path.up()
+ self.path.goto(x,y)
+ self.path.down()
+ self.path.begin_fill()
- def world():
- "Draw world using path."
- "Desenhe o mundo usando o caminho."
- bgcolor('black')
- path.color('blue')
+ for count in range(4):
+ self.path.forward(20)
+ self.path.left(90)
+
+ self.path.end_fill()
+
+ def offset(self,point):
+ x = (floor(point.x, 20) + 200) / 20
+ y = (180 - floor(point.y, 20)) / 20
+ index = int(x + y * 20)
+ return index
- for index in range(len(tiles)):
- tile = tiles[index]
+ def valid(self,point):
+ "Return True if point is valid in tiles."
+ index = self.offset(point)
+ self.pacman.move(self.pacman.aim)
+
+ if self.tiles[index] == 0:
+ return False
+
+ index = self.offset(point + 19)
+
+ if self.tiles[index] == 0:
+ return False
+
+ return point.x % 20 == 0 or point.y % 20 == 0
- if tile > 0:
+ def change(self,x,y):
+ if self.valid(self.pacman.position + vector(x, y)):
+ self.pacman.aim.x = x
+ self.pacman.aim.y = y
+
+
+ def draw_world(self):
+ bgcolor('black')
+ self.path.color('blue')
+
+ for index in range(len(self.tiles)):
+ tile = self.tiles[index]
+ if tile> 0:
x = (index % 20) * 20 - 200
y = 180 - (index // 20) * 20
- square(x, y)
-
+ self.square(x,y)
+
if tile == 1:
- path.up()
- path.goto(x + 10, y + 10)
- path.dot(2, 'white')
- def square(x, y):
- "Draw square using path at (x, y)."
- "Desenhe um quadrado usando o caminho em (x, y)."
- path.up()
- path.goto(x, y)#move o pincel ate a posição
- path.down()
- path.begin_fill()#chamado antes de desenhar uma forma
+ self.path.up()
+ self.path.goto(x + 10, y + 10)
+ self.path.dot(2, 'white')
+
+ def draw_score(self):
+ self.writer.goto(160, 160)
+ self.writer.color('white')
+ self.writer.write(self.state['score'])
+
- for count in range(4):
- path.forward(20)
- path.left(90)
+
+ def run(self):
+ clear()
+ if self.valid(self.pacman.position + self.aim):
+ self.pacman.move(self.pacman.aim)
+ index = self.offset(self.pacman.aim)
- path.end_fill()
- update()
+ if self.tiles[index] == 1:
+ self.tiles[index] = 2
+ self.state['score'] += 1
+ x = (index % 20) * 20 - 200
+ y = 180 - (index // 20) * 20
+ self.square(x, y)
+ self.draw_world()
+ self.draw_score()
- for point, course in ghosts:
- if abs(pacman - point) < 20:
- return
-
- ontimer(move, 100)
- def change(x, y):
- "Change pacman aim if valid."
- "Mude o objetivo do pacman se for válido."
- if valid(pacman + vector(x, y)):
- aim.x = x
- aim.y = y
+ up()
+ goto(self.pacman.aim.x + 10, self.pacman.aim.y + 10)
+ dot(20,'yellow')
+
+
+ update()
+ ontimer(self.run, 100)
+
def init():
setup(420, 420, 370, 0)
hideturtle()
tracer(False)
- game = GamePacman()
- game.writer.goto(160, 160)
- game.writer.color('white')
- game.writer.write(state['score'])
listen()
- game.world()
- #move()
- done()
+ game = GamePacman()
+ game.run()
+ done()
+
if __name__ == '__main__':
init()
+
+
From 2eacab7f92129cfba13cba704bdc0b17879854f1 Mon Sep 17 00:00:00 2001
From: Breno
Date: Sun, 14 Mar 2021 17:23:18 -0300
Subject: [PATCH 62/81] part three refactoring in pacman_oop.py
---
freegames/pacman_oop.py | 97 +++++++++++++++++++++++++----------------
1 file changed, 59 insertions(+), 38 deletions(-)
diff --git a/freegames/pacman_oop.py b/freegames/pacman_oop.py
index 477ebe9f..c0095766 100644
--- a/freegames/pacman_oop.py
+++ b/freegames/pacman_oop.py
@@ -22,33 +22,18 @@ def __init__(self):
self.position = vector(-40, -80)
self.status = "ALIVE"
- def move(self,aim):
+ def move(self):
"Change pacman aim if valid."
- self.position.move(aim)
-class Ghost:
- def __init__(self):
- self.position = [vector(-180, 160), vector(5, 0)]
+ self.position.move(self.aim)
+class Ghost:
+ def __init__(self,x,y,w,z):
+ self.position = vector(x,y)
+ self.aim = vector(w, z)
+ self.color = "red"
def move(self):
-
- for point, course in ghosts:
- if valid(point + course):
- point.move(course)
- else:
- options = [
- vector(5, 0),
- vector(-5, 0),
- vector(0, 5),
- vector(0, -5),
- ]
- plan = choice(options)
- course.x = plan.x
- course.y = plan.y
- up()
- goto(point.x + 10, point.y + 10)
- dot(20, 'red')
+ self.position.move(self.aim)
- update()
class GamePacman:
def __init__(self):
@@ -56,7 +41,11 @@ def __init__(self):
self.path = Turtle(visible=False)
self.writer = Turtle(visible=False)
self.pacman = Pacman()
- self.ghost = Ghost()
+ self.ghost1 = Ghost(-180,160,5,0)
+ self.ghost2 = Ghost(-180,-160,0,5)
+ self.ghost3 = Ghost(100,160,0,-5)
+ self.ghost4 = Ghost(100,160,-5,0)
+ ghosts = [self.ghost1,self.ghost2,self.ghost3,self.ghost4]
self.aim = vector(5,0)
self.tiles = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -81,7 +70,7 @@ def __init__(self):
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
]
- onkey(lambda: self.change(5,0), 'Right')
+ onkey(lambda: self.change(5, 0), 'Right')
onkey(lambda: self.change(-5, 0), 'Left')
onkey(lambda: self.change(0, 5), 'Up')
onkey(lambda: self.change(0, -5), 'Down')
@@ -106,7 +95,6 @@ def offset(self,point):
def valid(self,point):
"Return True if point is valid in tiles."
index = self.offset(point)
- self.pacman.move(self.pacman.aim)
if self.tiles[index] == 0:
return False
@@ -134,7 +122,7 @@ def draw_world(self):
x = (index % 20) * 20 - 200
y = 180 - (index // 20) * 20
self.square(x,y)
-
+
if tile == 1:
self.path.up()
self.path.goto(x + 10, y + 10)
@@ -144,14 +132,23 @@ def draw_score(self):
self.writer.goto(160, 160)
self.writer.color('white')
self.writer.write(self.state['score'])
-
-
+
+ def draw_pacman(self):
+ up()
+ goto(self.pacman.position.x +10 , self.pacman.position.y + 10)
+ dot(20,'yellow')
def run(self):
+
+ self.writer.undo()
+ self.draw_score()
+
clear()
- if self.valid(self.pacman.position + self.aim):
- self.pacman.move(self.pacman.aim)
- index = self.offset(self.pacman.aim)
+
+ if self.valid(self.pacman.position + self.pacman.aim):
+ self.pacman.move()
+ print("moveu-se",self.pacman.position)
+ index = self.offset(self.pacman.position)
if self.tiles[index] == 1:
self.tiles[index] = 2
@@ -159,16 +156,39 @@ def run(self):
x = (index % 20) * 20 - 200
y = 180 - (index // 20) * 20
self.square(x, y)
- self.draw_world()
- self.draw_score()
+
+ self.draw_pacman()
+
+ update()
+ ontimer(self.run, 100)
+
+ '''# ghost aim
+ for point, course in ghosts:
+ if valid(point + course):
+ point.move(course)
+ else:
+ options = [
+ vector(5, 0),
+ vector(-5, 0),
+ vector(0, 5),
+ vector(0, -5),
+ ]
+ plan = choice(options)
+ course.x = plan.x
+ course.y = plan.y
up()
- goto(self.pacman.aim.x + 10, self.pacman.aim.y + 10)
- dot(20,'yellow')
+ goto(point.x + 10, point.y + 10)
+ dot(20, 'red')
+
+ update()
+
+ for point, course in ghosts:
+ if abs(pacman - point) < 20:
+ return'''
+
- update()
- ontimer(self.run, 100)
def init():
setup(420, 420, 370, 0)
@@ -177,6 +197,7 @@ def init():
listen()
game = GamePacman()
+ game.draw_world()
game.run()
done()
From a797254565af0ca66e15e05cb4e301ff661e4a3b Mon Sep 17 00:00:00 2001
From: Breno
Date: Sun, 14 Mar 2021 23:40:52 -0300
Subject: [PATCH 63/81] correction of move function
---
freegames/pacman_oop.py | 111 +++++++++++++++++++++-------------------
1 file changed, 58 insertions(+), 53 deletions(-)
diff --git a/freegames/pacman_oop.py b/freegames/pacman_oop.py
index c0095766..e74cc22e 100644
--- a/freegames/pacman_oop.py
+++ b/freegames/pacman_oop.py
@@ -23,8 +23,13 @@ def __init__(self):
self.status = "ALIVE"
def move(self):
- "Change pacman aim if valid."
self.position.move(self.aim)
+
+ def dead(self):
+ self.status = "DEAD"
+
+ def alive(self):
+ return self.status != "DEAD"
class Ghost:
def __init__(self,x,y,w,z):
@@ -41,12 +46,10 @@ def __init__(self):
self.path = Turtle(visible=False)
self.writer = Turtle(visible=False)
self.pacman = Pacman()
- self.ghost1 = Ghost(-180,160,5,0)
- self.ghost2 = Ghost(-180,-160,0,5)
- self.ghost3 = Ghost(100,160,0,-5)
- self.ghost4 = Ghost(100,160,-5,0)
- ghosts = [self.ghost1,self.ghost2,self.ghost3,self.ghost4]
- self.aim = vector(5,0)
+ self.ghosts = [Ghost(-180,160,5,0),
+ Ghost(-180,-160,0,5),
+ Ghost(100,160,0,-5),
+ Ghost(100,-160,-5,0)]
self.tiles = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
@@ -74,6 +77,7 @@ def __init__(self):
onkey(lambda: self.change(-5, 0), 'Left')
onkey(lambda: self.change(0, 5), 'Up')
onkey(lambda: self.change(0, -5), 'Down')
+
def square(self,x,y):
self.path.up()
self.path.goto(x,y)
@@ -132,24 +136,8 @@ def draw_score(self):
self.writer.goto(160, 160)
self.writer.color('white')
self.writer.write(self.state['score'])
-
- def draw_pacman(self):
- up()
- goto(self.pacman.position.x +10 , self.pacman.position.y + 10)
- dot(20,'yellow')
-
- def run(self):
-
- self.writer.undo()
- self.draw_score()
- clear()
-
- if self.valid(self.pacman.position + self.pacman.aim):
- self.pacman.move()
- print("moveu-se",self.pacman.position)
index = self.offset(self.pacman.position)
-
if self.tiles[index] == 1:
self.tiles[index] = 2
self.state['score'] += 1
@@ -157,51 +145,68 @@ def run(self):
y = 180 - (index // 20) * 20
self.square(x, y)
- self.draw_pacman()
-
- update()
- ontimer(self.run, 100)
+
+ def move_and_draw_pacman(self):
- '''# ghost aim
- for point, course in ghosts:
- if valid(point + course):
- point.move(course)
- else:
- options = [
- vector(5, 0),
- vector(-5, 0),
- vector(0, 5),
- vector(0, -5),
- ]
- plan = choice(options)
- course.x = plan.x
- course.y = plan.y
+ if self.valid(self.pacman.position + self.pacman.aim):
+ self.pacman.move()
+ print("moveu-se",self.pacman.position)
up()
- goto(point.x + 10, point.y + 10)
- dot(20, 'red')
+ goto(self.pacman.position.x +10 , self.pacman.position.y + 10)
+ dot(20,'yellow')
+
- update()
+ def move_and_draw_ghost(self):
+ for ghost in self.ghosts:
+ if self.valid(ghost.position + ghost.aim):
+ ghost.move()
+ else:
+ options = [
+ vector(5, 0),
+ vector(-5, 0),
+ vector(0, 5),
+ vector(0, -5),
+ ]
+ plan = choice(options)
+ ghost.aim.x = plan.x
+ ghost.aim.y = plan.y
+
+ up()
+ goto(ghost.position.x + 10, ghost.position.y + 10)
+ dot(20, 'red')
- for point, course in ghosts:
- if abs(pacman - point) < 20:
- return'''
+ def run(self):
+ self.writer.undo()
+ self.draw_score()
+ clear()
+
+ self.move_and_draw_pacman()
+
+ self.move_and_draw_ghost()
+
+ if self.pacman.alive():
+ ontimer(self.run, 100)
+ else:
+ return
+
+ for ghost in self.ghosts:
+ if abs(self.pacman.position - ghost.position) < 20:
+ self.pacman.dead()
+
+ update()
-
-
def init():
setup(420, 420, 370, 0)
hideturtle()
tracer(False)
listen()
-
+
game = GamePacman()
game.draw_world()
game.run()
done()
if __name__ == '__main__':
- init()
-
-
+ init()
\ No newline at end of file
From 8ccadc3b2684d2c96a9fcfae9d9400656191b295 Mon Sep 17 00:00:00 2001
From: Breno
Date: Tue, 16 Mar 2021 03:36:10 -0300
Subject: [PATCH 64/81] addition of the compass-oriented system
---
freegames/pacman_oop.py | 177 +++++++++++++++++++++++++++++++---------
1 file changed, 139 insertions(+), 38 deletions(-)
diff --git a/freegames/pacman_oop.py b/freegames/pacman_oop.py
index e74cc22e..2c0baa35 100644
--- a/freegames/pacman_oop.py
+++ b/freegames/pacman_oop.py
@@ -14,11 +14,10 @@
from turtle import bgcolor, clear, up, down, goto, Turtle, dot, update, ontimer, setup, hideturtle, tracer, listen, onkey, done
from freegames import floor, vector
-
class Pacman:
def __init__(self):
self.aim = vector(5, 0)
- self.direction = "WEST"
+ self.direction = "EAST"
self.position = vector(-40, -80)
self.status = "ALIVE"
@@ -31,6 +30,57 @@ def dead(self):
def alive(self):
return self.status != "DEAD"
+ def left(self):
+ if self.direction == "NORTH" :
+ self.aim.x = -5
+ self.aim.y = 0
+
+ elif self.direction == "SOUTH":
+ self.aim.x = 5
+ self.aim.y = 0
+
+ elif self.direction == "WEST" :
+ self.aim.x = 0
+ self.aim.y = -5
+
+ elif self.direction == "EAST":
+ self.aim.x = 0
+ self.aim.y = 5
+
+ def right(self):
+ if self.direction == "NORTH" :
+ self.aim.x = 5
+ self.aim.y = 0
+
+ elif self.direction == "SOUTH":
+ self.aim.x = -5
+ self.aim.y = 0
+
+ elif self.direction == "WEST" :
+ self.aim.x = 0
+ self.aim.y = 5
+
+ elif self.direction == "EAST":
+ self.aim.x = 0
+ self.aim.y = -5
+
+ def u_turn(self):
+ if self.direction == "NORTH" :
+ self.aim.x = 0
+ self.aim.y = -5
+
+ elif self.direction == "SOUTH":
+ self.aim.x = 0
+ self.aim.y = 5
+
+ elif self.direction == "WEST" :
+ self.aim.x = 5
+ self.aim.y = 0
+
+ elif self.direction == "EAST":
+ self.aim.x = -5
+ self.aim.y = 0
+
class Ghost:
def __init__(self,x,y,w,z):
self.position = vector(x,y)
@@ -38,7 +88,17 @@ def __init__(self,x,y,w,z):
self.color = "red"
def move(self):
self.position.move(self.aim)
-
+
+ def change_direction(self):
+ options = [
+ vector(5, 0),
+ vector(-5, 0),
+ vector(0, 5),
+ vector(0, -5),
+ ]
+ plan = choice(options)
+ self.aim.x = plan.x
+ self.aim.y = plan.y
class GamePacman:
def __init__(self):
@@ -72,11 +132,52 @@ def __init__(self):
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
]
-
- onkey(lambda: self.change(5, 0), 'Right')
- onkey(lambda: self.change(-5, 0), 'Left')
- onkey(lambda: self.change(0, 5), 'Up')
- onkey(lambda: self.change(0, -5), 'Down')
+ self.draw_world()
+
+ onkey(lambda: self.on_rightkeypressed() , 'Right')
+ onkey(lambda: self.on_leftkeypressed(), 'Left')
+ onkey(lambda: self.on_upkeypressed(), 'Up')
+ onkey(lambda: self.on_downkeypressed(), 'Down')
+
+ def on_rightkeypressed(self):
+ if self.pacman_next_position(5,0):
+ if self.pacman.direction == 'NORTH':
+ self.pacman.right()
+ elif self.pacman.direction == "SOUTH":
+ self.pacman.left()
+ elif self.pacman.direction == "WEST":
+ self.pacman.u_turn()
+ self.pacman.direction = "EAST"
+
+ def on_leftkeypressed(self):
+ if self.pacman_next_position(-5,0):
+ if self.pacman.direction == 'NORTH':
+ self.pacman.left()
+ elif self.pacman.direction == "SOUTH":
+ self.pacman.right()
+ elif self.pacman.direction == "EAST":
+ self.pacman.u_turn()
+ self.pacman.direction = "WEST"
+
+ def on_upkeypressed(self):
+ if self.pacman_next_position(0,5):
+ if self.pacman.direction == 'WEST':
+ self.pacman.right()
+ elif self.pacman.direction == "EAST":
+ self.pacman.left()
+ if self.pacman.direction == "SOUTH":
+ self.pacman.u_turn()
+ self.pacman.direction = "NORTH"
+
+ def on_downkeypressed (self):
+ if self.pacman_next_position(0,-5):
+ if self.pacman.direction == 'WEST':
+ self.pacman.left()
+ elif self.pacman.direction == "EAST":
+ self.pacman.right()
+ elif self.pacman.direction == "NORTH":
+ self.pacman.u_turn()
+ self.pacman.direction = "SOUTH"
def square(self,x,y):
self.path.up()
@@ -109,13 +210,19 @@ def valid(self,point):
return False
return point.x % 20 == 0 or point.y % 20 == 0
-
- def change(self,x,y):
- if self.valid(self.pacman.position + vector(x, y)):
- self.pacman.aim.x = x
- self.pacman.aim.y = y
-
+ def pacman_next_position(self, x=None, y=None):
+ if x != None and y != None:
+ if self.valid(self.pacman.position + vector(x, y)):
+ return True
+ else:
+ return False
+ else:
+ if self.valid(self.pacman.position + self.pacman.aim):
+ return True
+ else:
+ return False
+
def draw_world(self):
bgcolor('black')
self.path.color('blue')
@@ -144,57 +251,52 @@ def draw_score(self):
x = (index % 20) * 20 - 200
y = 180 - (index // 20) * 20
self.square(x, y)
-
-
- def move_and_draw_pacman(self):
- if self.valid(self.pacman.position + self.pacman.aim):
- self.pacman.move()
- print("moveu-se",self.pacman.position)
+ def move_pacman(self):
+ self.pacman.move()
+ def draw_pacman(self):
up()
- goto(self.pacman.position.x +10 , self.pacman.position.y + 10)
+ goto(self.pacman.position.x +10 , self.pacman.position.y + 10)
dot(20,'yellow')
-
def move_and_draw_ghost(self):
for ghost in self.ghosts:
if self.valid(ghost.position + ghost.aim):
ghost.move()
else:
- options = [
- vector(5, 0),
- vector(-5, 0),
- vector(0, 5),
- vector(0, -5),
- ]
- plan = choice(options)
- ghost.aim.x = plan.x
- ghost.aim.y = plan.y
+ ghost.change_direction()
up()
goto(ghost.position.x + 10, ghost.position.y + 10)
dot(20, 'red')
+ def check_collision(self):
+ for ghost in self.ghosts:
+ if abs(self.pacman.position - ghost.position) < 20:
+ self.pacman.dead()
+
def run(self):
self.writer.undo()
self.draw_score()
clear()
-
- self.move_and_draw_pacman()
+
+ if self.pacman_next_position():
+ self.move_pacman()
+ self.draw_pacman()
+ else:
+ self.draw_pacman()
self.move_and_draw_ghost()
+ self.check_collision()
+
if self.pacman.alive():
ontimer(self.run, 100)
else:
return
- for ghost in self.ghosts:
- if abs(self.pacman.position - ghost.position) < 20:
- self.pacman.dead()
-
update()
def init():
@@ -204,7 +306,6 @@ def init():
listen()
game = GamePacman()
- game.draw_world()
game.run()
done()
From 765da6c135b7149c73d0f47e94c9b6fcf29b9eb7 Mon Sep 17 00:00:00 2001
From: Breno
Date: Tue, 16 Mar 2021 23:09:43 -0300
Subject: [PATCH 65/81] correction of the compass-oriented system
---
freegames/pacman_oop.py | 133 +++++++++++++++-------------------------
1 file changed, 49 insertions(+), 84 deletions(-)
diff --git a/freegames/pacman_oop.py b/freegames/pacman_oop.py
index 2c0baa35..9b0ef7fa 100644
--- a/freegames/pacman_oop.py
+++ b/freegames/pacman_oop.py
@@ -25,67 +25,53 @@ def move(self):
self.position.move(self.aim)
def dead(self):
- self.status = "DEAD"
+ self.status = "DIE"
def alive(self):
- return self.status != "DEAD"
+ return self.status != "DIE"
+
+ def next_position(self, aim=None):
+ if aim != None :
+ new_position = self.position + aim
+ else:
+ new_position = self.position + self.aim
+ return new_position
- def left(self):
- if self.direction == "NORTH" :
- self.aim.x = -5
- self.aim.y = 0
+ turn_to_left = {'NORTH': ('WEST', vector(-5, 0)),
+ 'WEST' : ('SOUTH', vector(0, -5)),
+ 'SOUTH': ('EAST', vector(5, 0)),
+ 'EAST' : ('NORTH', vector(0, 5))}
- elif self.direction == "SOUTH":
- self.aim.x = 5
- self.aim.y = 0
+ turn_to_right = {'NORTH': ('EAST', vector(5, 0)),
+ 'EAST' : ('SOUTH', vector(0, -5)),
+ 'SOUTH': ('WEST', vector(-5, 0)),
+ 'WEST' : ('NORTH', vector(0, 5))}
- elif self.direction == "WEST" :
- self.aim.x = 0
- self.aim.y = -5
+ turn_to_go_back = {'NORTH': ('SOUTH', vector(0, -5)),
+ 'SOUTH' : ('NORTH', vector(0, 5)),
+ 'WEST': ('EAST', vector(5, 0)),
+ 'EAST' : ('WEST', vector(-5, 0))}
- elif self.direction == "EAST":
- self.aim.x = 0
- self.aim.y = 5
+ def left(self):
+ self.direction, new_aim = self.turn_to_left[self.direction]
+ self.aim.x = new_aim.x
+ self.aim.y = new_aim.y
def right(self):
- if self.direction == "NORTH" :
- self.aim.x = 5
- self.aim.y = 0
-
- elif self.direction == "SOUTH":
- self.aim.x = -5
- self.aim.y = 0
-
- elif self.direction == "WEST" :
- self.aim.x = 0
- self.aim.y = 5
-
- elif self.direction == "EAST":
- self.aim.x = 0
- self.aim.y = -5
+ self.direction, new_aim = self.turn_to_right[self.direction]
+ self.aim.x = new_aim.x
+ self.aim.y = new_aim.y
def u_turn(self):
- if self.direction == "NORTH" :
- self.aim.x = 0
- self.aim.y = -5
-
- elif self.direction == "SOUTH":
- self.aim.x = 0
- self.aim.y = 5
-
- elif self.direction == "WEST" :
- self.aim.x = 5
- self.aim.y = 0
-
- elif self.direction == "EAST":
- self.aim.x = -5
- self.aim.y = 0
-
+ self.direction, new_aim = self.turn_to_go_back[self.direction]
+ self.aim.x = new_aim.x
+ self.aim.y = new_aim.y
+
class Ghost:
- def __init__(self,x,y,w,z):
- self.position = vector(x,y)
- self.aim = vector(w, z)
- self.color = "red"
+ def __init__(self,position_x,position_y,aim_x,aim_y):
+ self.position = vector(position_x,position_y)
+ self.aim = vector(aim_x, aim_y)
+
def move(self):
self.position.move(self.aim)
@@ -96,9 +82,7 @@ def change_direction(self):
vector(0, 5),
vector(0, -5),
]
- plan = choice(options)
- self.aim.x = plan.x
- self.aim.y = plan.y
+ self.aim = choice(options)
class GamePacman:
def __init__(self):
@@ -140,44 +124,41 @@ def __init__(self):
onkey(lambda: self.on_downkeypressed(), 'Down')
def on_rightkeypressed(self):
- if self.pacman_next_position(5,0):
+ if self.valid(self.pacman.next_position(vector(5,0))):
if self.pacman.direction == 'NORTH':
self.pacman.right()
elif self.pacman.direction == "SOUTH":
self.pacman.left()
elif self.pacman.direction == "WEST":
self.pacman.u_turn()
- self.pacman.direction = "EAST"
def on_leftkeypressed(self):
- if self.pacman_next_position(-5,0):
+ if self.valid(self.pacman.next_position (vector(-5,0))):
if self.pacman.direction == 'NORTH':
self.pacman.left()
elif self.pacman.direction == "SOUTH":
self.pacman.right()
elif self.pacman.direction == "EAST":
self.pacman.u_turn()
- self.pacman.direction = "WEST"
+
def on_upkeypressed(self):
- if self.pacman_next_position(0,5):
+ if self.valid(self.pacman.next_position(vector(0,5))):
if self.pacman.direction == 'WEST':
self.pacman.right()
elif self.pacman.direction == "EAST":
self.pacman.left()
- if self.pacman.direction == "SOUTH":
+ elif self.pacman.direction == "SOUTH":
self.pacman.u_turn()
- self.pacman.direction = "NORTH"
def on_downkeypressed (self):
- if self.pacman_next_position(0,-5):
+ if self.valid(self.pacman.next_position(vector(0,-5))):
if self.pacman.direction == 'WEST':
self.pacman.left()
elif self.pacman.direction == "EAST":
self.pacman.right()
elif self.pacman.direction == "NORTH":
self.pacman.u_turn()
- self.pacman.direction = "SOUTH"
def square(self,x,y):
self.path.up()
@@ -210,19 +191,7 @@ def valid(self,point):
return False
return point.x % 20 == 0 or point.y % 20 == 0
-
- def pacman_next_position(self, x=None, y=None):
- if x != None and y != None:
- if self.valid(self.pacman.position + vector(x, y)):
- return True
- else:
- return False
- else:
- if self.valid(self.pacman.position + self.pacman.aim):
- return True
- else:
- return False
-
+
def draw_world(self):
bgcolor('black')
self.path.color('blue')
@@ -252,10 +221,10 @@ def draw_score(self):
y = 180 - (index // 20) * 20
self.square(x, y)
- def move_pacman(self):
- self.pacman.move()
+ def move_and_draw_pacman(self):
+ if self.valid(self.pacman.next_position()):
+ self.pacman.move()
- def draw_pacman(self):
up()
goto(self.pacman.position.x +10 , self.pacman.position.y + 10)
dot(20,'yellow')
@@ -281,12 +250,8 @@ def run(self):
self.writer.undo()
self.draw_score()
clear()
-
- if self.pacman_next_position():
- self.move_pacman()
- self.draw_pacman()
- else:
- self.draw_pacman()
+
+ self.move_and_draw_pacman()
self.move_and_draw_ghost()
From c901faaf33e04cd87a0e3f751f3255c3a37268eb Mon Sep 17 00:00:00 2001
From: Breno
Date: Wed, 24 Mar 2021 17:18:47 -0300
Subject: [PATCH 66/81] addition of object-oriented activities and relolution
---
freegames/pacman_oop.py | 127 ++++++++++++++++++++++++++--------------
1 file changed, 83 insertions(+), 44 deletions(-)
diff --git a/freegames/pacman_oop.py b/freegames/pacman_oop.py
index 9b0ef7fa..fc104265 100644
--- a/freegames/pacman_oop.py
+++ b/freegames/pacman_oop.py
@@ -2,11 +2,11 @@
Exercises
-1. Change the board.
-2. Change the number of ghosts.
-3. Change where pacman starts.
-4. Make the ghosts faster/slower.
-5. Make the ghosts smarter.
+1. Move the score variable/attribute to Pacman's class. This attribute must be incremented by a new method in Pacman's code. Chose draw_score according to the needed changes in GamePacman.
+2. Create a speed attribute and do the needed changes to change Pacman's speed according to its value.
+3. Create a subclass of Ghosts that each one of them has ghosts with different speeds value (Use the second exercise as an example).
+4. Create a superclass for both Pacman and Ghost.
+5. Create different types of food.
"""
@@ -14,21 +14,30 @@
from turtle import bgcolor, clear, up, down, goto, Turtle, dot, update, ontimer, setup, hideturtle, tracer, listen, onkey, done
from freegames import floor, vector
-class Pacman:
- def __init__(self):
- self.aim = vector(5, 0)
+class Master:
+ speed = 1
+ def __init__(self,position_x, position_y,aim_x,aim_y):
+ self.position = vector(position_x,position_y)
+ self.aim = vector(aim_x, aim_y)
+
+ def move(self):
+ self.position.move(self.aim * self.speed)
+
+class Pacman(Master):
+ score = 0
+ def __init__(self,position_x, position_y,aim_x,aim_y):
+ super().__init__(position_x, position_y,aim_x,aim_y)
self.direction = "EAST"
- self.position = vector(-40, -80)
- self.status = "ALIVE"
+ self.state = "ALIVE"
- def move(self):
- self.position.move(self.aim)
-
- def dead(self):
- self.status = "DIE"
+ def eat(self):
+ self.score +=1
+
+ def die(self):
+ self.state = "DEAD"
def alive(self):
- return self.status != "DIE"
+ return self.state != "DEAD"
def next_position(self, aim=None):
if aim != None :
@@ -47,33 +56,24 @@ def next_position(self, aim=None):
'SOUTH': ('WEST', vector(-5, 0)),
'WEST' : ('NORTH', vector(0, 5))}
- turn_to_go_back = {'NORTH': ('SOUTH', vector(0, -5)),
+ turn_to_around = {'NORTH': ('SOUTH', vector(0, -5)),
'SOUTH' : ('NORTH', vector(0, 5)),
'WEST': ('EAST', vector(5, 0)),
'EAST' : ('WEST', vector(-5, 0))}
def left(self):
self.direction, new_aim = self.turn_to_left[self.direction]
- self.aim.x = new_aim.x
- self.aim.y = new_aim.y
+ self.aim = new_aim
def right(self):
self.direction, new_aim = self.turn_to_right[self.direction]
- self.aim.x = new_aim.x
- self.aim.y = new_aim.y
+ self.aim = new_aim
- def u_turn(self):
- self.direction, new_aim = self.turn_to_go_back[self.direction]
- self.aim.x = new_aim.x
- self.aim.y = new_aim.y
+ def turn_around(self):
+ self.direction, new_aim = self.turn_to_around[self.direction]
+ self.aim = new_aim
-class Ghost:
- def __init__(self,position_x,position_y,aim_x,aim_y):
- self.position = vector(position_x,position_y)
- self.aim = vector(aim_x, aim_y)
-
- def move(self):
- self.position.move(self.aim)
+class Ghost(Master):
def change_direction(self):
options = [
@@ -84,16 +84,39 @@ def change_direction(self):
]
self.aim = choice(options)
+class FastGhost(Ghost):
+ speed = 2
+
+class SlowGhost(Ghost):
+ speed = 0.5
+
+class Food:
+ def __init__(self, x=None, y=None):
+ self.position = vector(x,y)
+ self.color = "yellow"
+ self.state = "ABSENT"
+
+ def captured(self):
+ self.state = "ABSENT"
+
+ def with_food(self):
+ self.state = "PRESENT"
+
+ def without_food(self):
+ if self.state == "ABSENT":
+ return True
+
class GamePacman:
def __init__(self):
self.state = {'score': 0}
self.path = Turtle(visible=False)
self.writer = Turtle(visible=False)
- self.pacman = Pacman()
+ self.pacman = Pacman(-40, -80, 5, 0)
+ self.food = Food(-160,100)
self.ghosts = [Ghost(-180,160,5,0),
- Ghost(-180,-160,0,5),
- Ghost(100,160,0,-5),
- Ghost(100,-160,-5,0)]
+ FastGhost(-180,-160,0,5),
+ SlowGhost(100,160,0,-5),
+ FastGhost(100,-160,-5,0)]
self.tiles = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
@@ -130,7 +153,7 @@ def on_rightkeypressed(self):
elif self.pacman.direction == "SOUTH":
self.pacman.left()
elif self.pacman.direction == "WEST":
- self.pacman.u_turn()
+ self.pacman.turn_around()
def on_leftkeypressed(self):
if self.valid(self.pacman.next_position (vector(-5,0))):
@@ -139,7 +162,7 @@ def on_leftkeypressed(self):
elif self.pacman.direction == "SOUTH":
self.pacman.right()
elif self.pacman.direction == "EAST":
- self.pacman.u_turn()
+ self.pacman.turn_around()
def on_upkeypressed(self):
@@ -149,7 +172,7 @@ def on_upkeypressed(self):
elif self.pacman.direction == "EAST":
self.pacman.left()
elif self.pacman.direction == "SOUTH":
- self.pacman.u_turn()
+ self.pacman.turn_around()
def on_downkeypressed (self):
if self.valid(self.pacman.next_position(vector(0,-5))):
@@ -158,7 +181,7 @@ def on_downkeypressed (self):
elif self.pacman.direction == "EAST":
self.pacman.right()
elif self.pacman.direction == "NORTH":
- self.pacman.u_turn()
+ self.pacman.turn_around()
def square(self,x,y):
self.path.up()
@@ -215,11 +238,22 @@ def draw_score(self):
index = self.offset(self.pacman.position)
if self.tiles[index] == 1:
+ self.pacman.eat()
self.tiles[index] = 2
- self.state['score'] += 1
+ self.state['score'] = self.pacman.score
x = (index % 20) * 20 - 200
y = 180 - (index // 20) * 20
self.square(x, y)
+
+ def create_and_draw_food(self):
+ foods_positions = [vector(-180,150),vector(-180,-150),vector(100,150),vector(100,-150)]
+ if self.food.without_food() == True:
+ self.food.position = choice(foods_positions)
+ if self.valid(self.food.position):
+ up()
+ goto(self.food.position.x + 10, self.food.position.y + 10)
+ dot(10,self.food.color)
+ self.food.with_food()
def move_and_draw_pacman(self):
if self.valid(self.pacman.next_position()):
@@ -243,8 +277,11 @@ def move_and_draw_ghost(self):
def check_collision(self):
for ghost in self.ghosts:
if abs(self.pacman.position - ghost.position) < 20:
- self.pacman.dead()
-
+ self.pacman.die()
+ if abs(self.pacman.position - self.food.position) < 20:
+ self.pacman.score += 2
+ self.food.captured()
+
def run(self):
self.writer.undo()
@@ -256,6 +293,8 @@ def run(self):
self.move_and_draw_ghost()
self.check_collision()
+
+ self.create_and_draw_food()
if self.pacman.alive():
ontimer(self.run, 100)
@@ -275,4 +314,4 @@ def init():
done()
if __name__ == '__main__':
- init()
\ No newline at end of file
+ init()
From 523849c4d01e61c13c83466e530933b9c99d2e6b Mon Sep 17 00:00:00 2001
From: Breno
Date: Wed, 31 Mar 2021 03:47:16 -0300
Subject: [PATCH 67/81] change from 'Master to 'Actor' and add foor atribute
---
freegames/pacman_oop.py | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/freegames/pacman_oop.py b/freegames/pacman_oop.py
index fc104265..b424ca03 100644
--- a/freegames/pacman_oop.py
+++ b/freegames/pacman_oop.py
@@ -2,9 +2,11 @@
Exercises
-1. Move the score variable/attribute to Pacman's class. This attribute must be incremented by a new method in Pacman's code. Chose draw_score according to the needed changes in GamePacman.
+1. Move the score variable/attribute to Pacman's class. This attribute must be incremented by a new method in Pacman's code.
+ Chose draw_score according to the needed changes in GamePacman.
2. Create a speed attribute and do the needed changes to change Pacman's speed according to its value.
-3. Create a subclass of Ghosts that each one of them has ghosts with different speeds value (Use the second exercise as an example).
+3. Create a subclass of Ghosts that each one of them has ghosts
+ with different speeds value (Use the second exercise as an example).
4. Create a superclass for both Pacman and Ghost.
5. Create different types of food.
@@ -14,7 +16,7 @@
from turtle import bgcolor, clear, up, down, goto, Turtle, dot, update, ontimer, setup, hideturtle, tracer, listen, onkey, done
from freegames import floor, vector
-class Master:
+class Actor:
speed = 1
def __init__(self,position_x, position_y,aim_x,aim_y):
self.position = vector(position_x,position_y)
@@ -23,15 +25,15 @@ def __init__(self,position_x, position_y,aim_x,aim_y):
def move(self):
self.position.move(self.aim * self.speed)
-class Pacman(Master):
- score = 0
+class Pacman(Actor):
+ speed = 0
def __init__(self,position_x, position_y,aim_x,aim_y):
- super().__init__(position_x, position_y,aim_x,aim_y)
+ super().__init__(position_x, position_y, aim_x, aim_y)
self.direction = "EAST"
self.state = "ALIVE"
- def eat(self):
- self.score +=1
+ def eat(self, power):
+ self.score += power
def die(self):
self.state = "DEAD"
@@ -73,7 +75,7 @@ def turn_around(self):
self.direction, new_aim = self.turn_to_around[self.direction]
self.aim = new_aim
-class Ghost(Master):
+class Ghost(Actor):
def change_direction(self):
options = [
@@ -91,6 +93,7 @@ class SlowGhost(Ghost):
speed = 0.5
class Food:
+ power = 5
def __init__(self, x=None, y=None):
self.position = vector(x,y)
self.color = "yellow"
@@ -164,7 +167,6 @@ def on_leftkeypressed(self):
elif self.pacman.direction == "EAST":
self.pacman.turn_around()
-
def on_upkeypressed(self):
if self.valid(self.pacman.next_position(vector(0,5))):
if self.pacman.direction == 'WEST':
@@ -279,7 +281,7 @@ def check_collision(self):
if abs(self.pacman.position - ghost.position) < 20:
self.pacman.die()
if abs(self.pacman.position - self.food.position) < 20:
- self.pacman.score += 2
+ self.pacman.eat(self.food.power)
self.food.captured()
def run(self):
From da65165314d4f4e738c79a294f52994d5a2f8e9a Mon Sep 17 00:00:00 2001
From: Breno
Date: Wed, 31 Mar 2021 16:56:56 -0300
Subject: [PATCH 68/81] change in the game point counting method
---
freegames/pacman_oop.py | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/freegames/pacman_oop.py b/freegames/pacman_oop.py
index b424ca03..2f8c6611 100644
--- a/freegames/pacman_oop.py
+++ b/freegames/pacman_oop.py
@@ -18,6 +18,7 @@
class Actor:
speed = 1
+ score = 0
def __init__(self,position_x, position_y,aim_x,aim_y):
self.position = vector(position_x,position_y)
self.aim = vector(aim_x, aim_y)
@@ -26,14 +27,15 @@ def move(self):
self.position.move(self.aim * self.speed)
class Pacman(Actor):
- speed = 0
+ speed = 1
+ score = {'score': 0}
def __init__(self,position_x, position_y,aim_x,aim_y):
super().__init__(position_x, position_y, aim_x, aim_y)
self.direction = "EAST"
self.state = "ALIVE"
- def eat(self, power):
- self.score += power
+ def eat(self, food):
+ self.score['score'] += food
def die(self):
self.state = "DEAD"
@@ -111,7 +113,6 @@ def without_food(self):
class GamePacman:
def __init__(self):
- self.state = {'score': 0}
self.path = Turtle(visible=False)
self.writer = Turtle(visible=False)
self.pacman = Pacman(-40, -80, 5, 0)
@@ -236,16 +237,16 @@ def draw_world(self):
def draw_score(self):
self.writer.goto(160, 160)
self.writer.color('white')
- self.writer.write(self.state['score'])
+ self.writer.write(self.pacman.score['score'])
+
+
- index = self.offset(self.pacman.position)
- if self.tiles[index] == 1:
- self.pacman.eat()
+ def clear_map(self,index):
self.tiles[index] = 2
- self.state['score'] = self.pacman.score
x = (index % 20) * 20 - 200
y = 180 - (index // 20) * 20
self.square(x, y)
+
def create_and_draw_food(self):
foods_positions = [vector(-180,150),vector(-180,-150),vector(100,150),vector(100,-150)]
@@ -283,6 +284,11 @@ def check_collision(self):
if abs(self.pacman.position - self.food.position) < 20:
self.pacman.eat(self.food.power)
self.food.captured()
+ index = self.offset(self.pacman.position )
+ if self.tiles[index] == 1:
+ self.pacman.eat(1)
+ self.clear_map(index)
+
def run(self):
@@ -290,11 +296,11 @@ def run(self):
self.draw_score()
clear()
+ self.check_collision()
+
self.move_and_draw_pacman()
self.move_and_draw_ghost()
-
- self.check_collision()
self.create_and_draw_food()
From db845ffa38260bc857e375726b336c6e18614d98 Mon Sep 17 00:00:00 2001
From: Breno
Date: Wed, 31 Mar 2021 19:03:11 -0300
Subject: [PATCH 69/81] change in the method of analysis and verification of
the state of the food
---
freegames/pacman_oop.py | 36 +++++++++++++++++++-----------------
1 file changed, 19 insertions(+), 17 deletions(-)
diff --git a/freegames/pacman_oop.py b/freegames/pacman_oop.py
index 2f8c6611..5095c9e0 100644
--- a/freegames/pacman_oop.py
+++ b/freegames/pacman_oop.py
@@ -35,7 +35,11 @@ def __init__(self,position_x, position_y,aim_x,aim_y):
self.state = "ALIVE"
def eat(self, food):
- self.score['score'] += food
+ if type(food) == Food:
+ self.score['score'] += food.power
+ else:
+ self.score['score'] += food
+ print(food)
def die(self):
self.state = "DEAD"
@@ -101,15 +105,14 @@ def __init__(self, x=None, y=None):
self.color = "yellow"
self.state = "ABSENT"
- def captured(self):
- self.state = "ABSENT"
-
- def with_food(self):
- self.state = "PRESENT"
+ def toggle_state_to_present(self):
+ self.state = 'PRESENT'
+
+ def toggle_state_to_absent(self):
+ self.state = 'ABSENT'
- def without_food(self):
- if self.state == "ABSENT":
- return True
+ def is_captured(self):
+ return self.state == "ABSENT"
class GamePacman:
def __init__(self):
@@ -239,8 +242,6 @@ def draw_score(self):
self.writer.color('white')
self.writer.write(self.pacman.score['score'])
-
-
def clear_map(self,index):
self.tiles[index] = 2
x = (index % 20) * 20 - 200
@@ -248,15 +249,16 @@ def clear_map(self,index):
self.square(x, y)
- def create_and_draw_food(self):
+ def move_and_draw_food(self):
foods_positions = [vector(-180,150),vector(-180,-150),vector(100,150),vector(100,-150)]
- if self.food.without_food() == True:
+ if self.food.is_captured():
self.food.position = choice(foods_positions)
if self.valid(self.food.position):
up()
goto(self.food.position.x + 10, self.food.position.y + 10)
dot(10,self.food.color)
- self.food.with_food()
+ self.food.toggle_state_to_present()
+
def move_and_draw_pacman(self):
if self.valid(self.pacman.next_position()):
@@ -282,8 +284,8 @@ def check_collision(self):
if abs(self.pacman.position - ghost.position) < 20:
self.pacman.die()
if abs(self.pacman.position - self.food.position) < 20:
- self.pacman.eat(self.food.power)
- self.food.captured()
+ self.food.toggle_state_to_absent()
+ self.pacman.eat(self.food)
index = self.offset(self.pacman.position )
if self.tiles[index] == 1:
self.pacman.eat(1)
@@ -302,7 +304,7 @@ def run(self):
self.move_and_draw_ghost()
- self.create_and_draw_food()
+ self.move_and_draw_food()
if self.pacman.alive():
ontimer(self.run, 100)
From 927e092776f434e2b061a9a922c967b3b749971a Mon Sep 17 00:00:00 2001
From: Breno
Date: Sat, 3 Apr 2021 15:56:09 -0300
Subject: [PATCH 70/81] actor and pacman class adjustments
---
freegames/pacman_oop.py | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/freegames/pacman_oop.py b/freegames/pacman_oop.py
index 5095c9e0..ec2e4ebd 100644
--- a/freegames/pacman_oop.py
+++ b/freegames/pacman_oop.py
@@ -18,7 +18,6 @@
class Actor:
speed = 1
- score = 0
def __init__(self,position_x, position_y,aim_x,aim_y):
self.position = vector(position_x,position_y)
self.aim = vector(aim_x, aim_y)
@@ -28,18 +27,14 @@ def move(self):
class Pacman(Actor):
speed = 1
- score = {'score': 0}
def __init__(self,position_x, position_y,aim_x,aim_y):
super().__init__(position_x, position_y, aim_x, aim_y)
self.direction = "EAST"
self.state = "ALIVE"
+ self.score = {'score': 0}
def eat(self, food):
- if type(food) == Food:
self.score['score'] += food.power
- else:
- self.score['score'] += food
- print(food)
def die(self):
self.state = "DEAD"
@@ -105,10 +100,10 @@ def __init__(self, x=None, y=None):
self.color = "yellow"
self.state = "ABSENT"
- def toggle_state_to_present(self):
+ def food_show(self):
self.state = 'PRESENT'
- def toggle_state_to_absent(self):
+ def food_hide(self):
self.state = 'ABSENT'
def is_captured(self):
@@ -257,7 +252,7 @@ def move_and_draw_food(self):
up()
goto(self.food.position.x + 10, self.food.position.y + 10)
dot(10,self.food.color)
- self.food.toggle_state_to_present()
+ self.food.food_show()
def move_and_draw_pacman(self):
@@ -284,11 +279,11 @@ def check_collision(self):
if abs(self.pacman.position - ghost.position) < 20:
self.pacman.die()
if abs(self.pacman.position - self.food.position) < 20:
- self.food.toggle_state_to_absent()
+ self.food.food_hide()
self.pacman.eat(self.food)
index = self.offset(self.pacman.position )
if self.tiles[index] == 1:
- self.pacman.eat(1)
+ self.pacman.eat(self.food)
self.clear_map(index)
From eec31799dfd085f9a65c441b1bb441853027b061 Mon Sep 17 00:00:00 2001
From: Breno
Date: Tue, 6 Apr 2021 14:55:41 -0300
Subject: [PATCH 71/81] adjustment in the eat method
---
freegames/pacman_oop.py | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/freegames/pacman_oop.py b/freegames/pacman_oop.py
index ec2e4ebd..e22ff9ac 100644
--- a/freegames/pacman_oop.py
+++ b/freegames/pacman_oop.py
@@ -34,7 +34,7 @@ def __init__(self,position_x, position_y,aim_x,aim_y):
self.score = {'score': 0}
def eat(self, food):
- self.score['score'] += food.power
+ self.score['score'] += food.energy
def die(self):
self.state = "DEAD"
@@ -94,7 +94,8 @@ class SlowGhost(Ghost):
speed = 0.5
class Food:
- power = 5
+
+ energy = 1
def __init__(self, x=None, y=None):
self.position = vector(x,y)
self.color = "yellow"
@@ -237,7 +238,7 @@ def draw_score(self):
self.writer.color('white')
self.writer.write(self.pacman.score['score'])
- def clear_map(self,index):
+ def clear_tile(self,index):
self.tiles[index] = 2
x = (index % 20) * 20 - 200
y = 180 - (index // 20) * 20
@@ -284,7 +285,7 @@ def check_collision(self):
index = self.offset(self.pacman.position )
if self.tiles[index] == 1:
self.pacman.eat(self.food)
- self.clear_map(index)
+ self.clear_tile(index)
def run(self):
From 08a49fd3a93c12c77b0b85c80a288ef6ada8836e Mon Sep 17 00:00:00 2001
From: Breno
Date: Sun, 11 Apr 2021 20:21:49 -0300
Subject: [PATCH 72/81] adjustment in the food show and slow method
---
freegames/pacman_oop.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/freegames/pacman_oop.py b/freegames/pacman_oop.py
index e22ff9ac..29c53807 100644
--- a/freegames/pacman_oop.py
+++ b/freegames/pacman_oop.py
@@ -101,10 +101,10 @@ def __init__(self, x=None, y=None):
self.color = "yellow"
self.state = "ABSENT"
- def food_show(self):
+ def show(self):
self.state = 'PRESENT'
- def food_hide(self):
+ def hide(self):
self.state = 'ABSENT'
def is_captured(self):
@@ -253,7 +253,7 @@ def move_and_draw_food(self):
up()
goto(self.food.position.x + 10, self.food.position.y + 10)
dot(10,self.food.color)
- self.food.food_show()
+ self.food.show()
def move_and_draw_pacman(self):
@@ -280,7 +280,7 @@ def check_collision(self):
if abs(self.pacman.position - ghost.position) < 20:
self.pacman.die()
if abs(self.pacman.position - self.food.position) < 20:
- self.food.food_hide()
+ self.food.hide()
self.pacman.eat(self.food)
index = self.offset(self.pacman.position )
if self.tiles[index] == 1:
From d26a6b10ac28b4998bb673811fff817f8f616ccc Mon Sep 17 00:00:00 2001
From: Breno
Date: Tue, 13 Apr 2021 12:48:01 -0300
Subject: [PATCH 73/81] oriented object pacman final version
---
freegames/pacman_oop.py | 111 ++++++++++++----------------------------
1 file changed, 34 insertions(+), 77 deletions(-)
diff --git a/freegames/pacman_oop.py b/freegames/pacman_oop.py
index 29c53807..a061fc6d 100644
--- a/freegames/pacman_oop.py
+++ b/freegames/pacman_oop.py
@@ -16,32 +16,26 @@
from turtle import bgcolor, clear, up, down, goto, Turtle, dot, update, ontimer, setup, hideturtle, tracer, listen, onkey, done
from freegames import floor, vector
-class Actor:
- speed = 1
+class Pacman:
def __init__(self,position_x, position_y,aim_x,aim_y):
self.position = vector(position_x,position_y)
self.aim = vector(aim_x, aim_y)
-
- def move(self):
- self.position.move(self.aim * self.speed)
-
-class Pacman(Actor):
- speed = 1
- def __init__(self,position_x, position_y,aim_x,aim_y):
- super().__init__(position_x, position_y, aim_x, aim_y)
self.direction = "EAST"
self.state = "ALIVE"
- self.score = {'score': 0}
+ self.score = 0
+
+ def move(self):
+ self.position.move(self.aim )
+
+ def eat(self):
+ self.score += 1
- def eat(self, food):
- self.score['score'] += food.energy
-
def die(self):
self.state = "DEAD"
-
+
def alive(self):
return self.state != "DEAD"
-
+
def next_position(self, aim=None):
if aim != None :
new_position = self.position + aim
@@ -71,13 +65,19 @@ def left(self):
def right(self):
self.direction, new_aim = self.turn_to_right[self.direction]
self.aim = new_aim
-
+
def turn_around(self):
self.direction, new_aim = self.turn_to_around[self.direction]
self.aim = new_aim
-
-class Ghost(Actor):
-
+
+class Ghost:
+ def __init__(self,position_x, position_y,aim_x,aim_y):
+ self.position = vector(position_x,position_y)
+ self.aim = vector(aim_x, aim_y)
+
+ def move(self):
+ self.position.move(self.aim )
+
def change_direction(self):
options = [
vector(5, 0),
@@ -87,39 +87,15 @@ def change_direction(self):
]
self.aim = choice(options)
-class FastGhost(Ghost):
- speed = 2
-
-class SlowGhost(Ghost):
- speed = 0.5
-
-class Food:
-
- energy = 1
- def __init__(self, x=None, y=None):
- self.position = vector(x,y)
- self.color = "yellow"
- self.state = "ABSENT"
-
- def show(self):
- self.state = 'PRESENT'
-
- def hide(self):
- self.state = 'ABSENT'
-
- def is_captured(self):
- return self.state == "ABSENT"
-
class GamePacman:
def __init__(self):
self.path = Turtle(visible=False)
self.writer = Turtle(visible=False)
self.pacman = Pacman(-40, -80, 5, 0)
- self.food = Food(-160,100)
self.ghosts = [Ghost(-180,160,5,0),
- FastGhost(-180,-160,0,5),
- SlowGhost(100,160,0,-5),
- FastGhost(100,-160,-5,0)]
+ Ghost(-180,-160,0,5),
+ Ghost(100,160,0,-5),
+ Ghost(100,-160,-5,0)]
self.tiles = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
@@ -157,7 +133,7 @@ def on_rightkeypressed(self):
self.pacman.left()
elif self.pacman.direction == "WEST":
self.pacman.turn_around()
-
+
def on_leftkeypressed(self):
if self.valid(self.pacman.next_position (vector(-5,0))):
if self.pacman.direction == 'NORTH':
@@ -196,7 +172,7 @@ def square(self,x,y):
self.path.left(90)
self.path.end_fill()
-
+
def offset(self,point):
x = (floor(point.x, 20) + 200) / 20
y = (180 - floor(point.y, 20)) / 20
@@ -216,7 +192,7 @@ def valid(self,point):
return False
return point.x % 20 == 0 or point.y % 20 == 0
-
+
def draw_world(self):
bgcolor('black')
self.path.color('blue')
@@ -232,11 +208,14 @@ def draw_world(self):
self.path.up()
self.path.goto(x + 10, y + 10)
self.path.dot(2, 'white')
-
+
def draw_score(self):
- self.writer.goto(160, 160)
+ self.writer.goto(140, 160)
self.writer.color('white')
- self.writer.write(self.pacman.score['score'])
+ self.writer.clear()
+ self.writer.write('score: ')
+ self.writer.goto(175, 160)
+ self.writer.write(self.pacman.score)
def clear_tile(self,index):
self.tiles[index] = 2
@@ -244,18 +223,6 @@ def clear_tile(self,index):
y = 180 - (index // 20) * 20
self.square(x, y)
-
- def move_and_draw_food(self):
- foods_positions = [vector(-180,150),vector(-180,-150),vector(100,150),vector(100,-150)]
- if self.food.is_captured():
- self.food.position = choice(foods_positions)
- if self.valid(self.food.position):
- up()
- goto(self.food.position.x + 10, self.food.position.y + 10)
- dot(10,self.food.color)
- self.food.show()
-
-
def move_and_draw_pacman(self):
if self.valid(self.pacman.next_position()):
self.pacman.move()
@@ -279,28 +246,19 @@ def check_collision(self):
for ghost in self.ghosts:
if abs(self.pacman.position - ghost.position) < 20:
self.pacman.die()
- if abs(self.pacman.position - self.food.position) < 20:
- self.food.hide()
- self.pacman.eat(self.food)
+
index = self.offset(self.pacman.position )
if self.tiles[index] == 1:
- self.pacman.eat(self.food)
+ self.pacman.eat()
self.clear_tile(index)
-
def run(self):
-
self.writer.undo()
self.draw_score()
clear()
-
self.check_collision()
-
self.move_and_draw_pacman()
-
self.move_and_draw_ghost()
-
- self.move_and_draw_food()
if self.pacman.alive():
ontimer(self.run, 100)
@@ -314,7 +272,6 @@ def init():
hideturtle()
tracer(False)
listen()
-
game = GamePacman()
game.run()
done()
From 8cb18af9d629142cffb737a2bb3fa16876ac42ff Mon Sep 17 00:00:00 2001
From: Grant Jenks
Date: Mon, 14 Jun 2021 17:52:05 -0700
Subject: [PATCH 74/81] First pass with blue
---
freegames/ant.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/freegames/ant.py b/freegames/ant.py
index d83c7168..c9c963f7 100644
--- a/freegames/ant.py
+++ b/freegames/ant.py
@@ -39,6 +39,7 @@ def draw():
ontimer(draw, 100)
+
setup(420, 420, 370, 0)
hideturtle()
tracer(False)
From 978175c779a8249ac424099b12253104d1f4b234 Mon Sep 17 00:00:00 2001
From: Adorilson Bezerra
Date: Wed, 13 Oct 2021 11:33:05 -0300
Subject: [PATCH 75/81] Update documentation about Pacman OO version
---
README.rst | 3 ++-
docs/index.rst | 1 +
docs/pacman_oop.rst | 6 ++++++
3 files changed, 9 insertions(+), 1 deletion(-)
create mode 100644 docs/pacman_oop.rst
diff --git a/README.rst b/README.rst
index cef360bf..659ad5ff 100644
--- a/README.rst
+++ b/README.rst
@@ -155,12 +155,13 @@ Pacman
......
`Pacman`_ -- classic arcade game. Use the arrow keys to navigate and eat all
-the white food. Watch out for red ghosts that roam the maze.
+the white food. Watch out for red ghosts that roam the maze. (`OO version`_)
.. image:: http://www.grantjenks.com/docs/freegames/_static/pacman.gif
:alt: Pacman Free Python Game
.. _`Pacman`: http://www.grantjenks.com/docs/freegames/pacman.html
+.. _`OO version`: pacman_oop.html
Cannon
......
diff --git a/docs/index.rst b/docs/index.rst
index 0af26523..65ac44c7 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -26,5 +26,6 @@
connect
memory
pacman
+ pacman_oop
fidget
madlibs
diff --git a/docs/pacman_oop.rst b/docs/pacman_oop.rst
new file mode 100644
index 00000000..de3fbc06
--- /dev/null
+++ b/docs/pacman_oop.rst
@@ -0,0 +1,6 @@
+Pacman
+======
+
+Pacman, classic arcade game.
+
+.. literalinclude:: ../freegames/pacman_oop.py
From 7470caff307d454c1198702a77623eaa77f89950 Mon Sep 17 00:00:00 2001
From: Adorilson Bezerra
Date: Wed, 13 Oct 2021 14:09:13 -0300
Subject: [PATCH 76/81] Fix README about Pacman
---
README.rst | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.rst b/README.rst
index 659ad5ff..bcc06b74 100644
--- a/README.rst
+++ b/README.rst
@@ -155,13 +155,13 @@ Pacman
......
`Pacman`_ -- classic arcade game. Use the arrow keys to navigate and eat all
-the white food. Watch out for red ghosts that roam the maze. (`OO version`_)
+the white food. Watch out for red ghosts that roam the maze.
+(`OO version `_)
.. image:: http://www.grantjenks.com/docs/freegames/_static/pacman.gif
:alt: Pacman Free Python Game
.. _`Pacman`: http://www.grantjenks.com/docs/freegames/pacman.html
-.. _`OO version`: pacman_oop.html
Cannon
......
From 78c05d4fcdc90c2a6921f204e9dfdf81ee1f720b Mon Sep 17 00:00:00 2001
From: Adorilson Bezerra
Date: Wed, 13 Oct 2021 14:36:09 -0300
Subject: [PATCH 77/81] Fix README about Snake
---
README.rst | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/README.rst b/README.rst
index 4fba756f..70ba18ec 100644
--- a/README.rst
+++ b/README.rst
@@ -147,13 +147,12 @@ Snake
`Snake`_ -- classic arcade game. Use the arrow keys to navigate and eat the
green food. Each time the food is consumed, the snake grows one segment
-longer. Avoid eating yourself or going out of bounds! (`OO version`_)
+longer. Avoid eating yourself or going out of bounds! (`OO version `_)
.. image:: http://www.grantjenks.com/docs/freegames/_static/snake.gif
:alt: Snake Free Python Game
.. _`Snake`: http://www.grantjenks.com/docs/freegames/snake.html
-.. _`OO version`: snake_oop.html
Pacman
......
From 240258ebdf19759d2657fbc482a292baa377b3fd Mon Sep 17 00:00:00 2001
From: Pedro Henrique de Brito Gomes
Date: Thu, 21 Oct 2021 08:50:57 -0300
Subject: [PATCH 78/81] Update sphinx.po
---
docs/locale/pt_BR/LC_MESSAGES/sphinx.po | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/docs/locale/pt_BR/LC_MESSAGES/sphinx.po b/docs/locale/pt_BR/LC_MESSAGES/sphinx.po
index e64d3329..9d5205c8 100644
--- a/docs/locale/pt_BR/LC_MESSAGES/sphinx.po
+++ b/docs/locale/pt_BR/LC_MESSAGES/sphinx.po
@@ -4,19 +4,20 @@
# package.
# FIRST AUTHOR , 2021.
#
-#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Free Python Games 2.3.2\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-08-24 21:25-0300\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME \n"
-"Language-Team: LANGUAGE \n"
+"PO-Revision-Date: 2021-10-21 08:45-0300\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.9.1\n"
+"Last-Translator: Pedro Henrique de Brito Gomes \n"
+"Language-Team: \n"
+"Language: pt_BR\n"
+"X-Generator: Poedit 2.3\n"
#: ../../_templates/gumroad.html:1
msgid "Donate"
@@ -36,5 +37,4 @@ msgstr "Conteúdo"
#: ../../_templates/search.html:14 ../../_templates/search.html:17
msgid "Search"
-msgstr ""
-
+msgstr "Busca"
From 5145804b874a12ae2fcf8e8adb83ee08a91f4a23 Mon Sep 17 00:00:00 2001
From: Adorilson Bezerra
Date: Wed, 19 Oct 2022 22:35:14 -0300
Subject: [PATCH 79/81] Add .venv to .gitignore
---
.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitignore b/.gitignore
index fc62191c..75bc0667 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,7 @@
# virutalenv directories
/env*/
+.venv
# coverage files
.coverage
From 628076b10d66df4cd248a93a67417e68ffeef1fb Mon Sep 17 00:00:00 2001
From: Adorilson Bezerra
Date: Wed, 19 Oct 2022 22:37:21 -0300
Subject: [PATCH 80/81] Moving score attribute to GamePacman again
---
freegames/pacman_oop.py | 149 +++++++++++++++++++++-------------------
1 file changed, 77 insertions(+), 72 deletions(-)
diff --git a/freegames/pacman_oop.py b/freegames/pacman_oop.py
index a061fc6d..82803197 100644
--- a/freegames/pacman_oop.py
+++ b/freegames/pacman_oop.py
@@ -2,11 +2,13 @@
Exercises
-1. Move the score variable/attribute to Pacman's class. This attribute must be incremented by a new method in Pacman's code.
- Chose draw_score according to the needed changes in GamePacman.
-2. Create a speed attribute and do the needed changes to change Pacman's speed according to its value.
-3. Create a subclass of Ghosts that each one of them has ghosts
- with different speeds value (Use the second exercise as an example).
+1. Move the score variable/attribute to Pacman's class. This attribute must be
+incremented by a new method in Pacman's code. Chose draw_score according to the
+needed changes in GamePacman.
+2. Create a speed attribute and do the needed changes to change Pacman's speed
+according to its value.
+3. Create a subclass of Ghosts that each one of them has ghosts with different
+speeds value (Use the second exercise as an example).
4. Create a superclass for both Pacman and Ghost.
5. Create different types of food.
@@ -16,19 +18,17 @@
from turtle import bgcolor, clear, up, down, goto, Turtle, dot, update, ontimer, setup, hideturtle, tracer, listen, onkey, done
from freegames import floor, vector
+
class Pacman:
- def __init__(self,position_x, position_y,aim_x,aim_y):
- self.position = vector(position_x,position_y)
+ def __init__(self, position_x, position_y, aim_x, aim_y):
+ self.position = vector(position_x, position_y)
self.aim = vector(aim_x, aim_y)
self.direction = "EAST"
self.state = "ALIVE"
self.score = 0
def move(self):
- self.position.move(self.aim )
-
- def eat(self):
- self.score += 1
+ self.position.move(self.aim)
def die(self):
self.state = "DEAD"
@@ -37,26 +37,26 @@ def alive(self):
return self.state != "DEAD"
def next_position(self, aim=None):
- if aim != None :
+ if aim != None:
new_position = self.position + aim
else:
new_position = self.position + self.aim
return new_position
turn_to_left = {'NORTH': ('WEST', vector(-5, 0)),
- 'WEST' : ('SOUTH', vector(0, -5)),
- 'SOUTH': ('EAST', vector(5, 0)),
- 'EAST' : ('NORTH', vector(0, 5))}
+ 'WEST': ('SOUTH', vector(0, -5)),
+ 'SOUTH': ('EAST', vector(5, 0)),
+ 'EAST': ('NORTH', vector(0, 5))}
turn_to_right = {'NORTH': ('EAST', vector(5, 0)),
- 'EAST' : ('SOUTH', vector(0, -5)),
- 'SOUTH': ('WEST', vector(-5, 0)),
- 'WEST' : ('NORTH', vector(0, 5))}
+ 'EAST': ('SOUTH', vector(0, -5)),
+ 'SOUTH': ('WEST', vector(-5, 0)),
+ 'WEST': ('NORTH', vector(0, 5))}
turn_to_around = {'NORTH': ('SOUTH', vector(0, -5)),
- 'SOUTH' : ('NORTH', vector(0, 5)),
- 'WEST': ('EAST', vector(5, 0)),
- 'EAST' : ('WEST', vector(-5, 0))}
+ 'SOUTH': ('NORTH', vector(0, 5)),
+ 'WEST': ('EAST', vector(5, 0)),
+ 'EAST': ('WEST', vector(-5, 0))}
def left(self):
self.direction, new_aim = self.turn_to_left[self.direction]
@@ -70,13 +70,14 @@ def turn_around(self):
self.direction, new_aim = self.turn_to_around[self.direction]
self.aim = new_aim
+
class Ghost:
- def __init__(self,position_x, position_y,aim_x,aim_y):
- self.position = vector(position_x,position_y)
+ def __init__(self, position_x, position_y, aim_x, aim_y):
+ self.position = vector(position_x, position_y)
self.aim = vector(aim_x, aim_y)
def move(self):
- self.position.move(self.aim )
+ self.position.move(self.aim)
def change_direction(self):
options = [
@@ -87,46 +88,48 @@ def change_direction(self):
]
self.aim = choice(options)
+
class GamePacman:
def __init__(self):
+ self.state = {'score': 0}
self.path = Turtle(visible=False)
self.writer = Turtle(visible=False)
self.pacman = Pacman(-40, -80, 5, 0)
- self.ghosts = [Ghost(-180,160,5,0),
- Ghost(-180,-160,0,5),
- Ghost(100,160,0,-5),
- Ghost(100,-160,-5,0)]
+ self.ghosts = [Ghost(-180, 160, 5, 0),
+ Ghost(-180, -160, 0, 5),
+ Ghost(100, 160, 0, -5),
+ Ghost(100, -160, -5, 0)]
self.tiles = [
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
- 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0,
- 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
- 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0,
- 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0,
- 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
- 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0,
- 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
- 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0,
- 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0,
- 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
- 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
- 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0,
- 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0,
- 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0,
- 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
- 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
+ 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0,
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
+ 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0,
+ 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0,
+ 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
+ 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0,
+ 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
+ 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0,
+ 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0,
+ 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
+ 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
+ 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0,
+ 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0,
+ 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0,
+ 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
]
self.draw_world()
- onkey(lambda: self.on_rightkeypressed() , 'Right')
+ onkey(lambda: self.on_rightkeypressed(), 'Right')
onkey(lambda: self.on_leftkeypressed(), 'Left')
onkey(lambda: self.on_upkeypressed(), 'Up')
onkey(lambda: self.on_downkeypressed(), 'Down')
def on_rightkeypressed(self):
- if self.valid(self.pacman.next_position(vector(5,0))):
+ if self.valid(self.pacman.next_position(vector(5, 0))):
if self.pacman.direction == 'NORTH':
self.pacman.right()
elif self.pacman.direction == "SOUTH":
@@ -135,7 +138,7 @@ def on_rightkeypressed(self):
self.pacman.turn_around()
def on_leftkeypressed(self):
- if self.valid(self.pacman.next_position (vector(-5,0))):
+ if self.valid(self.pacman.next_position(vector(-5, 0))):
if self.pacman.direction == 'NORTH':
self.pacman.left()
elif self.pacman.direction == "SOUTH":
@@ -144,7 +147,7 @@ def on_leftkeypressed(self):
self.pacman.turn_around()
def on_upkeypressed(self):
- if self.valid(self.pacman.next_position(vector(0,5))):
+ if self.valid(self.pacman.next_position(vector(0, 5))):
if self.pacman.direction == 'WEST':
self.pacman.right()
elif self.pacman.direction == "EAST":
@@ -152,8 +155,8 @@ def on_upkeypressed(self):
elif self.pacman.direction == "SOUTH":
self.pacman.turn_around()
- def on_downkeypressed (self):
- if self.valid(self.pacman.next_position(vector(0,-5))):
+ def on_downkeypressed(self):
+ if self.valid(self.pacman.next_position(vector(0, -5))):
if self.pacman.direction == 'WEST':
self.pacman.left()
elif self.pacman.direction == "EAST":
@@ -161,25 +164,25 @@ def on_downkeypressed (self):
elif self.pacman.direction == "NORTH":
self.pacman.turn_around()
- def square(self,x,y):
+ def square(self, x, y):
self.path.up()
- self.path.goto(x,y)
+ self.path.goto(x, y)
self.path.down()
self.path.begin_fill()
for count in range(4):
self.path.forward(20)
self.path.left(90)
-
+
self.path.end_fill()
- def offset(self,point):
+ def offset(self, point):
x = (floor(point.x, 20) + 200) / 20
y = (180 - floor(point.y, 20)) / 20
index = int(x + y * 20)
return index
- def valid(self,point):
+ def valid(self, point):
"Return True if point is valid in tiles."
index = self.offset(point)
@@ -199,10 +202,10 @@ def draw_world(self):
for index in range(len(self.tiles)):
tile = self.tiles[index]
- if tile> 0:
+ if tile > 0:
x = (index % 20) * 20 - 200
y = 180 - (index // 20) * 20
- self.square(x,y)
+ self.square(x, y)
if tile == 1:
self.path.up()
@@ -215,21 +218,21 @@ def draw_score(self):
self.writer.clear()
self.writer.write('score: ')
self.writer.goto(175, 160)
- self.writer.write(self.pacman.score)
+ self.writer.write(self.state['score'])
- def clear_tile(self,index):
- self.tiles[index] = 2
- x = (index % 20) * 20 - 200
- y = 180 - (index // 20) * 20
- self.square(x, y)
+ def clear_tile(self, index):
+ self.tiles[index] = 2
+ x = (index % 20) * 20 - 200
+ y = 180 - (index // 20) * 20
+ self.square(x, y)
def move_and_draw_pacman(self):
if self.valid(self.pacman.next_position()):
self.pacman.move()
up()
- goto(self.pacman.position.x +10 , self.pacman.position.y + 10)
- dot(20,'yellow')
+ goto(self.pacman.position.x + 10, self.pacman.position.y + 10)
+ dot(20, 'yellow')
def move_and_draw_ghost(self):
for ghost in self.ghosts:
@@ -247,11 +250,11 @@ def check_collision(self):
if abs(self.pacman.position - ghost.position) < 20:
self.pacman.die()
- index = self.offset(self.pacman.position )
+ index = self.offset(self.pacman.position)
if self.tiles[index] == 1:
- self.pacman.eat()
+ self.state['score'] += 1
self.clear_tile(index)
-
+
def run(self):
self.writer.undo()
self.draw_score()
@@ -267,6 +270,7 @@ def run(self):
update()
+
def init():
setup(420, 420, 370, 0)
hideturtle()
@@ -276,5 +280,6 @@ def init():
game.run()
done()
+
if __name__ == '__main__':
init()
From 4f4090a224202948d1a423d740fb36f3d3611e64 Mon Sep 17 00:00:00 2001
From: Adorilson Bezerra
Date: Thu, 20 Oct 2022 18:07:03 -0300
Subject: [PATCH 81/81] Erase self.score Pacman attribute
---
freegames/pacman_oop.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/freegames/pacman_oop.py b/freegames/pacman_oop.py
index 82803197..0d3032fa 100644
--- a/freegames/pacman_oop.py
+++ b/freegames/pacman_oop.py
@@ -25,7 +25,6 @@ def __init__(self, position_x, position_y, aim_x, aim_y):
self.aim = vector(aim_x, aim_y)
self.direction = "EAST"
self.state = "ALIVE"
- self.score = 0
def move(self):
self.position.move(self.aim)