Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

pygame-enter-username-keep-top-ten-players

277 views

Published on

How Enter/Input Username/Text in Pygame/Python 3

Sample Games in Pygame/Python 3 with the functionality of >>>

Entering text/username in
Snake and Tetris games
and keep TOP TEN Players saved (txt file)
I use both jsonpickle module and my custom serializer to save in a text file

In Youtube:
https://youtu.be/L8Rl11BhV_4

Note - easy start
Install Thonny Python IDE
Under
Tools > Manage Packages
install Pygame, jsonpickle, etc modules

Published in: Technology
  • Be the first to comment

pygame-enter-username-keep-top-ten-players

  1. 1. Enter Username-Pygame I show you how enter text (username) in Pygame(Python 3) through two sample games: Snake and Tetris and keep TOP TEN Players saved (txt file) I use both jsonpickle module and my custom serializer to save in a text file
  2. 2. Main Python Files are below  /Tetris/ folder: tetromino-production-jsonpickle-top-10.py, hightscores.json, tetromino-production-custom-top-10.py, hightscores.txt  /Snake/ folder: snake-production-jsonpickle-top-10.py, hightscores.json, snake-production-custom-top-10.py, hightscores.txt  Other files, support the games like images or image sprites.  All Files are in the two folders and these are in a ZIP file archive
  3. 3. Other functionality  Games ask for User name and also include:  Pause by pressing “P” or “p”, Start by inserting User name and pressing Enter or Space-bar. Control games with Arrow keys.  TOP TEN Players in .txt (custom version) or .json (jsonpickle module version) files. If you insert an already existed User name and scored more than before the score is edited and you can Not have double user names  Added collision sounds (Snake), If you want run game as other Player restart it.  TOP Player appear in the Splash screen at startup or at the end  Txt and json files if Not exist are automatically created, json file stores Python json pickled object, text file store entries in text “user,points”  The code lines responsible for TOP TEN Players and Enter Username indicated in the next slide (lines in the python files) and saved in .txt or .json files
  4. 4. Snake game – code lines for Username Enter and keep TOP TEN Players  snake-production-jsonpickle-top-10.py  Username Enter  Lines 53 – 100, 534, 547 - 548  TOP TEN Players  Lines 10-11, 138 – 251, 328, 525  snake-production-custom-top-10.py  Username Enter  Lines 56 – 99, 504, 517 - 518  TOP TEN Players  Lines 105 – 132, 135 – 217, 298, 495,
  5. 5. Tetris game – code lines for Username enter and keep TOP TEN players  tetromino-production-jsonpickle-top-10.py  Username Enter  Lines 162 – 215, 561 - 563  TOP TEN Players  Lines 9 – 10, 250 – 363, 389 - 390, 405, 542, 557  tetromino-production-custom-top-10.py  Username Enter  Lines 162 – 215, 565 – 567,  TOP TEN Players  Lines 217 – 367, 393 - 394, 409, 546, 561,
  6. 6. Support via E-mail, or Envato Forum Support  Lsepolis123@gmail.com // My Email for Support  https://thonny.org  https://www.geany.org/download/releases/  Recommended Python Free Editors/IDE – cross platform  https://codecanyon.net/user/lse123/ (Envato – my Account)

×