summaryrefslogtreecommitdiff
path: root/packages/numptyphysics
diff options
context:
space:
mode:
authorJulien Cassignol <ainulindale@gmail.com>2008-11-15 00:09:03 +0000
committerStefan Schmidt <stefan@datenfreihafen.org>2008-11-15 00:09:03 +0000
commitcb452087bb55cb426a711f5fbec60bf8173859e2 (patch)
tree8fb9e6990f6127666faffd5d7453cd7f478a2a75 /packages/numptyphysics
parentc3ddec6575892bd802b98db7a608cd4b57ae625b (diff)
numptyphysics: Update to rev 109, add some patches
Diffstat (limited to 'packages/numptyphysics')
-rw-r--r--packages/numptyphysics/numptyphysics/faster.patch22
-rw-r--r--packages/numptyphysics/numptyphysics/keyb.patch189
-rw-r--r--packages/numptyphysics/numptyphysics/keyb.pngbin0 -> 2571 bytes
-rw-r--r--packages/numptyphysics/numptyphysics/next.pngbin0 -> 7054 bytes
-rw-r--r--packages/numptyphysics/numptyphysics/numptyphysics.desktop9
-rw-r--r--packages/numptyphysics/numptyphysics/replay_off.patch166
-rw-r--r--packages/numptyphysics/numptyphysics_svn.bb30
7 files changed, 401 insertions, 15 deletions
diff --git a/packages/numptyphysics/numptyphysics/faster.patch b/packages/numptyphysics/numptyphysics/faster.patch
new file mode 100644
index 0000000000..e52c11e526
--- /dev/null
+++ b/packages/numptyphysics/numptyphysics/faster.patch
@@ -0,0 +1,22 @@
+--- old_Config.h 2008-11-05 13:45:25.000000000 +0200
++++ Config.h 2008-11-05 13:45:44.000000000 +0200
+@@ -36,14 +36,15 @@
+ # define SELECT_TOLERANCE 8.0f //PIXELS_PER_METREf)
+ # define CLICK_TOLERANCE 16 //PIXELs
+ #else
+-# define ITERATION_RATE 60 //fps
+-# define RENDER_RATE 20 //fps
+-# define SOLVER_ITERATIONS 10
++# define ITERATION_RATE 30 //fps
++# define RENDER_RATE 10 //fps
++# define SOLVER_ITERATIONS 5
+ # define JOINT_TOLERANCE 4.0f //PIXELs
+ # define SELECT_TOLERANCE 5.0f //PIXELS_PER_METREf)
+-# define CLICK_TOLERANCE 4 //PIXELs
++# define CLICK_TOLERANCE 16 //PIXELs
+ #endif
+
++
+ #define ITERATION_TIMESTEPf (1.0f / (float)ITERATION_RATE)
+ #define RENDER_INTERVAL (1000/RENDER_RATE)
+
diff --git a/packages/numptyphysics/numptyphysics/keyb.patch b/packages/numptyphysics/numptyphysics/keyb.patch
new file mode 100644
index 0000000000..aa82e67215
--- /dev/null
+++ b/packages/numptyphysics/numptyphysics/keyb.patch
@@ -0,0 +1,189 @@
+diff -ur oldÃ_Game.cppGame.cpp
+--- old_Game.cpp 2008-11-01 08:56:50.000000000 +0200
++++ Game.cpp 2008-11-01 10:48:33.000000000 +0200
+@@ -896,6 +896,7 @@
+ Window m_window;
+ Overlay *m_pauseOverlay;
+ Overlay *m_editOverlay;
++ Overlay *m_keyboardOverlay;
+ // DemoOverlay m_demoOverlay;
+ Os *m_os;
+ public:
+@@ -905,6 +906,7 @@
+ m_window(width,height,"Numpty Physics","NPhysics"),
+ m_pauseOverlay( NULL ),
+ m_editOverlay( NULL ),
++ m_keyboardOverlay( NULL ),
+ m_os( Os::get() )
+ //,m_demoOverlay( *this )
+ {
+@@ -1038,6 +1040,14 @@
+ && m_overlays.indexOf( m_pauseOverlay ) >= 0;
+ }
+
++ void togglePause()
++ {
++ if ( !m_pauseOverlay ) {
++ m_pauseOverlay = createIconOverlay( *this, "pause.png", 50, 50 );
++ }
++ toggleOverlay( m_pauseOverlay );
++ }
++
+ void edit( bool doEdit )
+ {
+ if ( m_edit != doEdit ) {
+@@ -1080,10 +1090,7 @@
+ case SDLK_SPACE:
+ case SDLK_KP_ENTER:
+ case SDLK_RETURN:
+- if ( !m_pauseOverlay ) {
+- m_pauseOverlay = createIconOverlay( *this, "pause.png", 50, 50 );
+- }
+- toggleOverlay( m_pauseOverlay );
++ togglePause();
+ break;
+ case SDLK_s:
+ case SDLK_F4:
+@@ -1094,6 +1191,10 @@
+ edit( !m_edit );
+ break;
+ case SDLK_d:
++ if ( !m_keyboardOverlay ) {
++ m_keyboardOverlay = createKeyboardOverlay(*this);
++ }
++ toggleOverlay( m_keyboardOverlay );
+ //toggleOverlay( m_demoOverlay );
+ break;
+ case SDLK_r:
+@@ -1154,6 +1165,19 @@
+ return false;
+ }
+
++ void undoLastStroke()
++ {
++ if ( m_createStroke ) {
++ m_scene.deleteStroke( m_createStroke );
++ m_createStroke = NULL;
++ } else {
++ m_scene.deleteStroke( m_scene.strokes().at(m_scene.strokes().size()-1) );
++ }
++ m_refresh = true;
++ }
++
++
++
+ bool handlePlayEvent( SDL_Event &ev )
+ {
+ switch( ev.type ) {
+@@ -1197,13 +1221,7 @@
+ break;
+ case SDL_KEYDOWN:
+ if ( ev.key.keysym.sym == SDLK_ESCAPE ) {
+- if ( m_createStroke ) {
+- m_scene.deleteStroke( m_createStroke );
+- m_createStroke = NULL;
+- } else {
+- m_scene.deleteStroke( m_scene.strokes().at(m_scene.strokes().size()-1) );
+- }
+- m_refresh = true;
++ undoLastStroke();
+ }
+ break;
+ default:
+@@ -1250,6 +1268,10 @@
+ {
+ Overlay *completedOverlay = createNextLevelOverlay(*this);
+
++ //toggle onScreenKeyboard ON
++ m_keyboardOverlay = createKeyboardOverlay(*this);
++ toggleOverlay( m_keyboardOverlay );
++
+ m_scene.draw( m_window, FULLSCREEN_RECT );
+ m_window.update( FULLSCREEN_RECT );
+
+diff -ur old_Game.h Game.h
+--- old_Game.h 2008-11-01 08:56:50.000000000 +0200
++++ Game.h 2008-11-01 09:27:22.000000000 +0200
+@@ -41,6 +41,9 @@
+ virtual void gotoLevel( int l, bool replay=false ) {}
+ Levels& levels() { return m_levels; }
+ virtual bool renderScene( Canvas& c, int level ) =0;
++ virtual void togglePause() {}
++ virtual void undoLastStroke() {}
++ virtual void edit( bool editting ) {}
+ bool m_quit;
+ bool m_edit;
+ bool m_refresh;
+diff -ur old_Overlay.cpp Overlay.cpp
+--- old_Overlay.cpp 2008-11-01 08:56:50.000000000 +0200
++++ Overlay.cpp 2008-11-01 09:45:57.000000000 +0200
+@@ -311,7 +311,51 @@
+ }
+ };
+
++class KeyboardOverlay : public IconOverlay
++{
++ int m_saving, m_sending;
++public:
++ KeyboardOverlay( GameControl& game )
++ : IconOverlay(game,"keyb.png",0,0,true),
++ m_saving(0),
++ m_sending(0)
++ {}
++
++ int index( int x, int y )
++ {
++ //these values correspond with keyb.png (in pixels)
++ int sizeOfElement = 20;
++
++ int colum = x/sizeOfElement;
++ int row = y/sizeOfElement;
++ return row*3+colum;
++ }
++
++ virtual void draw( Canvas& screen )
++ {
++ IconOverlay::draw( screen );
++ }
+
++ virtual bool onClick( int x, int y )
++ {
++ int i = index(x,y);
++ //printf("i= %d\n",i); return 0;
++ switch (i) {
++ case -1: return false;
++ case 0: m_game.undoLastStroke(); break;
++ case 1: m_game.togglePause(); break;
++ case 2: m_game.m_quit=true; break;
++ case 3: break;
++ case 4: m_game.edit( !m_game.m_edit ); break;
++ case 5: break;
++ case 6: m_game.gotoLevel(m_game.m_level-1); break;
++ case 7: m_game.gotoLevel(m_game.m_level); break;
++ case 8: m_game.gotoLevel(m_game.m_level+1); break;
++ default: break;
++ }
++ return true;
++ }
++};
+
+
+ Overlay* createIconOverlay( GameControl& game, const char* file,
+@@ -330,3 +383,8 @@
+ {
+ return new NextLevelOverlay( game );
+ }
++
++extern Overlay* createKeyboardOverlay( GameControl& game )
++{
++ return new KeyboardOverlay( game );
++}
+diff -ur old_Overlay.h Overlay.h
+--- old_Overlay.h 2008-11-01 08:56:50.000000000 +0200
++++ Overlay.h 2008-11-01 09:44:16.000000000 +0200
+@@ -45,4 +45,5 @@
+
+ extern Overlay* createNextLevelOverlay( GameControl& game );
+
++extern Overlay* createKeyboardOverlay( GameControl& game );
+ #endif //OVERLAY_H
diff --git a/packages/numptyphysics/numptyphysics/keyb.png b/packages/numptyphysics/numptyphysics/keyb.png
new file mode 100644
index 0000000000..4d77e88fd9
--- /dev/null
+++ b/packages/numptyphysics/numptyphysics/keyb.png
Binary files differ
diff --git a/packages/numptyphysics/numptyphysics/next.png b/packages/numptyphysics/numptyphysics/next.png
new file mode 100644
index 0000000000..21a94ce1dc
--- /dev/null
+++ b/packages/numptyphysics/numptyphysics/next.png
Binary files differ
diff --git a/packages/numptyphysics/numptyphysics/numptyphysics.desktop b/packages/numptyphysics/numptyphysics/numptyphysics.desktop
new file mode 100644
index 0000000000..b85265ab6f
--- /dev/null
+++ b/packages/numptyphysics/numptyphysics/numptyphysics.desktop
@@ -0,0 +1,9 @@
+[Desktop Entry]
+Name=numptyphysics
+Comment=Physics Game
+Note=Simulate Objects
+Exec=xrandr -o 3 && numptyphysics -geometry 640x480; xrandr -o 0
+Icon=star.png
+Type=Application
+Categories=Games
+
diff --git a/packages/numptyphysics/numptyphysics/replay_off.patch b/packages/numptyphysics/numptyphysics/replay_off.patch
new file mode 100644
index 0000000000..e2f606ea64
--- /dev/null
+++ b/packages/numptyphysics/numptyphysics/replay_off.patch
@@ -0,0 +1,166 @@
+--- old_Game.cpp 2008-10-30 15:46:15.000000000 +0200
++++ Game.cpp 2008-10-30 15:49:14.000000000 +0200
+@@ -1197,100 +1197,9 @@
+ }
+ };
+
+-class DemoRecorder
+-{
+-public:
+-
+- void start()
+- {
+- m_running = true;
+- m_log.empty();
+- m_log.capacity(512);
+- m_lastTick = 0;
+- m_lastTickTime = SDL_GetTicks();
+- }
+
+- void stop()
+- {
+- printf("stop recording: %d events\n",m_log.size());
+- m_running = false;
+- }
+
+- void tick()
+- {
+- if ( m_running ) {
+- m_lastTick++;
+- m_lastTickTime = SDL_GetTicks();
+- }
+- }
+
+- void record( SDL_Event& ev )
+- {
+- if ( m_running ) {
+- m_log.append( m_lastTick, SDL_GetTicks()-m_lastTickTime, ev );
+- }
+- }
+-
+- DemoLog& getLog() { return m_log; }
+-
+-private:
+- bool m_running;
+- DemoLog m_log;
+- int m_lastTick;
+- int m_lastTickTime;
+-};
+-
+-
+-class DemoPlayer
+-{
+-public:
+-
+- void start( const DemoLog* log )
+- {
+- m_playing = true;
+- m_log = log;
+- m_index = 0;
+- m_lastTick = 0;
+- m_lastTickTime = SDL_GetTicks();
+- printf("start playback: %d events\n",m_log->size());
+- }
+-
+- bool isRunning() { return m_playing; }
+-
+- void stop()
+- {
+- m_playing = false;
+- m_log = NULL;
+- }
+-
+- void tick()
+- {
+- if ( m_playing ) {
+- m_lastTick++;
+- m_lastTickTime = SDL_GetTicks();
+- }
+- }
+-
+- bool fetchEvent( SDL_Event& ev )
+- {
+- if ( m_playing
+- && m_index < m_log->size()
+- && m_log->at(m_index).t <= m_lastTick
+- && m_log->at(m_index).o <= SDL_GetTicks()-m_lastTickTime ) {
+- ev = m_log->at(m_index).e;
+- m_index++;
+- return true;
+- }
+- return false;
+- }
+-
+-private:
+- bool m_playing;
+- const DemoLog* m_log;
+- int m_index;
+- int m_lastTick;
+- int m_lastTickTime;
+-};
+
+
+ class Game : public GameParams
+@@ -1303,8 +1212,6 @@
+ IconOverlay m_pauseOverlay;
+ EditOverlay m_editOverlay;
+ // DemoOverlay m_demoOverlay;
+- DemoRecorder m_recorder;
+- DemoPlayer m_player;
+ Os *m_os;
+ public:
+ Game( int width, int height )
+@@ -1328,15 +1235,11 @@
+ if ( m_edit ) {
+ m_scene.protect(0);
+ }
+- m_recorder.stop();
+- m_player.stop();
+ if ( replay ) {
+ // for ( int i=0; i<m_recorder.getLog().size(); i++ ) {
+ // printf("DEMO: %s\n",m_recorder.getLog().asString(i).c_str());
+ // }
+- m_player.start( &m_recorder.getLog() );
+ } else {
+- m_recorder.start();
+ }
+ return true;
+ }
+@@ -1659,26 +1562,23 @@
+ while ( iterateCounter < ITERATION_RATE ) {
+ if ( !isPaused() ) {
+ m_scene.step();
+- m_recorder.tick();
+- m_player.tick();
+ }
+
+ SDL_Event ev;
+ bool more = true;
+ while ( more ) {
+ more = SDL_PollEvent(&ev);
+- if ( m_player.isRunning()
++ if ( 0
+ && ( ev.type==SDL_MOUSEMOTION ||
+ ev.type==SDL_MOUSEBUTTONDOWN ||
+ ev.type==SDL_MOUSEBUTTONUP ) ) {
+ more = false; //discard
+ }
+ if (!more) {
+- more = m_player.fetchEvent(ev);
++ more = 0;
+ }
+ if ( more ) {
+ bool handled = false;
+- m_recorder.record( ev );
+ for ( int i=m_overlays.size()-1; i>=0 && !handled; i-- ) {
+ handled = m_overlays[i]->handleEvent(ev);
+ }
+@@ -1703,8 +1603,6 @@
+ if ( m_scene.isCompleted() != isComplete && !m_edit ) {
+ isComplete = m_scene.isCompleted();
+ if ( isComplete ) {
+- m_player.stop();
+- m_recorder.stop();
+ showOverlay( completedOverlay );
+ } else {
+ hideOverlay( completedOverlay );
diff --git a/packages/numptyphysics/numptyphysics_svn.bb b/packages/numptyphysics/numptyphysics_svn.bb
index 6c833c2f01..1e5409f223 100644
--- a/packages/numptyphysics/numptyphysics_svn.bb
+++ b/packages/numptyphysics/numptyphysics_svn.bb
@@ -1,39 +1,39 @@
DESCRIPTION = "Numpty Physics is a drawing puzzle game in the spirit (and style?) \
of Crayon Physics using the same excellent Box2D engine."
-DEPENDS = "virtual/libsdl libsdl-image"
+DEPENDS = "virtual/libsdl libsdl-image libpng"
LICENSE = "GPL"
HOMEPAGE = "http://numptyphysics.garage.maemo.org/"
SECTION = "x11/games"
PV = "0.2+svnr${SRCREV}"
+inherit autotools
+
SRC_URI = "\
svn://garage.maemo.org/svn/${PN};module=trunk;proto=https \
http://wwwpub.zih.tu-dresden.de/~mkluge/numptyphysics_setup.tgz \
- file://gcc43.diff;patch=1 \
+ file://replay_off.patch;patch=1;pnum=0 \
+ file://next.png \
+ file://keyb.patch;patch=1;pnum=0 \
+ file://keyb.png \
+ file://faster.patch;patch=1;pnum=0 \
+ file://numptyphysics.desktop \
"
S = "${WORKDIR}/trunk"
EXTRA_S = "${WORKDIR}/local/packages/numptyphysics"
-# what an ugly buildsystem... handcrafted Makefiles... back to the stoneage
-export CCOPTS = "${CFLAGS} -I Box2D/Include"
-export LDOPTS = "${LDFLAGS} -lSDL -lSDL_image -lX11"
-
-do_configure() {
- for i in Config.h Makefile Game.cpp; do
- install -m 0644 ${EXTRA_S}/$i ${S}
- done
+do_configure_append() {
+ mv ../next.png data
+ mv ../keyb.png data
}
-do_install() {
+do_install_append() {
install -d ${D}${datadir}/numptyphysics
- install -d ${D}${bindir}
install -d ${D}${datadir}/pixmaps
install -d ${D}${datadir}/applications
- install -m 0755 ${S}/arm/Game ${D}${bindir}/numptyphysics
install -m 0644 ${EXTRA_S}/star.png ${D}${datadir}/pixmaps
- install -m 0644 ${EXTRA_S}/numptyphysics.desktop ${D}/${datadir}/applications
- cp -a ${EXTRA_S}/data/* ${D}/${datadir}/numptyphysics/
+ install -m 0644 ../numptyphysics.desktop ${D}/${datadir}/applications
+ cp -a ${EXTRA_S}/data/* data/keyb.png ${D}/${datadir}/numptyphysics/
}
FILES_${PN} += "${datadir}"