Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 408909
Collapse All | Expand All

(-)file_not_specified_in_diff (-88 / +17 lines)
Line  Link Here
0
-- Makefile
0
++ Makefile
Lines 5-12 Link Here
5
# See file COPYRIGHT and COPYING
5
# See file COPYRIGHT and COPYING
6
6
7
# This you may want to change
7
# This you may want to change
8
RELEASE=no
9
DEBUG=no
10
prefix=/opt/cervi
8
prefix=/opt/cervi
11
incdir=$(prefix)/include
9
incdir=$(prefix)/include
12
bindir=$(prefix)/bin
10
bindir=$(prefix)/bin
Lines 18-81 Link Here
18
export
16
export
19
VERSION=0.0.4
17
VERSION=0.0.4
20
PACKAGE=cervi
18
PACKAGE=cervi
21
CFLAGS=
22
CXXFLAGS=
23
CFLAGS+=-Wall -D_GNU_SOURCE -D_REENTRANT -DVERSION=\"$(VERSION)\" \
19
CFLAGS+=-Wall -D_GNU_SOURCE -D_REENTRANT -DVERSION=\"$(VERSION)\" \
24
       $(shell gtk-config --cflags) $(shell pkg-config --cflags esound) \
20
       $(shell pkg-config --cflags gtk+-2.0) \
25
       -DDATADIR=\"$(datadir)\"
21
       -DDATADIR=\"$(datadir)\"
26
CXXFLAGS+=-Wall -D_GNU_SOURCE -D_REENTRANT -DVERSION=\"$(VERSION)\" \
22
CXXFLAGS+=-Wall -D_GNU_SOURCE -D_REENTRANT -DVERSION=\"$(VERSION)\" \
27
	 $(shell gtk-config --cflags) $(shell pkg-config --cflags esound) \
23
	 $(shell pkg-config --cflags gtk+-2.0) \
28
	 -DDATADIR=\"$(datadir)\"
24
	 -DDATADIR=\"$(datadir)\"
29
CPPFLAGS=
25
LDLIBS=-lm $(shell pkg-config --libs gtk+-2.0) \
30
LDFLAGS=
31
LDLIBS=-lm $(shell gtk-config --libs) $(shell pkg-config --libs esound) \
32
       -lpthread
26
       -lpthread
33
LINK.o=$(CXX) $(LDFLAGS) $(TARGET_ARCH)
27
LINK.o=$(CXX) $(LDFLAGS) $(TARGET_ARCH)
34
MAIN=cervi
28
MAIN=cervi
35
INSTALL=install -c -m 644
29
INSTALL=install -c -m 644
36
INSTALL_BIN=install -c -m 755 -D
30
INSTALL_BIN=install -c -m 755 -D
37
31
38
ifeq ($(RELEASE),yes)
32
.PHONY: all backup clean tags install
39
 CFLAGS += -O2
33
40
 CXXFLAGS += -O2
34
all: $(MAIN)
41
 LDFLAGS += -s -Wl,-O,2
42
endif
43
44
ifeq ($(DEBUG),yes)
45
 CFLAGS += -g -DDEBUG
46
 CXXFLAGS += -g -DDEBUG
47
else
48
 CFLAGS += -DNDEBUG
49
 CXXFLAGS += -DNDEBUG
50
endif
51
52
.PHONY: all backup clean tags DEBUG RELEASE install clean-music \
53
	install-music all-music
54
all: all-music $(MAIN)
55
all-music:
56
	$(MAKE) -C music
57
backup:
35
backup:
58
	./backup.sh $(PACKAGE)-$(VERSION)
36
	./backup.sh $(PACKAGE)-$(VERSION)
59
clean: clean-music
37
clean:
60
	$(RM) $(MAIN) *.o
38
	$(RM) $(MAIN) *.o
61
clean-music:
62
	$(MAKE) -C music clean
63
tags:
39
tags:
64
	ctags -R .
40
	ctags -R .
65
DEBUG: clean
41
install: all
66
	$(MAKE) DEBUG=yes
67
RELEASE: clean
68
	$(MAKE) RELEASE=yes
69
install: all install-music
70
	$(INSTALL_BIN) $(MAIN) $(DESTDIR)/$(bindir)/$(MAIN)
42
	$(INSTALL_BIN) $(MAIN) $(DESTDIR)/$(bindir)/$(MAIN)
71
install-music: all-music
72
	$(MAKE) -C music install
73
43
74
$(MAIN): main.o keymap.o game.o field.o music.o
44
$(MAIN): main.o keymap.o game.o field.o
75
	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
45
	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
76
main.o: main.cc field.h game.h music.h
46
main.o: main.cc field.h game.h
77
keymap.o: keymap.cc keymap.h
47
keymap.o: keymap.cc keymap.h
78
game.o: game.cc game.h field.h keymap.h music.h
48
game.o: game.cc game.h field.h keymap.h
79
game.h: keymap.h field.h
49
game.h: keymap.h field.h
80
field.o: field.cc field.h
50
field.o: field.cc field.h
81
music.o: music.cc music.h
51
++ game.cc
82
-- game.cc
Lines 13-19 Link Here
13
#include <cmath>
13
#include <cmath>
14
#include <gdk/gdkkeysyms.h>
14
#include <gdk/gdkkeysyms.h>
15
#include "game.h"
15
#include "game.h"
16
#include "music.h"
17
16
18
/*
17
/*
19
 * TODO:
18
 * TODO:
Lines 22-30 Link Here
22
 *             or bounce.
21
 *             or bounce.
23
 */
22
 */
24
23
25
// from main.cc for signalling music thread
26
extern void signal_mt();
27
28
namespace std {
24
namespace std {
29
    // colors of cerv's
25
    // colors of cerv's
30
    unsigned int colors[] = {
26
    unsigned int colors[] = {
Lines 107-116 Link Here
107
	    }
103
	    }
108
	}
104
	}
109
105
110
	m.reset(); // reset music to initial state
111
	m.speed = speed();
112
	m.play = true;
113
	signal_mt(); // signal it
114
    }
106
    }
115
107
116
    // delete all cervi
108
    // delete all cervi
Lines 119-126 Link Here
119
	for (int i=0; i<n_cervi; i++) {
111
	for (int i=0; i<n_cervi; i++) {
120
	    delete cervi[i];
112
	    delete cervi[i];
121
	}
113
	}
122
	m.play = false;
123
	signal_mt();
124
    }
114
    }
125
115
126
    // darken color
116
    // darken color
Lines 216-222 Link Here
216
		    cervi[i]->_speed += (ncollision - _ncollided) * 20;
206
		    cervi[i]->_speed += (ncollision - _ncollided) * 20;
217
		    cervi[i]->_rotspeed -= (ncollision - _ncollided);
207
		    cervi[i]->_rotspeed -= (ncollision - _ncollided);
218
		}
208
		}
219
	    m.speed = speed();
220
	}
209
	}
221
210
222
	// set place numbers
211
	// set place numbers
Lines 243-250 Link Here
243
	    for (int i=0; i<n_cervi; i++) {
232
	    for (int i=0; i<n_cervi; i++) {
244
		if (!cervi[i]->_collision) {
233
		if (!cervi[i]->_collision) {
245
		    cervi[i]->_collision = true;
234
		    cervi[i]->_collision = true;
246
		    m.play = false;
247
		    signal_mt();
248
		}
235
		}
249
	    }
236
	    }
250
	}
237
	}
Lines 310-316 Link Here
310
	    _cspeed += _speed * ticks / 1000;
297
	    _cspeed += _speed * ticks / 1000;
311
	    if (_cspeed > _speed)
298
	    if (_cspeed > _speed)
312
		_cspeed = _speed;
299
		_cspeed = _speed;
313
	    m.speed = _game->speed();
314
	}
300
	}
315
301
316
	if (_x < 1) {
302
	if (_x < 1) {
317
-- main.cc
303
++ main.cc
Lines 21-27 Link Here
21
#include <stdint.h>
21
#include <stdint.h>
22
#include "field.h"
22
#include "field.h"
23
#include "game.h"
23
#include "game.h"
24
#include "music.h"
25
using namespace std;
24
using namespace std;
26
25
27
// delete and set to NULL
26
// delete and set to NULL
Lines 66-72 Link Here
66
void chspeed(gpointer, gpointer n);
65
void chspeed(gpointer, gpointer n);
67
void updatefsize();
66
void updatefsize();
68
void chfsize(gpointer, gpointer n);
67
void chfsize(gpointer, gpointer n);
69
void chmusic(gpointer, gpointer n);
70
void about();
68
void about();
71
void quit();
69
void quit();
72
70
Lines 104-110 Link Here
104
 { "/Options/Field 1580x1100",	NULL,	 A chfsize,	4,
102
 { "/Options/Field 1580x1100",	NULL,	 A chfsize,	4,
105
     "/Options/Field 600x410"},
103
     "/Options/Field 600x410"},
106
 { "/Options/sep3",		NULL,	    	NULL,	0, "<Separator>" },
104
 { "/Options/sep3",		NULL,	    	NULL,	0, "<Separator>" },
107
 { "/Options/Mute music",	NULL,	 A chmusic,	0, "<ToggleItem>"},
108
 { "/_Help",			NULL,		NULL,	0, "<LastBranch>" },
105
 { "/_Help",			NULL,		NULL,	0, "<LastBranch>" },
109
 { "/_Help/_About...",		NULL,	       about,	0, NULL }
106
 { "/_Help/_About...",		NULL,	       about,	0, NULL }
110
};
107
};
Lines 334-344 Link Here
334
    updatefsize();
331
    updatefsize();
335
}
332
}
336
333
337
void chmusic(gpointer, gpointer n)
338
{
339
    m.playmusic = !m.playmusic;
340
}
341
342
// create backing pixmap (and show about)
334
// create backing pixmap (and show about)
343
gint configure_event(GtkWidget *widget, GdkEventConfigure *event)
335
gint configure_event(GtkWidget *widget, GdkEventConfigure *event)
344
{
336
{
Lines 471-491 Link Here
471
    return;
463
    return;
472
}
464
}
473
465
474
// music thread
475
pthread_t mt;
476
void* music_t(void*)
477
{
478
    signal(SIGUSR1,sigusr1);
479
    m.thread();
480
    return 0;
481
}
482
483
// signal music thread to stop waiting
484
void signal_mt()
485
{
486
    pthread_kill(mt,SIGUSR1);
487
}
488
489
// all loved C main function
466
// all loved C main function
490
int main(int argc, char *argv[])
467
int main(int argc, char *argv[])
491
{
468
{
Lines 502-520 Link Here
502
    // when everything is stable
479
    // when everything is stable
503
    //gdk_key_repeat_disable();
480
    //gdk_key_repeat_disable();
504
481
505
    // music thread init
506
    pthread_create(&mt,0,music_t,0);
507
508
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
482
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
509
    gtk_window_set_title(GTK_WINDOW(window), "GTK Cervi");
483
    gtk_window_set_title(GTK_WINDOW(window), "GTK Cervi");
510
    gtk_window_set_policy(GTK_WINDOW(window),0,0,1);
484
    gtk_window_set_policy(GTK_WINDOW(window),0,0,1);
511
485
512
    // set up fonts
486
    // set up fonts
513
    bigfont = gdk_font_load("-*-helvetica-bold-r-normal--34-*");
487
    bigfont = gdk_font_load("-*-helvetica-bold-r-normal--34-*");
514
    if (!bigfont) bigfont = gdk_font_ref(window->style->font);
488
    if (!bigfont) bigfont = gtk_style_get_font(window->style);
515
489
516
    medfont = gdk_font_load("-misc-fixed-medium-r-normal--14-*");
490
    medfont = gdk_font_load("-misc-fixed-medium-r-normal--14-*");
517
    if (!medfont) medfont = gdk_font_ref(window->style->font);
491
    if (!medfont) medfont = gtk_style_get_font(window->style);
518
    medfontheight = gdk_string_height(medfont,"GNU Iy") + 3;
492
    medfontheight = gdk_string_height(medfont,"GNU Iy") + 3;
519
493
520
    vbox = gtk_vbox_new(0, 0);
494
    vbox = gtk_vbox_new(0, 0);
Lines 569-575 Link Here
569
	for (int x=0; x<8; x++)
543
	for (int x=0; x<8; x++)
570
	    for (int y=0; y<8; y++)
544
	    for (int y=0; y<8; y++)
571
		gdk_image_put_pixel(im,x,y,gdk_rgb_xpixel_from_rgb(colors[i]));
545
		gdk_image_put_pixel(im,x,y,gdk_rgb_xpixel_from_rgb(colors[i]));
572
	label = gtk_image_new(im,0);
546
	label = gtk_image_new_from_image(im,0);
573
	gtk_box_pack_end(GTK_BOX(status), label, 0, 0, 0);
547
	gtk_box_pack_end(GTK_BOX(status), label, 0, 0, 0);
574
	gtk_widget_show(label);
548
	gtk_widget_show(label);
575
549

Return to bug 408909