Giter Site home page Giter Site logo

alcornwill / gfx Goto Github PK

View Code? Open in Web Editor NEW
21.0 3.0 0.0 3.86 MB

fantasy console template in C, SDL2 and python

License: MIT License

Makefile 0.05% C 97.38% C++ 1.90% Objective-C 0.55% CMake 0.03% Batchfile 0.01% Python 0.09%
c sdl2 fantasy-console python tilemap 2d games

gfx's Introduction

gfx

screenshot

Fantasy console (similar to PICO8)

  • made with C and SDL2
  • has python27 binding
  • permissive license (MIT)
  • very minimal, great starting point for making your own fantasy console

building

I use gcc and mingw32.
To build the python module:

make gfx

(you will need to edit PYTHON_PATH and PYTHON in Makefile to point to your python installation)

To install in python, use distutils:

python setup.py install

All this does is copy gfx.pyd and SDL .dlls to site-packages.

Then it should work:
helloworld.py

from gfx import *

def __update__():
    color(YELLOW)
    text(0, 0, "Hello World")
    
def __name__ == "__main__":
    init()
    load_spritesheet("assets/spritesheet.bmp")
    mainloop()

The batch file build.bat will automatically build, install and test gfx for you (if you have PYTHON27 in your environment variables)

API

Drawing methods:

  • point
  • line
  • rect
  • rectfill
  • circ
  • circfill
  • text
  • sprite
  • map

see test.py for python example usage
see mapedit.c for C example usage
(run make mapedit to build the bin\mapedit.exe tool)

Asset Files

Unlike PICO8, gfx uses external asset files of conventional file formats

Asset Type File Format
spritesheet .bmp
map [binary format]
audio .wav

Currently you can only have one spritesheet, but you can load up to 24 .wav files.
Unusually, the spritesheet has to be 1-bit (black/white)
When drawing, the sprite color is determined by the current color (set with color())
I created my spritesheet with Graphics Gale

Input

there are 8 buttons:

Name Keyboard
A Z
B X
UP UP ARROW
DOWN DOWN ARROW
LEFT LEFT ARROW
RIGHT RIGHT ARROW
START ENTER
SELECT SPACE

gfx's People

Contributors

alcornwill avatar

Stargazers

 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

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.