A set of functions compatible with the TIC-80 platform

Overview

Pygame-80

pygame80

A set of functions from TIC-80 tiny computer platform ported to Pygame 2.0.1. Many of them are designed to work with the NumPy library to improve performance and per pixel access.

Some of the highlights of using this library are:

  • TIC-80 friendly
  • Highly customizable (any screen resolution, different screen modes, any number of audio channels, custom FPS)
  • Python as programming language
  • Practically no memory restrictions regarding the number of assets that can be used (code size, tilesets, spritesheets, music, sfx, color palette)
  • Expandable with the use of modules and libraries
  • Support of multiple audio and image formats

Dependencies

pip install pygame
pip install numpy

To run the demo program, you can use Thonny IDE or GNU/Linux shell or Windows shell

  • Thonny IDE: Open pygame80.py and press F5 or CTRL+R or CTRL+T
  • GNU/Linux shell:~@ python3 /path/pygame80.py
  • Windows shell: >python /path/pygame80.py

Functions

Functions available so far:

btn: use pygame.key.get_pressed
cls: use pygame.Surface.fill
circ & circb: use pygame.draw.circle
elli & ellib: use pygame.draw.elipse
exit: use pygame.quit and raise SystemExit
font: use pygame.Surface.subsurface and pygame.transform.scale
line: use pygame.draw.line
map: use pygame.Surface.subsurface and pygame.transform.scale
mget & mset: VRAM 2D array indexing, read/write
pix (!: numpy library dependant): use pygame.surfarray.pixels3d
print: use pygame.font.Font
rect & rectb: use pygame.draw.rect
sfx (!: note and speed parameters not supported by Pygame): use pygame.mixer.Sound, pygame.mixer.Channel and pygame.mixer.Sound.set_volume
spr (!: 0-255 index only): use pygame.Surface, pygame.Surface.subsurface, pygame.transform.flip, pygame.transform.scale and pygame.transform.rotate
time: use pygame.time.get_ticks
trace (!: builtins built-in module dependant): use builtins.print with ANSI escape sequences for RGB color
tstamp (!: time built-in module dependant): use time.time()
tri & trib: use pygame.draw.polygon

Some excluded functions:

TIC, SCN(n), OVR, BDR: Callbacks
peek & peek4, poke & poke4, memcpy & memset: Memory Mapping
fset & fget: Sprite flags

To do list:

  • btnp: button input
  • key & keyp: keyboard input
  • textri (!: pygame.gfxdraw library dependant): textured triangle
  • mouse: mouse input
  • TIC-80 smallfont: system font variant
  • pix (!: numpy library dependant): per pixel read or write access
  • sync: function for asset management (!: important)
  • wiki (20/23): for show examples and tutorials
You might also like...
Tic Tac Toe Python Game GUI

Tic Tac Toe is one of the most played games and is the best time killer game that you can play anywhere with just a pen and paper.

Tictactoe py tkinter canvas - Tic Tac Toe written in Python 3 with tkinter mainly using canvas

Python 3 Tic Tac Toe with tkinter This is a tkinter version of my Tic Tac Toe ga

A Python tic tac toe game
A Python tic tac toe game

Tic Tac Toe A Python tic tac toe game To start the game, run python3 main.py First, you have to select the game level. Today, it has three levels In a

Tic-Tac-Toe Game in python3 Tkinter
Tic-Tac-Toe Game in python3 Tkinter

Tic Tac Toe Tic-Tac-Toe Game in python3 Tkinter About: Tic Tac Toe or Noughts and Crosses as called in British is a pencil and paper game for two play

Tic Tac Toe Game build with Python
Tic Tac Toe Game build with Python

Tic Tac Toe Game Description two players who take turns marking the spaces in a three-by-three grid with X or O. The player who succeeds in placing th

A DDQN that learned to play tic tac toe by playing against itself
A DDQN that learned to play tic tac toe by playing against itself

TicTacToeAI A DDQN that learned to play tic tac toe by playing against itself Cu

This is a simple Tic Tac Toe game built with Python.

This is a simple Tic Tac Toe game built with Python.

A set of tools to help you with running a Project Zomboid game server (Linux only)

Project Zomboid Server Tools A set of tools to help you with running a Project Zomboid game server (Linux only). Features Install Project Zomboid Dedi

This is a python implementation of wordle, which uses the same set of available words as the hit game, Wordle

Wordle Game This is a python implementation of wordle, which uses the same set of available words as the hit game, Wordle. Play the game manually pyth

Comments
  • Why is it not possible to run the source code of the TIC() function?

    Why is it not possible to run the source code of the TIC() function?

    Problem (The module may look like this):

    #CODE0
    
    def TIC():
        #CODE1
    
    #CODE2
    

    Objective:

    • To take the source code of the TIC() function (#CODE1) from a module and execute it with exec().

    exec(#CODE1)

    Tested ideas, but with failures. Idea 1:

    • Import only the TIC() function using from __ import __, so as to read its code with inspect.getsource() and execute it with exec()

      Failure: If the code contains an instruction outside of the TIC() function that calls a TIC-80 function, an error of type NameError: name '__' is not defined ocurrs, in addition to the execution of standard Python function instructions such as print() and variable assignment that would only occur locally.

    Idea 2:

    • Read the .py file and execute all your code with exec(), to indirectly "import" the TIC() function, plus the user variables and functions globally, then read the code with inspect.getsource() and execute it with exec().

      Failure: OSError: could not get source code.

    Idea 3:

    • Import only the TIC() function without other instructions outside the TIC() function being executed (print(), TIC-80 functions, variable assignment) using source code, then read the code with inspect.getsource() and execute it with exec().

      Failure: OSError: source code not available

    Source code:

    import ast
    import types
    
    with open("__.py") as f:
       p = ast.parse(f.read())
    
    for node in p.body[:]:
        if not isinstance(node, ast.FunctionDef):
            p.body.remove(node)
    
    
    
    module = types.ModuleType("mod")
    code = compile(p, "mod.py", 'exec')
    sys.modules["mod"] = module
    exec(code, module.__dict__)
    
    from mod import TIC
    

    Idea 4:

    • Read the .py file and extract the TIC() function using text processing, then run your code with exec().

      Notes: This has not been tested

    Idea 5:

    • Execute the TIC() function globally, so that you can access the TIC-80 functions and assign global variables without any problems.

      Failure: Requires modifying the original code using the global keyword for each of the functions and variables that the module tries to use or assign as far as I know.

      Notes: This has not been tested

    Idea 6:

    • Import the module globally, so that no assignment errors or TIC-80 function calls occur in the initialization process.

      Notes: This has not been tested.

    Idea 7:

    • Import the module and use try except in case of allocation errors or TIC-80 function calls in the initialization process. in the initialization process.

      Failure: This does not work because with the first error that pops up, the import process is interrupted.

    Idea 8 (Discarded):

    • Inject code to the TIC() function by code or by text processing so that it can be executed correctly using decoardors.

      Failure: This approach does not work, since being a function, the code runs locally and errors occur in allocating or using TIC-80 functions.

    Idea 9 (Almost functional):

    • Use setattr and make all TIC-80 functions globally accessible at the level of standard functions (builtins).

      Failure: There are confusions with standard Python functions (cls, exit, map, print) and TIC-80 functions.

    opened by Kyuchumimo 0
Owner
null
Rudimentary CMD based implementation of the Tic Tac Toe game

Packages used: questionary random os (Requires Python >3.8 as walrus operators are used in the script) Contains the .py file (tictactoe.py) and an exe

Ashwin 1 Oct 15, 2021
Open source Board Games Like Tic Tac Toe, Connect 4, Ludo, Snakes and Ladder etc...

Board-Games What to do... Add Board games like Tic Tac Toe, Connect 4, Ludo, Snakes and Ladder etc... How to do... Fork the repo Clone the repo git cl

Bit By Bit 1 Oct 10, 2022
Input-based tic tac toe game made in only python.

Tic Tac Toe Tic Tac Toe is a game in which two players seek in alternate turns to complete a row, a column, or a diagonal with either three O's or thr

Ayza 5 Jun 26, 2022
This is a simple Tic-Tac-Toe game.

Tic-Tac-Toe Nosso famoso e tradicional Jogo da Velha, mas agora em Python. Development setup Para rodar o programa, basta instalar python em sua maqui

João Assalim 1 Oct 10, 2022
Tic tac toe game developed by naman in python

TIC TAC TOE GAME DEVELOPED BY NAMAN IN PYTHON . IT USES MINMAX ALGORITHM TO COMPETE IN DIFFICULTY MODE

Naman  Anand 4 Jun 24, 2022
This is a simple tic tac toe game that runs in the command line.

Tic Tac Toe Game This is a simple tic tac toe game that runs in the command line. Game Description: The game is made up of a square grid with 9 portio

Josias Aurel 2 Nov 12, 2022
Just a simple Tic Tac Toe game, built with Python

TicTacToe Author: Gabriel Lima Table of Contents About Getting Started Linux Windows About This is one of the first projects I built when I first star

null 1 Nov 28, 2021
Tic Tac Toe game developed in python; have 2 difficulty levels

Tic Tac Toe Game This is a code for Tic Tac Toe game in python. Game has 2 difficulty levels. Easy Hard To play the game, use this command in a LINUX

Akshat Mittal 1 Jun 25, 2022
An old time game Tic-Tac-toe

A Tic Tac Toe Bot This is the code repository for my article on Medium - Playing Games with Python - Tic Tac Toe, where I have tried to take the famou

Jigyanshu 0 Feb 25, 2022
Quantum version of the game Tic Tac Toe.

QTicTacToe Quantum version of the game Tic Tac Toe. This game was inspired by the game at this site. Installation The game requires the qiskit python

null 1 Jan 5, 2022