From 69d13fdd214a86665f86cbea23fe598dc8bdf1e5 Mon Sep 17 00:00:00 2001 From: Thomas Thurman Date: Wed, 27 May 2009 01:09:53 -0400 Subject: [PATCH] Initial checkin --- Makefile | 18 +++ debian/README.Debian | 8 + debian/changelog | 6 + debian/compat | 1 + debian/control | 13 ++ debian/copyright | 39 +++++ debian/dirs | 2 + debian/files | 1 + debian/rules | 98 ++++++++++++ debian/sandcastle.substvars | 1 + sand.c | 345 +++++++++++++++++++++++++++++++++++++++++++ sandcastle.desktop | 9 ++ sandcastle.png | Bin 0 -> 5854 bytes sandcastle.xpm | 32 ++++ www/index.html | 11 ++ 15 files changed, 584 insertions(+) create mode 100644 Makefile create mode 100644 debian/README.Debian create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/dirs create mode 100644 debian/files create mode 100755 debian/rules create mode 100644 debian/sandcastle.substvars create mode 100644 sand.c create mode 100644 sandcastle.desktop create mode 100644 sandcastle.png create mode 100644 sandcastle.xpm delete mode 100644 welcome create mode 100644 www/index.html diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..508198e --- /dev/null +++ b/Makefile @@ -0,0 +1,18 @@ +all: sandcastle + +sandcastle: sand.c + gcc -g -O3 `pkg-config --cflags --libs gtk+-2.0 gdk-pixbuf-2.0 hildon-1 dbus-glib-1` sand.c -o sandcastle + +clean: + rm sandcastle + +install: sandcastle sandcastle.xpm sandcastle.desktop + install -d ${DESTDIR}/usr/bin + install sandcastle ${DESTDIR}/usr/bin + install -d ${DESTDIR}/usr/share/applications/hildon + install sandcastle.desktop ${DESTDIR}/usr/share/applications/hildon + install -d ${DESTDIR}/usr/share/pixmaps + install sandcastle.xpm ${DESTDIR}/usr/share/pixmaps + install -d ${DESTDIR}/usr/share/sandcastle + install sandcastle.png ${DESTDIR}/usr/share/sandcastle + diff --git a/debian/README.Debian b/debian/README.Debian new file mode 100644 index 0000000..bf64b94 --- /dev/null +++ b/debian/README.Debian @@ -0,0 +1,8 @@ +rfk for Debian +-------------- + + + + -- + + <> Thu, 19 Mar 2009 21:33:32 -0400 diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..19b18d1 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,6 @@ +sandcastle (0.01-1) unstable; urgency=low + + * Initial release + + -- Thomas Thurman Thu, 19 Mar 2009 21:33:32 -0400 + diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +5 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..c5d8678 --- /dev/null +++ b/debian/control @@ -0,0 +1,13 @@ +Source: sandcastle +Section: unknown +Priority: extra +Maintainer: Thomas Thurman +Build-Depends: debhelper (>= 5) +Standards-Version: 3.7.2 + +Package: sandcastle +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: A world full of sand + Sandcastle animates a world full of sand for Maemo. + diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..210831a --- /dev/null +++ b/debian/copyright @@ -0,0 +1,39 @@ +This package was debianized by + + <> on +Thu, 19 Mar 2009 21:33:32 -0400. + +It was downloaded from + +Upstream Author: + +Copyright: + +License: + + This package is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this package; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +On Debian systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL'. + +The Debian packaging is (C) 2009, + + <> and +is licensed under the GPL, see above. + + +# Please also look if there are files or directories which have a +# different copyright/license attached and list them here. diff --git a/debian/dirs b/debian/dirs new file mode 100644 index 0000000..ca882bb --- /dev/null +++ b/debian/dirs @@ -0,0 +1,2 @@ +usr/bin +usr/sbin diff --git a/debian/files b/debian/files new file mode 100644 index 0000000..97eebcd --- /dev/null +++ b/debian/files @@ -0,0 +1 @@ +sandcastle_0.01-1_armel.deb unknown extra diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..1987312 --- /dev/null +++ b/debian/rules @@ -0,0 +1,98 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + + + + +CFLAGS = -Wall -g + +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + CFLAGS += -O0 +else + CFLAGS += -O2 +endif + +configure: configure-stamp +configure-stamp: + dh_testdir + # Add here commands to configure the package. + + touch configure-stamp + + +build: build-stamp + +build-stamp: configure-stamp + dh_testdir + + # Add here commands to compile the package. + $(MAKE) + #docbook-to-man debian/sandcastle.sgml > rfk.1 + + touch $@ + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + + # Add here commands to clean up after the build process. + -$(MAKE) clean + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/sandcastle. + $(MAKE) DESTDIR=$(CURDIR)/debian/sandcastle install + + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples +# dh_install +# dh_installmenu +# dh_installdebconf +# dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_python +# dh_installinit +# dh_installcron +# dh_installinfo + dh_installman + dh_link + dh_strip + dh_compress + dh_fixperms +# dh_perl +# dh_makeshlibs + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/debian/sandcastle.substvars b/debian/sandcastle.substvars new file mode 100644 index 0000000..69c5948 --- /dev/null +++ b/debian/sandcastle.substvars @@ -0,0 +1 @@ +shlibs:Depends=libatk1.0-0 (>= 1.24.0), libc6 (>= 2.5.0-1), libcairo2, libdbus-1-3 (>= 1.1.4), libdbus-glib-1-2 (>= 0.76), libglib2.0-0 (>= 2.14.6-1osso1), libgtk2.0-0 (>= 2:2.12.9-0osso1), libhildon1, libpango1.0-0 diff --git a/sand.c b/sand.c new file mode 100644 index 0000000..e671d10 --- /dev/null +++ b/sand.c @@ -0,0 +1,345 @@ +/** + * Sandcastle - Falling sand game for Maemo 5 + * Copyright (c) 2009 Thomas Thurman + * This is a demonstration of the accelerometer. + * It's only a few hours' work and could stand to be improved in + * several ways: + * - use a sorted list of grains to speed up sand processing + * - add different colours of sand? + * - add various other stuff like plants, water, explosives... + * (as in the web game "Hell of Sand") + * + * I also haven't tracked down why it crashes sometimes when + * you run it from the launcher. Run it from a terminal as + * /usr/bin/sandcastle to get around this. + */ + +/** + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#include +#include +#include +#include +#include +#include + +GdkPixbuf *pixbuf; +GtkWidget *window, *area; +int width, height, rowstride; +int minx, maxx, miny, maxy; +DBusGProxy *dbus_proxy = NULL; +DBusGProxyCall *dbus_call = NULL; +guint32 *pixels = NULL; +GList *grains = NULL; + +const guint32 SAND = 0xff00ffff; +const guint32 WALL = 0xffffffff; +const guint32 EMPTY = 0xff000000; + +enum { + UP = 0, + UP_RIGHT = 1, + RIGHT = 2, + DOWN_RIGHT = 3, + DOWN = 4, + DOWN_LEFT = 5, + LEFT = 6, + UP_LEFT = 7 +}; + +int gravity = DOWN; +int there_is_gravity = TRUE; + +static inline guint32* +translate_pointer_by_direction(guint32 *src, int direction, int x, int y) +{ + static guint32 edge = WALL; + + switch (direction%8) { + case UP: + if (y<=0) return &edge; + return src-rowstride; + case UP_RIGHT: + if (y<=0 || x>=width) return &edge; + return (src-rowstride)+1; + case RIGHT: + if (x>=width) return &edge; + return src+1; + case DOWN_RIGHT: + if (x>=width || y>=height) return &edge; + return (src+rowstride)+1; + case DOWN: + if (y>=height) return &edge; + return src+rowstride; + case DOWN_LEFT: + if (x<=0 || y>=height) return &edge; + return (src+rowstride)-1; + case LEFT: + if (x<=0) return &edge; + return src-1; + case UP_LEFT: + if (x<=0 || y<=0) return &edge; + return (src-rowstride)-1; + } +} + +static gint +expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer data) +{ + gdk_draw_pixbuf (GDK_DRAWABLE(widget->window), + widget->style->fg_gc[GTK_WIDGET_STATE (widget)], + pixbuf, event->area.x, event->area.y, + event->area.x, event->area.y, + event->area.width, event->area.height, + GDK_RGB_DITHER_NONE, 0, 0); + return TRUE; +} + +static gboolean +tap_event (GtkWidget *widget, + GdkEventMotion *event, + gpointer user_data) +{ + int rx, ry; + + for (rx=-5; rx<=5; rx++) + for (ry=-5; ry<=5; ry++) + { + guint32 *p = pixels + (ry+(int)event->y)*rowstride + (rx+(int)event->x); + + if (*p==EMPTY) *p=SAND; + } + + gtk_widget_queue_draw_area (area, ((int)event->x)-5, ((int)event->y)-5, 10, 10); + minx=miny=0; + maxx=width; maxy=height; +} + +static void +orientation_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *data) +{ + gchar *s1, *s2, *s3; + gint x, y, z; + gchar facing = 0; + + if (dbus_g_proxy_end_call (proxy, call, NULL, + G_TYPE_STRING, &s1, + G_TYPE_STRING, &s2, + G_TYPE_STRING, &s3, + G_TYPE_INT, &x, + G_TYPE_INT, &y, + G_TYPE_INT, &z, + G_TYPE_INVALID)) { + + if (x<=-500) facing |= 0x10; + else if (x<=0) facing |= 0x20; + else if (x<=500) facing |= 0x30; + else facing |= 0x40; + + if (y<=-500) facing |= 0x1; + else if (y<=0) facing |= 0x2; + else if (y<=500) facing |= 0x3; + else facing |= 0x4; + + g_free(s1); g_free(s2); g_free(s3); + + there_is_gravity = TRUE; + + switch (facing) { + case 0x34: case 0x36: case 0x24: gravity=UP; break; + case 0x13: case 0x14: gravity=UP_RIGHT; break; + case 0x12: gravity=RIGHT; break; + case 0x11: gravity=DOWN_RIGHT; break; + case 0x21: case 0x31: gravity=DOWN; break; + case 0x41: gravity=DOWN_LEFT; break; + case 0x42: case 0x43: gravity=LEFT; break; + case 0x44: gravity=UP_LEFT; break; + default: + there_is_gravity=FALSE; + } + + } else { + g_warning ("Couldn't end the call!\n"); + } + dbus_call = NULL; +} + +gint +sand_sort (gpointer sand1, gpointer sand2) +{ + if (sand1newmaxx) newmaxx=x; + if (ynewmaxy) newmaxy=y; + } + p += xdelta; + } + } + + minx=newminx; if (minx>2) minx--; else minx=0; + maxx=newmaxx; if (maxx2) miny--; else miny=0; + maxy=newmaxy; if (maxymXB| zmLUWg(-Op1w3g^5rPLCH2_gw1CGteioSyeN=b3lreb0NI=gm3)+ijJLNJ0SsgqM*LD_*;|>=QR22}id#Kxx6Dq~avW8>ud4Mn5CHsy6L;lg001W;0RV>3KSuv4dDFnZ zaPog9!|ZZ&fz`e>p-_a>?AQj|;Km6Q#L@p%yv;HjO1c0naKl<>aP{vj_!mL^tt=Cs z>Djff9hzony3*X@EfW1Yjoa+T=*>IJFGh`(&KiR`c^n*c$(ejyDK?c!` zUT>z&?fu!PqLSC^FZ6=m#tJZU&*yslb zmd(WB2y2W#&D%WUATeCSglcEt!!9SR%~^l96trC8l=e9wrtL&bmV z+uwL$l-c|2R9Qus;I587I5dGt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0{bSp9pss{Tj6QqZLMVb_Oia7L75JYW_n zN0zFTf&qa^=h9yNV=^^*9w5P+X0}3l-bK#jh_T0iLxd{GQ}v_bi0hQK3lrzdnRfp1TM+(6TrT#mzee1rR6h=J5t8){?Bg-UELiVZ)yy;VQzODjf5~hKsrgZ+ZrB z*NqBITiy+bN;w&yKD;>Mkkjzdfv^B!(Md>$t5S%(M+Sc&A@NU;FfFz+^zDB|LI#K2 zILiK>5yyXumND|G%pzo%$LXB)@6_l2PPDnT&y{OC{diRT=a9SI@+M-MW5pW3r1))4 z>f($G3N@Uf0x@ZEAHe?Bqao}en|=ea@PpI*wu>FrT%9D_Nb(?=5X|^_!J@M0RCAA8 zfrcEx{wdq1U#POa#6#G_5Rj4*wYFPzUy*o_d+B_+;KiB7DkGHGh4J}kmlSTlb0`7| z`8dgb->%T0UFdb;t!TD^J`{a&p7T_ds0METxx_DezqBRYYiZdtLAZ7r z`25q?lT{Ld#b?0D+Ya*+`o9-`U~%*78Q}?Cxijn-;ViaiV;7{@KT7W|>8HTX{L~uh z`brV;95t$GGKO87oiJCPM$xQ%dZ5zX!RJZRi=_(Q2%{{v-zK&~WG5YvqVq6|9yHq0 z*!t`~<(A!`8hylFWm(bfT!aZ+2F{{(?A|?O_kvZ&o`P4i3m>T1G{iY*lIWrDKg_F_ z-WeYwky{HA0uL-q)_6app3?Sandcastle + +

Sandcastle

+

A Falling Sand Game for Maemo

+ +

This is still being written. For now, you can visit +the garage page for sandcastle, +browse the source code, +or play a similar game in Java. +

+ -- 1.7.9.5