User Tools

Site Tools


pygame_terminal

This is an old revision of the document!


PyGame Terminal

This is a version of a common type of starter program I use for many projects.

It requires PyGame.

The basic idea is that there will be a visible representation of an IBM PC VGA terminal, a DEC VT100 style character set, and so forth. It is a common starting program to replicate any of the BSDGAMES such as Robots, Life, Hack, or any program that requires a portable terminal or where access to the console is not superconvenient (ex. when using an IDE).

There are four basic components:

  • main.py
  • game.py
  • window.py
  • the character set

Additionally a small logo can be used, but if you comment out the logo line it still works.

  • I use a few different ones depending on the situation. I find that the ones included here are some of the best and/or most useful.
  • Example Logo:

The best source for old character sets is The Ultimate Oldschool PC Font Pack. I usually use an IBM_PC_VGA_8x16_PLUS TTF font. They're easy to work with in Python, Java, and C++. If you can't use TTF on the web there are woff and other versions available too. The plus means you can use unicode and/or ANSI codes which is often the only way to print IBM PC special characters. Perfect for those writing a ZZT clone!

The clacon2 font is also very good: http://webdraft.hu/fonts/classic-console/

main.py

<Code:Python> from Window import Window from Game import Game

def main():

  window = Window()
  window.setLogo("logo32x32.png")
  window.setCaption("Basic Console Starter Program")
  window.setSize(960, 640)
  window.setFont("PxPlus_IBM_VGA8.ttf", 32) # 32 point font
  game = Game(window)
  game.start()

if name

"__main__":

  main()

</code>

game.py

<Code:Python> </code>

window.py

<Code:Python> </code>

pygame_terminal.1695175654.txt.gz · Last modified: 2023/09/20 02:07 by appledog

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki