Giter Club home page Giter Club logo

free-python-games's Introduction

Free Python Games

Free Python Games is an Apache2 licensed collection of free Python games intended for education and fun. The games are written in simple Python code and designed for experimentation and changes. Simplified versions of several classic arcade games are included.

Python is one of the top-five most popular programming languages in the world and available for free from Python.org. Python includes an extensive Standard Library distributed with your installation. The Standard Library has a module called Turtle which is a popular way to introduce programming to kids. Turtle was part of the original Logo programming language developed by Wally Feurzig and Seymour Papert in 1966. All of the games in Free Python Games are implemented using Python and its Turtle module.

Starting in 2012, Free Python Games began as an after school program to teach programming to inner-city youth. The goal was to have fun as 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.

The games run anywhere Python can be installed which includes desktop computers running Windows, Mac OS, or Linux and older or low-power hardware such as the Raspberry Pi. Kids across the United States in grades 6th-12th have enjoyed learning about topics such as encryption and projectile motion through games.

Each game is entirely independent from the others and includes comments along with a list of exercises to work through with students. Creativity and flexibility is important. There is no right or wrong way to implement a new feature or behavior! You never know which games students will engage with best.

Testimonials

"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."

-- Luke Martin, Student

"Free Python Games inspired and introduced a new hobby to our son. Thank you so much for exposing him to coding. He is having so much fun!"

-- Mary Lai, Parent

"Free Python Games are great because they really engage students and let them learn at their own pace."

-- Rick Schertle, Teacher, Steindorf STEAM School

"Free Python Games combines play and learning in a flexible environment that reduces the stress of a difficult topic like programming."

-- Brett Bymaster, Youth Pastor, The River Church Community

"Free Python Games is great for students, is highly organized and flexible, and seeks to unleash inquiry and understanding."

-- Terri Furton, Principal, Downtown College Prep

Features

  • Fun to play!
  • Simple Python code
  • Easy to install
  • Designed for education
  • Depends only on the Python Standard Library
  • Used in hundreds of hours of classroom instruction
  • Fully Documented
  • 100% Test Coverage
  • Developed on Python 3.10
  • Tested on CPython 3.6, 3.7, 3.8, 3.9, 3.10
  • Tested on Linux, Mac OS X, and Windows
  • Tested using GitHub Actions

Quickstart

Installing Free Python Games is simple with pip:

$ python3 -m pip install freegames

Free Python Games supports a command-line interface (CLI). Help for the CLI is available using:

$ python3 -m freegames --help

The CLI supports three commands: list, copy, and show. For a list of all games run:

$ python3 -m freegames list

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:

$ python3 -m freegames.snake

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:

$ python3 -m freegames copy snake
$ python3 snake.py

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:

$ python3 -m idlelib.idle snake.py

You can also access documentation in the interpreter with Python's built-in help function:

>>> import freegames
>>> help(freegames)

Free Python Games also provides an entry-point script for compatibility with pipx:

$ pipx install freegames
$ freegames play life

Free Games

Paint

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 can be selected using the keyboard.

Paint Free Python Game

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!

Snake Free Python Game

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.

Pacman Free Python Game

Cannon

Cannon -- projectile motion. Click the screen to fire your cannnonball. The cannonball pops blue balloons in its path. Pop all the balloons before they can cross the screen.

Cannon Free Python Game

Connect

Connect -- Connect 4 game. Click a row to drop a disc. The first player to connect four discs vertically, horizontally, or diagonally wins!

Connect 4 Free Python Game

Flappy

Flappy -- Flappy-bird inspired game. Click the screen to flap your wings. Watch out for black ravens as you fly across the screen.

Flappy Bird Free Python Game

Memory

Memory -- puzzle game of number pairs. Click a tile to reveal a number. Match two numbers and the tiles will disappear to reveal an image.

Memory Free Python Game

Pong

Pong -- classic arcade game. Use the keyboard to move your paddle up and down. The first player to miss the ball loses.

Pong Free Python Game

Simon Says

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 you get the sequence right the pattern gets one step longer.

Simon Says Free Python Game

Tic Tac Toe

Tic Tac Toe -- classic game. Click the screen to place an X or O. Connect three in a row and you win!

Tic Tac Toe Free Python Game

Tiles

Tiles -- puzzle game of sliding numbers into place. Click a tile 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?

Tiles Free Python Game

Tron

Tron -- classic arcade game. Use the keyboard to change the direction of your Tron player. Avoid touching the line drawn by your opponent.

Tron Free Python Game

Life

Life -- Conway's Game of Life. The classic, zero-player, cellular automation created in 1970 by John Conway.

Game of Life Free Python Game

Maze

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 side to another.

Maze Free Python Game

Fidget

Fidget -- fidget spinner inspired animation. Click the screen to accelerate the fidget spinner.

Fidget Spinner Free Python Game

Illusion

Illusion -- an optical illusion.

Optical Illusion Free Python Game

Typing

Typing -- practice typing while letters fall down the screen.

Typing Free Python Game

User Guide

For those wanting more details, this part of the documentation describes curriculum, API, and development.

References

Free Python Games License

Copyright 2017-2023 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 License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

free-python-games's People

Contributors

acrosman avatar baekminhyeon avatar bamboudorer avatar drocpdp avatar gaurav17467 avatar grantjenks avatar hanwooseok1 avatar nitinkumar30 avatar songjunghyun1004 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

free-python-games's Issues

Support for pythonista on iOS?

Getting this error:
stash: <class 'TypeError'>: setup() takes from 1 to 3 positional arguments but 5 were given

When I type python3 -m freegames.snake

Number can be seen before guessing

The game named guess asks you to guess a number but when I tried to run the game, I'm getting the number beforehand which doesn't justify the game. I've attached the screenshot where I'm able to guess the number in my first attempt because of this. Kindly look into this and do the needful. Kindly mark it as a bug.

Guess game bug

Also, I'm trying to put a solution further & raised a CR for this but FYI, LINE 17 should be marked as a comment.
solution

Hangman with AI

Implement hangman with an AI.

  1. Player will specify a word.
  2. Computer player will validate word in dictionary.
  3. Computer player will then guess letters.
  4. For missed guesses, the hangman gains more parts.

Instead of using "hangman" which is politically incorrect, use Ascii Art and make the picture disappear.

Support for object-oriented programming courses

Hi.

I'm a professor and I'm starting to tutor students to implement OOP version games.
(Recently, we receive a donation to this initiative - in pt-br)

We not intend to change the current files, but just add new files (rewriting some games) in this programming paradigm.
So FPG would can be used in OOP courses, too.

A initial idea is add a new folder, called oop, where these new files will live.
So, if you want copy the snake game in a oop approach, you just type

$ python3 -m freegames copy oop.snake
$ python3 snake.py

What do you think about? Some comment? Some preference for what game we can start?

Tiles puzzles always unsolvable?

It may be just me, but I started building in a "solvable" check for the tiles generated. To boil it down, I used two rules:

  1. if the blank is on an even row from bottom, the number of inversions should be odd.
  2. if the blank is on an odd row from the bottom, the number of inversions should be even.

If neither of these rules are true, the puzzle is unsolvable.

The problem is, when I put this logic into place, the game generated puzzles that were unsolvable 100% of the time.

I was able to fix the problem by taking the values (numbers) of tiles variable and shuffling that, then rejoining the keys and values of the tiles dictionary. Once this was done, the game generates solvable puzzles as often as not.

It may be obvious by now that I have no idea what I'm doing haha but I'm trying to learn!

Is it just me, or are the puzzles always unsolvable, and why might this be? I'm staring at the original code, but I have no idea how 1-15 is arrived upon, as the ranges involved are much larger, such as 100, -200, 100, etc...

I'm not sure if it'd be worth doing a pull request for the 'check solvable' logic when done; I'm sure many other people who actually know what they're doing are involved in this project. Maybe it could be described as a suggested exercise at the beginning of the file?

Add Game: Baseball game

Estimate n-digits numbers randomly created.
Each digit is not repeated. (123 -> O / 899 -> X)
Strike: A correct number in a right position.
Ball: A correct number in a different position.

Add function : snake.py

Added red dot.
Red dot is trash.
If the snake eat trash, it will be reduced in length by one.
If snake meet trash when len(snake) == 1, the game ends

And If the game is over, IDLE will print out 'Game End'.

#26

This is code.

Create an interface that makes playing Python games easy

"""Free Games CLI
"""
import tkinter as tk
from tkinter import ttk
import runpy

def run_game(game):
runpy.run_module(f"freegames.{game}")

def create_game_button(game, frame):
button = ttk.Button(frame, text=game.capitalize(), command=lambda: run_game(game), style='Game.TButton')
button.pack(pady=10, padx=10)

def show_game_menu():
start_frame.pack_forget()
game_menu_frame.pack(padx=10, pady=10)

Tkinter ์œˆ๋„์šฐ ์ƒ์„ฑ

root = tk.Tk()
root.title("Free Python Games")

Style ์„ค์ •

style = ttk.Style()
style.configure('Game.TButton', font=('Helvetica', 16), padding=10, background='#3399ff', foreground='#000000')
style.map('Game.TButton', background=[('active', '#66ccff')])

Start Frame

start_frame = tk.Frame(root, padx=50, pady=50)
start_button = ttk.Button(start_frame, text="Game Start", command=show_game_menu, style='Game.TButton')
start_button.pack(pady=50)
start_frame.pack(padx=50, pady=50)

Game Menu Frame

game_menu_frame = tk.Frame(root, padx=20, pady=20)

๊ฒŒ์ž„ ๋ชฉ๋ก

games = ["snake", "pacman", "paint", "memory", "cannon", "flappy", "pong", "turtle"]

๊ฒŒ์ž„ ๋ฒ„ํŠผ ์ƒ์„ฑ

for game in games:
create_game_button(game, game_menu_frame)

Tkinter ์ด๋ฒคํŠธ ๋ฃจํ”„ ์‹œ์ž‘

root.mainloop()

Typo in Snake.py

The word "exercises" in snake.py is misspelled as "excercises'

(This is my very first time "contributing" to GitHub. I'm fairly new to programming and I decided to start with Python. I'm very lucky to have discovered freegames!)

Add More Comments to Games

Feedback from Paul Craven of programarcadegames.com: add more comments to games. Lots of comments really help students.

Add Demo from Lightning Talk

Move docs/demo.py to freegames/demo.py and improve source.

Show how to run (maybe auto-install packages using pip) in docs.

Game idea : Flappy bird

Hello,

I'm a computer science student and I have to contribute to an open source project for a course about the open source.
I've found this repository and find it really cool to help new programmers to learn python.

Is it possible to contribute by adding the game flappy bird ?
I'll try to keep it really simple so that every newcomers can understand the core of the game quickly.

Thanks in advance

Adding a game: Battleships

I am a student that has experience in programming but not GitHub. So I want to start with something simple. Is it ok for me to contribute to your project with the game battleships

tkinter not installed

Let me know if this is just me....

I have Python 3.6.7 and tkinter was not install initially (I'm using ubuntu)

had to run
sudo apt-get install python3-tk

to get tinkter working

below was my first attempt of running after

works fine now.

user@computer:~/programming/python/free-python-games$ python3 -m freegames.snake
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/lcc/programming/python/free-python-games/freegames/snake.py", line 12, in
from turtle import *
File "/usr/lib/python3.6/turtle.py", line 107, in
import tkinter as TK
ModuleNotFoundError: No module named 'tkinter'

Request to make Windows 10 friendly, Includes installer and plublisher signed

Hello i am interested in making your code Windows 10 friendly, it would require me to go over the code and make some changes, to make it compatible with pyinstaller, after that i will create a Windows EXE installer, and sign the exe's with my certificate.
You do not have the merge my fork but instead just include the installer in your release tags.
I look forward to hearing back from you! :D

Add Game: minesweeper

See: https://en.wikipedia.org/wiki/Minesweeper_(video_game)

Prototype:

"""Minesweeper Game

Just playing around. The code below is not well tested.

"""

import random
import collections

random.seed(1)

size = 5
bombs = collections.defaultdict(int)
counts = collections.defaultdict(int)
display = collections.defaultdict(lambda: 'X')
neighbors = sorted(set((i, j) for i in range(size) for j in range(size)) - {(0, 0)})

# Initialize

for x in range(size):
    for y in range(size):
        bombs[x, y] = 0
        counts[x, y] = 0
        display[x, y] = '?'

# Set bombs

for _ in range(3):
    x = random.randrange(size)
    y = random.randrange(size)
    bombs[x, y] = 1

# Calculate counts

for x in range(size):
    for y in range(size):
        total = 0
        for i in [-1, 0, 1]:
            for j in [-1, 0, 1]:
                total += bombs[x + i, y + j]
        counts[x, y] = total

def show(grid):
    for x in range(size):
        for y in range(size):
            print(grid[x, y], end=', ')
        print()

print('Bombs:')
show(bombs)

print('Counts:')
show(counts)

alive = True

def reveal(x, y):
    """Update display and return True/False for alive status.

    """
    if bombs[x, y]:
        return False

    display[x, y] = counts[x, y]

    if counts[x, y]:
        return True

    zeros = [ (x, y) ]

    while zeros:
        x, y = zeros.pop()

        if not ((0 <= x < size) and (0 <= y < size)):
            continue

        if counts[x, y] == 0:
            display[x, y] = 0

        for i in (-1, 0, 1):
            for j in (-1, 0, 1):
                if i == j == 0:
                    continue
                offset_x = x + i
                offset_y = y + j
                seen = display[offset_x, offset_y] != '?'
                if counts[offset_x, offset_y] == 0 and not seen:
                    zeros.append( (offset_x, offset_y) )

    return True

while alive:
    show(display)
    x = int(input('row: '))
    y = int(input('column: '))

    alive = reveal(x, y)

    if not alive or not any(spot == '?' for spot in display.values()):
        break

if alive:
    print('Congratulations! You win.')
else:
    print('Sorry, you failed.')

Add Game: Tetris

See: https://en.wikipedia.org/wiki/Tetris

Prototype:

"""Game of Tetris for Liftoff Interview

Written by Grant Jenks
Copyright 2019

"""

import atexit
import collections
import itertools
import random
import sqlite3
import threading
import time

import console


original_terminal_state = console.get_terminal_mode()
atexit.register(console.set_terminal_mode, original_terminal_state)


class Game:
    "Game state for Tetris."
    def __init__(self, width, height, seed=None):
        self.random = random.Random(seed)
        self.width = width
        self.height = height
        self.board = collections.defaultdict(lambda: '#')
        for x in range(width):
            for y in range(height):
                self.board[x, y] = ' '
        self.active = True
        self.speed = 20
        self.next_letter = self.random.choice('IJLOSTZ')
        self.piece = self.next_piece()
        self.score = 0
        self.stash = None

    def draw(self):
        "Draw game state."
        print('Score:', self.score, end='\r\n')
        print('Level:', self.score // 4 + 1, end='\r\n')
        print('Next piece:', self.next_letter, end='\r\n')
        print('Stash piece:', 'no' if self.stash is None else 'yes', end='\r\n')
        print('*' * (self.width + 2), end='\r\n')
        for y in range(self.height):
            print('|', end='')
            for x in range(self.width):
                if (x, y) in self.piece:
                    print('@', end='')
                else:
                    print(self.board[x, y], end='')
            print('|', end='\r\n')
        print('*' * (self.width + 2), end='\r\n')

    def next_piece(self):
        "Create a new piece, on collision set active to False."
        letter = self.next_letter
        self.next_letter = self.random.choice('IJLOSTZ')
        if letter == 'I':
            piece = {(0, 0), (0, 1), (0, 2), (0, 3)}
        elif letter == 'J':
            piece = {(1, 0), (1, 1), (1, 2), (0, 2)}
        elif letter == 'L':
            piece = {(0, 0), (0, 1), (0, 2), (1, 2)}
        elif letter == 'O':
            piece = {(0, 0), (0, 1), (1, 0), (1, 1)}
        elif letter == 'S':
            piece = {(0, 1), (1, 0), (1, 1), (2, 0)}
        elif letter == 'T':
            piece = {(0, 0), (1, 0), (2, 0), (1, 1)}
        else:
            assert letter == 'Z'
            piece = {(0, 0), (1, 0), (1, 1), (2, 1)}
        offset = self.width // 2 - 1
        piece = {(x + offset, y) for x, y in piece}
        if self.collide(piece):
            self.end()
        return piece

    def end(self):
        self.active = False
        print('Game over! Press any key to quit.', end='\r\n')

    def tick(self, mark):
        "Notify the game of a clock tick."
        if mark % self.speed == 0:
            moved = self.move_piece(0, 1)
            if not moved:
                for x, y in self.piece:
                    self.board[x, y] = '#'
                self.collapse()
                self.piece = self.next_piece()
            self.draw()

    def collapse(self):
        "Collapse full lines."
        y = self.height - 1
        while y >= 0:
            full_line = all(self.board[x, y] == '#' for x in range(self.width))
            if full_line:
                z = y
                while z > 0:
                    for x in range(self.width):
                        self.board[x, z] = self.board[x, z - 1]
                    z -= 1
                for x in range(self.width):
                    self.board[x, 0] = ' '
                self.score += 1
                if self.score % 4 == 0:
                    self.speed -= 1
            else:
                y -= 1

    def collide(self, piece):
        "Check whether piece collides with others on board."
        return any(self.board[x, y] != ' ' for x, y in piece)

    def move_piece(self, x, y):
        "Move piece by delta x and y."
        new_piece = {(a + x, y + b) for a, b in self.piece}
        if self.collide(new_piece):
            return False
        self.piece = new_piece
        return True

    def rotate_piece(self):
        "Rotate piece."
        min_x = min(x for x, y in self.piece)
        max_x = max(x for x, y in self.piece)
        diff_x = max_x - min_x
        min_y = min(y for x, y in self.piece)
        max_y = max(y for x, y in self.piece)
        diff_y = max_y - min_y
        size = max(diff_x, diff_y)
        new_piece = set()
        for x, y in self.piece:
            pair = (min_x + size) - (y - min_y), min_y + (x - min_x)
            new_piece.add(pair)
        if self.collide(new_piece):
            return False
        self.piece = new_piece
        return True

    def move(self, key):
        "Update game state based on key press."
        if key == 'left':
            moved = self.move_piece(-1, 0)
        elif key == 'right':
            moved = self.move_piece(1, 0)
        elif key == 'down':
            moved = self.move_piece(0, 1)
        elif key == 'up':
            moved = self.rotate_piece()
        elif key == 'swap':
            if self.stash is None:
                self.stash = self.piece
                self.piece = self.next_piece()
            else:
                self.piece, self.stash = self.stash, self.piece
            if self.collide(self.piece):
                self.end()
            moved = True
        else:
            assert key == 'space'
            moved = self.move_piece(0, 1)
            while moved:
                moved = self.move_piece(0, 1)
            moved = True
        if moved:
            self.draw()


def draw_loop(game):
    """Draw loop.

    Handle console drawing in a separate thread.

    """
    game.draw()
    counter = itertools.count(start=1)
    while game.active:
        mark = next(counter)
        game.tick(mark)
        time.sleep(0.1)


def input_loop(game):
    """Input loop.

    Handle keyboard input in a separate thread.

    """
    while game.active:
        key = console.get_input()
        if key is None:
            continue
        elif key == 'quit':
            game.active = False
        else:
            assert key in ('left', 'down', 'right', 'up', 'space', 'swap')
            game.move(key)
    console.set_terminal_mode(original_terminal_state)
    print('Enter your name for leaderboard (blank to ignore):')
    name = input()
    if name:
        con = sqlite3.connect('tetris.sqlite3', isolation_level=None)
        con.execute('CREATE TABLE IF NOT EXISTS Leaderboard (name, score)')
        con.execute('INSERT INTO Leaderboard VALUES (?, ?)', (name, game.score))
        scores = con.execute('SELECT * FROM Leaderboard ORDER BY score DESC LIMIT 10')
        print('{0:<16} | {1:<16}'.format('Name', 'Score'))
        for pair in scores:
            print('{0:<16} | {1:<16}'.format(*pair))

def main():
    "Main entry-point for Tetris."
    game = Game(10, 10)
    draw_thread = threading.Thread(target=draw_loop, args=(game,))
    input_thread = threading.Thread(target=input_loop, args=(game,))
    draw_thread.start()
    input_thread.start()
    draw_thread.join()
    input_thread.join()


if __name__ == '__main__':
    main()

Insert in Tkinter App

I have a flappy bird app running. However, I am trying to run inside a Tkinter, but I am not able to. Is there a way to insert the game inside Tkinter Canvas.

Add support for localization

It would be wonderful if each student can to read the documentation (in a first moment, and the source-code comments in a second moment) in your own idiom, not only English.

"Step by Step" Build programs like Legos manuals

  • Product: Transform program into a set of pages of images of HTML Diffs which edit or construct a program.
  • Study Lego manuals and learn how to do it!
  • Publish these as "book manuals" and market to parents who want to teach their kids how to program.

Tooling

See step_by_step repo for an initial implementation.

  • Python's HTMLDiff - generate html diffs
  • PhantomJS - screen capture for html
  • Pygments - syntax highlighter
  • autopep8 - source code formatter

Methods

Annotated construction

Annotate with comments:

# >>> 1
def count(iterable):
    return sum(1 for val in iterable)
# <<<
# >>> 2
total = count(values)
# <<<

Automatic construction

def count(iterable):     # 1 Function start.
    total = 0            # 2 Block.
    for val in iterable: # 3 Loop start.
        total += 1       # 4 Block.
    return total         # 5 Function end.
  • Break at blocks/block headers.
  • Maybe this should allow for annotated diffs.

Edits

# >>> 6v1
foreground = (0, 0, 0)
# <<<
# >>> 6v2
foreground = (255, 0, 0)
# <<<
  • Tag: chunk name, diff name, next diff name
  • If chunk name repeats then it is the application of a diff?
  • Diffs should be ordered in a linked list for easy insertion.

'Tap' in memory.py

When a tile with 'not hide' state is tapped again, No. of that tile appears on the image.
It seems better to resolve this problem.

#29

Exception in Tkinter callback when quit life game

I tried to run the life game via freegames play life. When I click close button of the game window. I got Exception in Tkinter callback.

> freegames play life
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\Liu.D.H\AppData\Local\Programs\Python\Python311\Lib\tkinter\__init__.py", line 1948, in __call__
    return self.func(*args)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\Liu.D.H\AppData\Local\Programs\Python\Python311\Lib\tkinter\__init__.py", line 861, in callit
    func(*args)
  File "C:\Users\Liu.D.H\AppData\Local\Programs\Python\Python311\Lib\site-packages\freegames\life.py", line 61, in draw
    ontimer(draw, 100)
  File "<string>", line 5, in ontimer
turtle.Terminator

[guess.py] - add and display counter to guesses upon game ending

When user completes game successfully, display message displaying number of guesses it took to complete.
Include tests.

Message will be:
(if guesses > 1)
Congratulations! You guessed the right answer:[value]
It took you [number of guesses] guesses!

(if guesses == 1)
Congratulations! You guessed the right answer:[value]
It took you 1 guess!

a problem

When i try to run bounce.py it says there is no module called freegames
Zrzut ekranu 2021-06-23 073228

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.