GithubHelp home page GithubHelp logo

wader / gtktetris Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 6.0 151 KB

Simple GTK tetris game

Home Page: https://github.com/wader/gtktetris

License: MIT License

C 88.71% Makefile 2.74% Shell 8.55%
gtk gtk2 tetris gtk3 game

gtktetris's Introduction

GtkTetris

A simple Tetris clone for the GTK library.

Requirements

  • GTK 2 >= 2.14
  • GTK 3 >= 3.14

Installation

Run

  • ./configure --prefix=/usr
  • make
  • make install

By default the GTK3 port is compiled, use --enable-gtk2 or --disable-gtk3 to compile the GTK2 port.

  • ./configure --prefix=/usr --enable-gtk2

The GTK3 version provides HiDPI support with:

  • GDK_SCALE=2 ./gtktetris - make UI 2x bigger
  • GDK_SCALE=3 ./gtktetris - make UI 3x bigger

You can also just run the compiled binary: src/gtktetris.

gtktetris's People

Contributors

wader avatar wdlkmpx avatar woodenshoe-wi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gtktetris's Issues

Performance

This is some technical info. Ideally the app should work fine in very slow machines.

Currently there are 2 block types (see Options dialog):

  1. image blocks (which are stored in cairo surfaces)
  2. "generated" blocks

The "image" block used to be faster with gdk_draw, using GdkPixmap, but now using only cairo it's slower. I notice visual glitches.

The reason for this is cairo_set_source_surface()

https://stackoverflow.com/questions/15773965/how-to-fast-redrawing-an-image-buffer

The "generated" block is fast, because it doesn't use cairo_set_source_surface(), which is slow with X.

So this is something to think about. There might be some workarounds or a different way to accelerate the drawing of the image blocks, which can be from .xpm, .svg, .png, .etc files.

The app should only read/write config files from HOME dir

Currently there is a problem with config files and stuff.

HIGHSCORE_PATH = /usr/local/games/gtktetris

Config files, stats, should be in:
$XDG_CONFIG_HOME/gtktetris/

The app must just assume that only 1 system user is going to use it. When it comes to names, perhaps there should be a dialog to specify a name.

Use vector graphics for blocks to support any scale

I remember having some idea about getting rid of GDK_SCALE and instead just scale the block images maybe using SVG etc.

I can see if i can brush off my inkscape skills and draw some scaleable blocks SVGs

GTK 3 Support

GTK3 support while keeping gtk2 is feasible.

With a special gtkcompat.h things can become mostly gtk3 while still compiling with gtk2, and probably supporting gtk2+.

It might take a few days or weeks or months... some deprecated functions are a bit (or too) hard to replace (i.e GdkPixmap/Drawable to Cairo).

MS Windows support

This might not happen but is worth considering.

The project is small enough to try to compile it with mingw32 (msys) and produce some MS Windows binaries...

This requires some changes, specially to paths and who knows what else.

Build system

A build system would benefit the project greatly.

Something that works in old and new distros without the need of updates ... autotools perhaps.

To keep things in order, the source files should be moved to a new dir src/

macOS support

Great work! had a quick look at building on macOS

Builds and works fine with brew gtk+ formula (gtk 2), only had to change autogen.sh to use glibtoolize.

Screen Shot 2020-12-12 at 10 45 58

With GTK 3 (gtk+3 formula) I get a bunch of errors about undefined GDK_* identifiers and some about duplicate switch cases (maybe errors is confusing because it's trying to helpful with typos?).

...
interface.c:104:26: error: use of undeclared identifier 'GDK_Down'; did you mean 'GDK_DOT'?
    case GDK_space: case GDK_Down:
                         ^~~~~~~~
                         GDK_DOT
/usr/local/Cellar/gtk+3/3.24.24/include/gtk-3.0/gdk/gdkcursor.h:155:3: note: 'GDK_DOT' declared here
  GDK_DOT                 = 38,
  ^
interface.c:79:22: error: duplicate case value 'GDK_OK'
    case GDK_x: case GDK_X:
                     ^
...

Some other things i noticed:

  • Cmd-Q to quit is not working
  • Main and high-score show up in the top left corner
  • A bit annoying with high-score popping up after game ends, why did i do it like that? :) not sure what alternatives there are
  • Show next block is no enabled by default, it should i think?
  • Maybe remove the "Save settings" button and instead just always save settings?
  • Move "Show next block" into settings dialog? then maybe can remove "Settings" menu and have it under "Game" menu instead?

Keys

Years ago I used to play Tetris at https://tetrisfriends.com/ and Tetris Battle at Facebook (the same game).

I noticed a similar game can be found at tetris.com.

The keys in GtkTetris are mostly OK, except the Down arrow key with the hard drop.

I guess this image can be used in the Help dialog and the keys can be adjusted accordingly.
tetris_keys

HOLD - C is probably not implemented.

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.