[
  {
    "path": ".gitignore",
    "content": "# Byte-compiled / optimized / DLL files\n__pycache__/\n*.py[cod]\n*$py.class\n\n# C extensions\n*.so\n\n# Distribution / packaging\n.Python\nbuild/\ndevelop-eggs/\ndist/\ndownloads/\neggs/\n.eggs/\nlib/\nlib64/\nparts/\nsdist/\nvar/\nwheels/\npip-wheel-metadata/\nshare/python-wheels/\n*.egg-info/\n.installed.cfg\n*.egg\nMANIFEST\n\n# PyInstaller\n#  Usually these files are written by a python script from a template\n#  before PyInstaller builds the exe, so as to inject date/other infos into it.\n*.manifest\n*.spec\n\n# Installer logs\npip-log.txt\npip-delete-this-directory.txt\n\n# Unit test / coverage reports\nhtmlcov/\n.tox/\n.nox/\n.coverage\n.coverage.*\n.cache\nnosetests.xml\ncoverage.xml\n*.cover\n.hypothesis/\n.pytest_cache/\n\n# Translations\n*.mo\n*.pot\n\n# Django stuff:\n*.log\nlocal_settings.py\ndb.sqlite3\ndb.sqlite3-journal\n\n# Flask stuff:\ninstance/\n.webassets-cache\n\n# Scrapy stuff:\n.scrapy\n\n# Sphinx documentation\ndocs/_build/\n\n# PyBuilder\ntarget/\n\n# Jupyter Notebook\n.ipynb_checkpoints\n\n# IPython\nprofile_default/\nipython_config.py\n\n# pyenv\n.python-version\n\n# pipenv\n#   According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.\n#   However, in case of collaboration, if having platform-specific dependencies or dependencies\n#   having no cross-platform support, pipenv may install dependencies that don't work, or not\n#   install all needed dependencies.\n#Pipfile.lock\n\n# celery beat schedule file\ncelerybeat-schedule\n\n# SageMath parsed files\n*.sage.py\n\n# Environments\n.env\n.venv\nenv/\nvenv/\nENV/\nenv.bak/\nvenv.bak/\n\n# Spyder project settings\n.spyderproject\n.spyproject\n\n# Rope project settings\n.ropeproject\n\n# mkdocs documentation\n/site\n\n# mypy\n.mypy_cache/\n.dmypy.json\ndmypy.json\n\n# Pyre type checker\n.pyre/\n"
  },
  {
    "path": ".replit",
    "content": "language = \"python3\"\nrun = \"python -m asciiracer\"\n"
  },
  {
    "path": ".travis.yml",
    "content": "language: python\npython:\n  - \"3.6\"\n  - \"3.7\"\n  - \"nightly\"\ninstall:\n  - pip install -r requirements.txt\n  - pip install flake8\nbefore_script:\n  - flake8 .\nscript:\n  - pytest\ndeploy:\n  provider: pypi\n  user: \"UpGado\"\n  password:\n    secure: bDLod+Mf1eV5e1uE39qtrjR3OCp5NlsnXa+GdhtbRi6tgkgb63foVAB/z0F2kKxzTHWgT6Zl+IIH9m4bZPvpblITKeLke16gG6s1qoXPkEIYInBTOYhJxe9noHvox6mD9dcffX3MZv5O0UOYnujOm0Mb7iIASJzInL8o54ALF0jar8/MLcJPVE+xGYIIgperUhgZPHcAEvpYUZTGsJ4EAHiTnPaq4cFw7FGf7KJJXKZ1aiuI0nu1xJFSvVwrCKd0S96y3+2+xe/DocHap7ZX8fau5CwtQ4CSbXew7dv+U2mYv3hdxxxZh0if10IgIn2iNrw6Tomps98XLuzm5aPDX7eKBeSJdwrZ6rDh/SUODOr34yGSZoXE3eUThqRaSsy+JGwUYleG4HlxiR/KhdD+H1avrnOMQavP9FY3g93BGmnvtBPfcHg6gn46gxV1Z9zOvSRjlDn0erQ/UEZtCiy6to8OoRdXudxYffhfNcv9MlWyR+jPB9wqmJbGdM3Ao0WHwLFYFUNo1Z1/38rnGQwtdErwTU41GsnEYhgKD1Z38NRKnXnseYtGDvy66dugI2ukkxc5LK1V8Hu6r6WHeObQdUlMBAGZ4GOli0YAh5zi8RXcW9FR8xVeeYOD8/p5T4RQh5QMBMsdmkalnPzYf783oPS0YE/Pp0yY1tG9UxjsND0=\n  on:\n    tags: true\n    python: \"3.7\"\n  distributions: \"sdist bdist_wheel\"\n"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2019 Ahmed Gado\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "```\n                    _ _                           \n     /\\            (_(_)                          \n    /  \\   ___  ___ _ _   _ __ __ _  ___ ___ _ __ \n   / /\\ \\ / __|/ __| | | | '__/ _` |/ __/ _ | '__|\n  / ____ \\\\__ | (__| | | | | | (_| | (_|  __| |   \n /_/    \\_|___/\\___|_|_| |_|  \\__,_|\\___\\___|_|   \n```                                              \n                                                  \n\n\n\n![PyPI](https://img.shields.io/pypi/v/asciiracer?color=success&label=pypi%20package)\n[![Build Status](https://travis-ci.com/UpGado/ascii_racer.svg?branch=master)](https://travis-ci.com/UpGado/ascii_racer)\n![GitHub last commit](https://img.shields.io/github/last-commit/UpGado/ascii_racer)\n[![Downloads](https://pepy.tech/badge/asciiracer)](https://pepy.tech/project/asciiracer)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\nAn endless racing game that runs in the terminal. 100% Python.\n\n<p align=\"center\"><img src=\"https://raw.githubusercontent.com/UpGado/ascii_racer/master/docs/gameplay.gif\" alt=\"ascii-racer\"/></p>\n\n## Instructions\n\nCollect as many alcoholic drinks as possible, while avoiding the `Beer` drinks. The game is only key-based.\n\n| Keys | Role        |\n|------|-------------|\n| a    | Move Left   |\n| d    | Move Right  |\n| w    | Accelerate  |\n| s    |  Decelerate |\n| q    |  Quit game  |\n\n### Installation\n\n> ```diff\n> + Please report issues if you try to install and run into problems!\n> ```\n\nMake sure you are running at least Python 3.6.0\n\nInstall using pip:\n```bash\npip3 install asciiracer\n```\nor clone the repository and install manually:\n\n```bash\n$ git clone https://github.com/UpGado/ascii_racer.git\n$ cd ascii_racer && python3 setup.py install\n```\n\n### Start Game\nTo start the game, run either:\n```bash\n$ asciiracer\n$ python -m asciiracer\n```\n\n### Scoring\nThere are four different types of drinks that you can collect on the racetrack. \n* Vodka - 10 Points\n* Gin - 5 Points\n* $ - 1 Point\n* Beer - Negative 20 points\n\n### Contributions\n\n> ```diff\n> + If you think this is cool, fork it and make it cooler!\n> ```\n\nThis might be great practice if you want to learn Python, and you can personally reach out to me if you have any questions about the *simple but elegant* code base.\n\n#### Possible Improvements\n\n- Color support.\n- Curvy roads and more interesting tracks.\n- Multiplayer/Competitive racing.\n- *Your* creative idea.\n\nIf you encounter any problem or have any suggestions, please [open an issue](https://github.com/UpGado/ascii_racer/issues/new) or [send a PR](https://github.com/UpGado/ascii_racer/pulls).\n"
  },
  {
    "path": "asciiracer/__init__.py",
    "content": ""
  },
  {
    "path": "asciiracer/__main__.py",
    "content": "from . import game\n\n\ndef main():\n    game.run()\n\n\nmain()\n"
  },
  {
    "path": "asciiracer/ascii_factory.py",
    "content": "# All digits are 6 characters wide and 4 high\nnums = {\n    0:     ['██████',\n            '█    █',\n            '█    █',\n            '██████'],\n\n    1:     ['   █  ',\n            '   █  ',\n            '   █  ',\n            '   ▉  '],\n\n    2:     ['██████',\n            '     █',\n            '██████',\n            '█▄▄▄▄▄'],\n\n    3:     ['██████',\n            '     █',\n            '▀▀▀▀▀█',\n            '▄▄▄▄▄█'],\n\n    4:     ['█    █',\n            '█    █',\n            '█▄▄▄▄█',\n            '     █'],\n\n    5:     ['██████',\n            '█     ',\n            '▀▀▀▀▀█',\n            '▄▄▄▄▄█'],\n\n    6:     ['█▀▀▀▀█',\n            '█     ',\n            '█▀▀▀▀█',\n            '█▄▄▄▄█'],\n\n    7:     ['██████',\n            '   ▗█▛',\n            '  ▟█▛ ',\n            '▄██▛  '],\n\n    8:     ['█▀▀▀▀█',\n            '█    █',\n            '█▀▀▀▀█',\n            '█▄▄▄▄█'],\n\n    9:     ['█▀▀▀▀█',\n            '█▄▄▄▄█',\n            '     █',\n            '     █'],\n}\n\n\ndef num2str(num):\n    assert(0 <= num and num <= 99)\n    r_digit = num % 10\n    l_digit = (num - r_digit)/10\n    l_digit, r_digit = [nums[_] for _ in [l_digit, r_digit]]\n    string = []\n    for l_line, r_line in zip(l_digit, r_digit):\n        string.append(' '.join([l_line, r_line]))\n    return string\n"
  },
  {
    "path": "asciiracer/config.py",
    "content": "from .misc import get_terminal_size\n\n#\n# Definitions:\n# - [X]_STICKY_TIME: amount of time a key press of action [X]\n#                    sticks in the game\nGAME_SIZE = get_terminal_size()\nFPS = 60\n\n# Car movement\nSPEED_INCREMENT = 1\nSPEED_DECREMENT = -1\nBASE_SPEED = 5\nMAX_SPEED = 99\nSPEED_STICKY_TIME = 0.2\nSTEERING_STICKY_TIME = 0.5\nSTEERING_STEP = 0.06\n\n# Environment\nHORIZON = 0.5  # how far from top?\nTRACK_SLOPE = 0.7  # x = x0 - slope*y\nDEBRIS_SPEED_MULTIPLIER = 1.0\nMAX_NUM_DEBRIS = 20\n\n# Cars\nMAX_NUM_CARS = 4\n"
  },
  {
    "path": "asciiracer/environment.py",
    "content": "import random\nfrom collections import namedtuple\nfrom .config import HORIZON, TRACK_SLOPE, DEBRIS_SPEED_MULTIPLIER, \\\n                   MAX_NUM_DEBRIS\nfrom .misc import linear_interpolate\n\nSprite = namedtuple('Sprite', ['attrs', 'current_coords'])\n\n\ndef init(screen):\n    global width, height, horizon_y, left_track, right_track\n    height, width = screen.getmaxyx()\n    horizon_y = int(HORIZON*height)\n    left_track = (int(3*width/16), '▞', TRACK_SLOPE)\n    right_track = (int(13*width/16), '▚', -TRACK_SLOPE)\n\n\ndef in_range(y, x):\n    return 0 <= y and y <= height - 1 and \\\n           0 <= x and x <= width - 1\n\n\ndef draw_background(screen, state):\n    global width, height\n    background = ' '\n    for y in range(height):\n        for x in range(width-1):\n            screen.addstr(y, x, background)\n\n\ndef draw_statusbar(screen, state):\n    status = '|'.join([f\"Time: {state['time']:.2f} seconds\",\n                      f\"Score: {state['score']}\"])\n    screen.addstr(0, 0, status)\n\n\ndef draw_tracks(screen, state):\n    global left_track, right_track, height, horizon_y\n    for (x0, character, slope) in [left_track, right_track]:\n        for y in range(horizon_y, height):\n            x = x0+int(slope*(height-1-y))\n            if y <= horizon_y + 5:\n                c = character\n                character = '$'\n            screen.addstr(y, x, character)\n            if y <= horizon_y + 5:\n                character = c\n\n\ndef spawn_debris(state, x_ranges):\n    debris_list = [[u'/\\\\',\n                    u'\\\\/'],\n                   ['*'],\n                   ['#']]\n    return spawn_sprite(state, x_ranges, debris_list, DEBRIS_SPEED_MULTIPLIER)\n\n\ndef spawn_money(state, x_ranges):\n    def martini_glass(ch):\n        return [r'╲___╱',\n                f\" ╲{ch}╱ \",\n                r'  ╿   ',\n                r'  ┴  ']\n\n    def beer_can():\n        return [r'┌-/-┐',\n                r'|   |',\n                r'|BUD|',\n                r'|   |',\n                r'└---┘']\n\n    def dollar_bill():\n        return [r'     ',\n                r'┌---┐',\n                r'|$1$|',\n                r'└---┘',\n                r'     ']\n    money_list = [(martini_glass('V'), 10),\n                  (dollar_bill(), 1),\n                  (martini_glass('G'), 5),\n                  (beer_can(), -20),\n                  (beer_can(), -20),\n                  (beer_can(), -20)]\n    return spawn_sprite(state, x_ranges, money_list, 1)\n\n\ndef spawn_sprite(state, x_ranges, sprites, speed_multiplier):\n    sprite_design = random.choice(sprites)\n\n    y0 = horizon_y\n    x_range = random.choice(x_ranges)\n    x0 = random.randint(*x_range)\n    t0 = state['time']\n    new_sprite = Sprite((sprite_design, y0, x0, t0, speed_multiplier),\n                        None)\n    return new_sprite\n\n\ndef draw_debris(screen, state):\n    top_track_offset = int(horizon_y*TRACK_SLOPE) - 2\n    x_ranges = [(0, left_track[0]+top_track_offset),\n                (right_track[0]-top_track_offset, width-1)]\n    draw_sprite(screen, state, 'debris', MAX_NUM_DEBRIS,\n                x_ranges, spawn_debris)\n\n\ndef draw_money(screen, state):\n    top_track_offset = int(horizon_y*TRACK_SLOPE) + 2\n    x_ranges = [(left_track[0]+top_track_offset,\n                right_track[0]-top_track_offset)]\n    draw_sprite(screen, state, 'money', 1, x_ranges, spawn_money)\n\n\ndef draw_sprite(screen, state, key, max_num, x_ranges, spawn_func):\n    num_missing_sprites = max_num - len(state[key])\n    if num_missing_sprites > 0:\n        for _ in range(num_missing_sprites):\n            state[key].append(spawn_func(state, x_ranges))\n    draw_parallax(state[key], screen, state)\n\n\ndef draw_parallax(sprites, screen, state):\n    for s, sprite_tuple in enumerate(sprites):\n        sprite, y0, x0, t0, speed_multiplier = sprite_tuple.attrs\n        if type(sprite) is tuple:\n            sprite_design = sprite[0]\n        else:\n            sprite_design = sprite\n        speed = state['speed']*speed_multiplier\n        step = parallax_slope(x0)\n        y = y0 + int(speed*(state['time']-t0))\n        x = x0 + int((y0-y)*step)\n        if in_range(y+len(sprite_design), x):\n            for i, line in enumerate(sprite_design):\n                screen.addstr(y+i, x, line)\n            sprites[s] = Sprite((sprite, y0, x0, t0, speed_multiplier),\n                                ((y, y+i), (x, x+len(line))))\n        else:\n            sprites.remove(sprite_tuple)\n\n\ndef draw_horizon(screen, state):\n    for x in range(width):\n        screen.addstr(horizon_y, x, '-')\n\n\ndef draw_car(screen, state):\n    car = [r'      ____________     ',\n           r'     /            \\    ',\n           r'  ▉▉|      RrrrR   |▉▉  ',\n           r'  ▉▉|  CA  R     R |▉▉  ',\n           r'  ▉▉ \\____________/ ▉▉   ']\n\n    car_width = len(car[0])\n    offset = 2  # offset from track\n    x0 = left_track[0]+car_width/2+offset\n    x1 = right_track[0]-car_width/2-offset\n    car_center_x = linear_interpolate(-1, x0, 1, x1, state['car_x'])\n    start_x = int(car_center_x - car_width / 2)\n    for offset, line in enumerate(reversed(car)):\n        y = height-1-offset\n        x = start_x + len(line)\n        screen.addstr(y, start_x, line)\n    y_coords = (height-1-offset, height-1)\n    x_coords = (start_x, x)\n    state['car'] = Sprite(None, (y_coords, x_coords))\n\n\ndef parallax_slope(x0):\n    # using top end of tracks as reference\n    top_track_offset = int(horizon_y*TRACK_SLOPE)\n    x_range = (left_track[0]+top_track_offset, right_track[0]-top_track_offset)\n    return linear_interpolate(x_range[0], TRACK_SLOPE,\n                              x_range[1], -TRACK_SLOPE, x0)\n"
  },
  {
    "path": "asciiracer/game.py",
    "content": "import curses\nfrom . import environment\nfrom .environment import draw_background, draw_tracks, draw_statusbar, \\\n                    draw_debris, draw_horizon, draw_car, draw_money\nfrom . import hud\nfrom .hud import draw_hud\nfrom .mechanics import update_state\nfrom .config import GAME_SIZE, FPS, BASE_SPEED\nfrom .misc import limit_fps\n\n\nSCENE = [draw_statusbar, draw_hud, draw_horizon, draw_tracks,\n         draw_debris, draw_car, draw_money, draw_background]\nstate = {'frames': 0,\n         'time': 0.0,  # seconds\n         'speed': BASE_SPEED,  # coord per frame\n         'car': None,\n         'car_x': 0,  # range -1:1\n         'car_steer_tuple': None,\n         'car_speed_tuple': None,\n         'debris': [],  # debris objects drawn in scene\n         'money': [],  # money objects drawn in scene\n         'score': 0,\n         'pdb': False}  # for testing\n\n\n@limit_fps(fps=FPS)\ndef draw_scene(screen):\n    for draw_element in reversed(SCENE):\n        draw_element(screen, state)\n    screen.refresh()\n\n\ndef main(screen):\n    screen.resize(*GAME_SIZE)\n    screen.nodelay(True)\n    environment.init(screen)\n    hud.init(screen)\n    while True:\n        draw_scene(screen)\n        key = screen.getch()\n        if key == ord('q'):\n            break\n        elif key == ord('p'):\n            state['pdb'] = True\n        else:\n            update_state(key, state)\n        state['frames'] += 1\n        state['time'] += 1/FPS\n    screen.clear()\n    screen.getkey()\n\n\ndef run():\n    curses.wrapper(main)\n"
  },
  {
    "path": "asciiracer/hud.py",
    "content": "from .ascii_factory import num2str\n\n\ndef init(screen):\n    global width, height\n    height, width = screen.getmaxyx()\n\n\ndef draw_speedmeter(screen, state):\n    margin_y, margin_x = 4, 4\n    hud = ['▛▀▀▀▀▀▀▀▀▀▀▀▀▀▜',\n           '▍             ▐',\n           '▍             ▐',\n           '▍             ▐',\n           '▍             ▐',\n           '▙▃▃▃▃▃▃▃▃▃▃▃▃▃▟',\n           '▍     MPH     ▐',\n           '▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀']\n    hud_width = len(hud[0])\n    speed = num2str(state['speed'])\n    for l, (hud_line, speed_line) in enumerate(zip(hud[1:-1], speed)):\n        hud[l+1] = hud_line[0] + speed_line + hud_line[-1]\n    x0 = width - margin_x - hud_width\n    y0 = margin_y\n    for y, line in enumerate(hud):\n        screen.addstr(y0+y, x0, line)\n\n\ndef draw_hud(screen, state):\n    draw_speedmeter(screen, state)\n"
  },
  {
    "path": "asciiracer/mechanics.py",
    "content": "from .config import SPEED_INCREMENT, SPEED_DECREMENT, BASE_SPEED, \\\n                   STEERING_STEP, MAX_SPEED, \\\n                   STEERING_STICKY_TIME, SPEED_STICKY_TIME\nfrom .misc import make_in_range, rectangle_overlap\n\n\ndef update_state(key, state):\n    steer_tuple = state['car_steer_tuple']\n    speed_tuple = state['car_speed_tuple']\n    # respond to keys\n    if key in {ord('w'), ord('s')}:\n        direction = 1 if key == ord('w') else -1\n        if speed_tuple is None or speed_tuple[1] != direction:\n            state['car_speed_tuple'] = (state['time'], direction)\n    elif key in {ord('d'), ord('a')}:\n        direction = 1 if key == ord('d') else -1\n        if steer_tuple is None or steer_tuple[1] != direction:\n            state['car_steer_tuple'] = (state['time'], direction)\n    elif key == -1:\n        # no key pressed\n        pass\n\n    if steer_tuple is not None:\n        update_steering(state, steer_tuple)\n\n    if speed_tuple is not None:\n        update_speed(state, speed_tuple)\n\n    collect_money(state)\n\n\ndef collect_money(state):\n    c_ys, c_xs = state['car'].current_coords\n    for money_object in state['money']:\n        ys, xs = money_object.current_coords\n        if rectangle_overlap(*c_ys, *c_xs, *ys, *xs):\n            (_, score), *args = money_object.attrs\n            state['score'] += score\n            state['money'].remove(money_object)\n\n\ndef update_steering(state, steer_tuple):\n    t0, direction = steer_tuple\n    elapsed_time = state['time'] - t0\n    if elapsed_time > STEERING_STICKY_TIME:\n        state['car_steer_tuple'] = None\n    else:\n        new_car_x = state['car_x'] + direction*STEERING_STEP\n        state['car_x'] = make_in_range(new_car_x, -1, 1)\n\n\ndef update_speed(state, speed_tuple):\n    t0, direction = speed_tuple\n    if state['time'] - t0 > SPEED_STICKY_TIME:\n        state['car_speed_tuple'] = None\n    else:\n        change = SPEED_INCREMENT if direction == 1 \\\n                                    else SPEED_DECREMENT\n        new_car_speed = state['speed'] + change\n        state['speed'] = make_in_range(new_car_speed,\n                                       BASE_SPEED, MAX_SPEED)\n"
  },
  {
    "path": "asciiracer/misc.py",
    "content": "import time\nfrom time import sleep\nimport os\nimport sys\n\n\ndef limit_fps(fps):\n    delay = 1/fps\n\n    def run_fps_capped(func):\n        def run(*args, **kwargs):\n            start_time = time.time()\n            func(*args, **kwargs)\n            elapsed_time = time.time() - start_time\n            sleep_time = delay-elapsed_time\n            if sleep_time >= 0:\n                sleep(sleep_time)\n        return run\n    return run_fps_capped\n\n\ndef linear_interpolate(x1, y1, x2, y2, x3):\n    y3 = y1 + (x3-x1)*(y2-y1)/(x2-x1)\n    return y3\n\n\ndef make_in_range(x, x_min, x_max):\n    x = min(x, x_max)\n    x = max(x_min, x)\n    return x\n\n\ndef rectangle_overlap(r1_y1, r1_y2, r1_x1, r1_x2,\n                      r2_y1, r2_y2, r2_x1, r2_x2):\n    if r2_x2 < r1_x1 or r2_x1 > r1_x2:\n        return False\n    elif r2_y2 < r1_y1 or r2_y1 > r1_y2:\n        return False\n    else:\n        return True\n\n\ndef get_terminal_size():\n    if sys.platform == 'win32':\n        return _get_terminal_size_windows()\n    else:\n        return _get_terminal_size_unix()\n\n\ndef _get_terminal_size_windows():\n    # http://code.activestate.com/recipes/440694-determine-size-of-console-window-on-windows/\n    from ctypes import windll, create_string_buffer\n\n    # stdin handle is -10\n    # stdout handle is -11\n    # stderr handle is -12\n\n    h = windll.kernel32.GetStdHandle(-12)\n    csbi = create_string_buffer(22)\n    res = windll.kernel32.GetConsoleScreenBufferInfo(h, csbi)\n\n    if res:\n        import struct\n        (_, _, _, _, _, left, top, right, bottom,\n         *_) = struct.unpack(\"hhhhHhhhhhh\", csbi.raw)\n        sizex = right - left + 1\n        sizey = bottom - top + 1\n    else:\n        sizex, sizey = 80, 25  # can't determine actual size\n    return (sizey, sizex)\n\n\ndef _get_terminal_size_unix():\n    return tuple(int(i) for i in os.popen('stty size', 'r').read().split())\n"
  },
  {
    "path": "asciiracer/tests/test_general.py",
    "content": "def func(x):\n    return x + 1\n\n\ndef test_answer():\n    assert func(3) == 4\n"
  },
  {
    "path": "requirements.txt",
    "content": ""
  },
  {
    "path": "setup.py",
    "content": "import setuptools\n\nwith open(\"README.md\", \"r\") as fh:\n    long_description = fh.read()\n\nsetuptools.setup(\n    name='asciiracer',\n    version='1.0.3',\n    python_requires='>=3.6.0',\n    author='Ahmed Gado',\n    author_email='ahmedehabg@gmail.com',\n    description='A racing game that runs in terminal',\n    long_description=long_description,\n    long_description_content_type=\"text/markdown\",\n    url='https://github.com/UpGado/ascii_racer',\n    packages=setuptools.find_packages(),\n    classifiers=[\n        \"Programming Language :: Python :: 3\",\n        \"License :: OSI Approved :: MIT License\",\n        \"Operating System :: OS Independent\",\n    ],\n    entry_points={\n        'console_scripts': [\n            'asciiracer = asciiracer.__main__:main'\n        ]\n    },\n    install_requires=[\n        'windows-curses >= 2.0;platform_system==\"Windows\"'\n    ]\n)\n"
  }
]