+
Skip to content

awth13/termadore

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Termadore

A nod to times past, in homage to the demo scene days of the Commodore64. Not to be taken seriously.

You are provided with a "screen" buffer based on your terminal dimensions and font size, along with some basic drawing tools.
What will you come up with?

Plus who doesn't love a bad play on words - we adore the terminal and the commodore.

Description

The draw buffer is made up of "pixels" which are pairs of utf-8 characters, referred to as shades.
Pairs are used to more closely resemble square pixels.

Black: '██'
Dark:  '▓▓'
Mid:   '▒▒'
Light: '░░'
Clear: '  '

Note: If your terminal is using a dark-mode colour scheme, then the above shade names may appear as if reversed.

Building

Currently in alpha testing. Default build is debug.
make in project root compiles or cleans the entire project. In demos and tests directories, compile targets may be specified by name.

# root
make
make BUILD=release
# demos/
make basic

Any files added to demos and tests directories are added to compile targets automatically.

Usage

The demos provide a reasonable example of usage.

General Approach

  • init_screen()
    • Analyse the terminal and allocate our "screen" buffer
  • while(1)
    • Create a "game loop" (traditionally an infinite while)
  • update()
    • Write your own update function(s) that draw to the buffer
  • render()
    • Draw to stdout
    • Frame rate is currently throttled to 30fps
  • kbhit()
    • Detect if/when the user has pressed a key
    • Good for a clean way to quit
  • cleanup()

Helper Functions

  • int get_width()
    • Current buffer width. May differ from actual terminal width.
  • int get_height()
    • Current buffer height. May differ from actual terminal height.
  • float get_dt()
    • Time in seconds since the last frame
  • void fill(shade)
    • Fill the entire buffer with a specific shade
  • void draw_line(x, y, len, shade)
    • Currently only horizontal
  • void set_pixel(x, y, shade)
  • void set_pixel_at_pen(shade)
    • Each write also steps the "pen" forward
  • void set_pen(x, y)

Todo

  • Write proper tests
  • Add colours
  • Allow user to set max FPS

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 92.3%
  • Makefile 7.7%
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载