5
# Author: Marco Scarpetta <marcoscarpetta02@gmail.com>
6
# Copyright: 2011 Marco Scarpeta
8
# This program is free software; you can redistribute it and/or modify it
9
# under the terms of the GNU General Public License as published by the Free
10
# Software Foundation; either version 3 of the License, or (at your option)
13
# This program is distributed in the hope that it will be useful, but WITHOUT
14
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18
# On Debian GNU/Linux systems, the full text of the GNU General Public License
19
# can be found in the file /usr/share/common-licenses/GPL-3.
23
tol = Object.speed/100
25
x2=Object.x+Object.width
27
y2=Object.y+Object.height
28
if Object.game.height-tol<y2<Object.game.height+tol:
29
Object.connected_events['collide'][0]('bottom',-1)
31
Object.connected_events['collide'][0]('top',-1)
33
Object.connected_events['collide'][0]('left',1)
34
if Object.game.width-tol<x2<Object.game.width+tol:
35
Object.connected_events['collide'][0]('right',1)
36
for dif_Object in Object.game.Objects:
37
if dif_Object != Object:
39
X2=dif_Object.x+dif_Object.width
41
Y2=dif_Object.y+dif_Object.height
42
if Y2-tol<y1<Y2+tol or Y1-tol<y2<Y1+tol:
43
if X1<=x1<=X2 or X1<=x2<=X2:
44
Object.connected_events['collide'][0](dif_Object,-1)
45
if X2-tol<x1<X2+tol or X1-tol<x2<X1+tol:
46
if Y1<=y1<=Y2 or Y1<=y2<=Y2:
47
Object.connected_events['collide'][0](dif_Object,1)
49
tol = Object.speed/100
52
x=Object.connected_events['position'][1][0]
53
y=Object.connected_events['position'][1][1]
54
if y-tol<y1<y+tol and x-tol<x1<x+tol:
55
Object.disconnect('position')
56
Object.connected_events['position'][0](Object)
57
def key_press_event(widget, data, options, Object, game):
58
function_data = Object.gtk_connected_events['key-press-event'][options]
59
if keys[options] == data.keyval:
60
function_data[0](function_data[1])
61
def key_release_event(widget, data, options, Object, game):
62
function_data = Object.gtk_connected_events['key-release-event'][options]
63
if keys[options] == data.keyval:
64
function_data[0](function_data[1])
65
def button_press_event(widget, data, options, Object, game):
66
if Object in game.Objects:
67
x1=int(Object.x)*Object.game.scale_ratio
68
x2=int(Object.x+Object.width)*Object.game.scale_ratio
69
y1=int(Object.y)*Object.game.scale_ratio
70
y2=int(Object.y+Object.height)*Object.game.scale_ratio
71
function_data = Object.gtk_connected_events['button-press-event'][options]
72
if x1<data.x<x2 and y1<data.y<y2:
73
function_data[0](Object, function_data[1])
74
def motion_notify_event(widget, data, options, Object, game):
75
function_data = Object.gtk_connected_events['motion-notify-event'][options]
76
function_data[0](function_data[1], data.x, data.y)
83
'key-press-event':key_press_event,
84
'key-release-event':key_release_event,
85
'button-press-event':button_press_event,
86
'motion-notify-event':motion_notify_event
89
def gtk_signals_dict():
91
for event in gtk_signals:
196
'ISO_Level3_Shift':65027,