chingu 0.7.6.1 → 0.7.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/chingu.gemspec +2 -2
- data/examples/example10_traits_retrofy.rb +1 -1
- data/examples/example11_animation.rb +2 -2
- data/examples/example21.yml +43 -43
- data/examples/example21_sidescroller_with_edit.rb +3 -3
- data/lib/chingu.rb +1 -1
- data/lib/chingu/game_object.rb +47 -3
- data/lib/chingu/game_states/edit.rb +19 -25
- data/lib/chingu/gosu_ext/image.rb +12 -4
- data/lib/chingu/traits/bounding_box.rb +1 -2
- data/lib/chingu/window.rb +7 -0
- metadata +4 -4
data/chingu.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{chingu}
|
8
|
-
s.version = "0.7.6.
|
8
|
+
s.version = "0.7.6.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["ippa"]
|
12
|
-
s.date = %q{2010-06-
|
12
|
+
s.date = %q{2010-06-18}
|
13
13
|
s.description = %q{OpenGL accelerated 2D game framework for Ruby. Builds on Gosu (Ruby/C++) which provides all the core functionality. Chingu adds simple yet powerful game states, prettier input handling, deployment safe asset-handling, a basic re-usable game object and stackable game logic.}
|
14
14
|
s.email = %q{ippa@rubylicio.us}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -13,7 +13,7 @@ class Game < Chingu::Window
|
|
13
13
|
super(600,400)
|
14
14
|
self.caption = "Testing out new module-based traits (SPACE for more spaceships)"
|
15
15
|
self.input = { :space => :create_thing, :esc => :exit }
|
16
|
-
|
16
|
+
retrofy
|
17
17
|
create_thing(200,200)
|
18
18
|
end
|
19
19
|
|
@@ -14,8 +14,8 @@ class Game < Chingu::Window
|
|
14
14
|
super
|
15
15
|
@factor = 6
|
16
16
|
self.input = { :escape => :exit }
|
17
|
-
|
18
|
-
|
17
|
+
self.caption = "Chingu::Animation / retrofy example. Move with arrows!"
|
18
|
+
retrofy
|
19
19
|
Droid.create(:x => $window.width/2, :y => $window.height/2)
|
20
20
|
end
|
21
21
|
end
|
data/examples/example21.yml
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
- CogWheel:
|
3
3
|
:x: 1088.0
|
4
4
|
:y: 352.0
|
5
|
-
:angle:
|
5
|
+
:angle: 261.503276348003
|
6
6
|
:zorder: 95
|
7
7
|
:factor_x: 1.68525252525252
|
8
8
|
:factor_y: 1.68525252525252
|
@@ -10,7 +10,7 @@
|
|
10
10
|
- CogWheel:
|
11
11
|
:x: 448.0
|
12
12
|
:y: 416.0
|
13
|
-
:angle:
|
13
|
+
:angle: 213.943880498079
|
14
14
|
:zorder: 88
|
15
15
|
:factor_x: 1.68525252525252
|
16
16
|
:factor_y: 1.68525252525252
|
@@ -932,13 +932,13 @@
|
|
932
932
|
:y: 64.0
|
933
933
|
:angle: 0
|
934
934
|
:zorder: 100
|
935
|
-
:factor_x: 1.
|
936
|
-
:factor_y: 1.
|
935
|
+
:factor_x: 1.15315315315315
|
936
|
+
:factor_y: 1.51496462905859
|
937
937
|
:color: 4294967295
|
938
938
|
- CogWheel:
|
939
939
|
:x: 1792.0
|
940
940
|
:y: 320.0
|
941
|
-
:angle:
|
941
|
+
:angle: 182.497282580259
|
942
942
|
:zorder: 95
|
943
943
|
:factor_x: 1.68525252525252
|
944
944
|
:factor_y: 1.68525252525252
|
@@ -954,7 +954,7 @@
|
|
954
954
|
- CogWheel:
|
955
955
|
:x: 2464.0
|
956
956
|
:y: 288.0
|
957
|
-
:angle:
|
957
|
+
:angle: 14.156596894522
|
958
958
|
:zorder: 95
|
959
959
|
:factor_x: 1.68525252525252
|
960
960
|
:factor_y: 1.68525252525252
|
@@ -962,7 +962,7 @@
|
|
962
962
|
- CogWheel:
|
963
963
|
:x: 2460.0
|
964
964
|
:y: 960.0
|
965
|
-
:angle:
|
965
|
+
:angle: 184.497282580259
|
966
966
|
:zorder: 95
|
967
967
|
:factor_x: 1.68525252525252
|
968
968
|
:factor_y: 1.68525252525252
|
@@ -1074,7 +1074,7 @@
|
|
1074
1074
|
- Saw:
|
1075
1075
|
:x: 2304.0
|
1076
1076
|
:y: 42973.9722397467
|
1077
|
-
:angle:
|
1077
|
+
:angle: 148.973186119936
|
1078
1078
|
:zorder: 100
|
1079
1079
|
:factor_x: 0.317794486215539
|
1080
1080
|
:factor_y: 0.320401002506266
|
@@ -1082,7 +1082,7 @@
|
|
1082
1082
|
- Saw:
|
1083
1083
|
:x: 2016.0
|
1084
1084
|
:y: 32173.9806240522
|
1085
|
-
:angle:
|
1085
|
+
:angle: 341.066180171485
|
1086
1086
|
:zorder: 100
|
1087
1087
|
:factor_x: 0.398395989974937
|
1088
1088
|
:factor_y: 0.401002506265664
|
@@ -1090,7 +1090,7 @@
|
|
1090
1090
|
- Saw:
|
1091
1091
|
:x: 1696.0
|
1092
1092
|
:y: 14500.9946086338
|
1093
|
-
:angle:
|
1093
|
+
:angle: 51.8801650144799
|
1094
1094
|
:zorder: 100
|
1095
1095
|
:factor_x: 0.958395989974934
|
1096
1096
|
:factor_y: 0.961002506265664
|
@@ -1098,7 +1098,7 @@
|
|
1098
1098
|
- Saw:
|
1099
1099
|
:x: 1056.0
|
1100
1100
|
:y: 24036.9954416873
|
1101
|
-
:angle:
|
1101
|
+
:angle: 324.855862936146
|
1102
1102
|
:zorder: 100
|
1103
1103
|
:factor_x: 0.637794486215539
|
1104
1104
|
:factor_y: 0.640401002506266
|
@@ -1106,7 +1106,7 @@
|
|
1106
1106
|
- Saw:
|
1107
1107
|
:x: 1344.0
|
1108
1108
|
:y: 24036.9954416873
|
1109
|
-
:angle:
|
1109
|
+
:angle: 327.855862936147
|
1110
1110
|
:zorder: 100
|
1111
1111
|
:factor_x: 0.637794486215539
|
1112
1112
|
:factor_y: 0.640401002506266
|
@@ -1362,7 +1362,7 @@
|
|
1362
1362
|
- Saw:
|
1363
1363
|
:x: 2176.0
|
1364
1364
|
:y: 42813.9722397467
|
1365
|
-
:angle:
|
1365
|
+
:angle: 151.973186119936
|
1366
1366
|
:zorder: 100
|
1367
1367
|
:factor_x: 0.317794486215539
|
1368
1368
|
:factor_y: 0.320401002506266
|
@@ -1370,7 +1370,7 @@
|
|
1370
1370
|
- Saw:
|
1371
1371
|
:x: 1280.0
|
1372
1372
|
:y: 30824.098278027
|
1373
|
-
:angle:
|
1373
|
+
:angle: 268.052196057188
|
1374
1374
|
:zorder: 100
|
1375
1375
|
:factor_x: 0.47739348370927
|
1376
1376
|
:factor_y: 0.48
|
@@ -1378,7 +1378,7 @@
|
|
1378
1378
|
- Saw:
|
1379
1379
|
:x: 1055.0
|
1380
1380
|
:y: 91481.6743590043
|
1381
|
-
:angle:
|
1381
|
+
:angle: 19.6523317612529
|
1382
1382
|
:zorder: 100
|
1383
1383
|
:factor_x: 0.156390977443606
|
1384
1384
|
:factor_y: 0.158997493734336
|
@@ -1386,7 +1386,7 @@
|
|
1386
1386
|
- Saw:
|
1387
1387
|
:x: 960.0
|
1388
1388
|
:y: 91545.6743590044
|
1389
|
-
:angle:
|
1389
|
+
:angle: 22.6523317612509
|
1390
1390
|
:zorder: 100
|
1391
1391
|
:factor_x: 0.156390977443606
|
1392
1392
|
:factor_y: 0.158997493734336
|
@@ -1394,7 +1394,7 @@
|
|
1394
1394
|
- Saw:
|
1395
1395
|
:x: 1120.0
|
1396
1396
|
:y: 91545.6743590044
|
1397
|
-
:angle:
|
1397
|
+
:angle: 22.6523317612509
|
1398
1398
|
:zorder: 100
|
1399
1399
|
:factor_x: 0.156390977443606
|
1400
1400
|
:factor_y: 0.158997493734336
|
@@ -1402,7 +1402,7 @@
|
|
1402
1402
|
- Saw:
|
1403
1403
|
:x: 864.0
|
1404
1404
|
:y: 91481.6743590043
|
1405
|
-
:angle:
|
1405
|
+
:angle: 25.6523317612509
|
1406
1406
|
:zorder: 100
|
1407
1407
|
:factor_x: 0.156390977443606
|
1408
1408
|
:factor_y: 0.158997493734336
|
@@ -1410,7 +1410,7 @@
|
|
1410
1410
|
- Saw:
|
1411
1411
|
:x: 1247.0
|
1412
1412
|
:y: 27755.9489495749
|
1413
|
-
:angle:
|
1413
|
+
:angle: 283.946457785343
|
1414
1414
|
:zorder: 100
|
1415
1415
|
:factor_x: 0.477192982456137
|
1416
1416
|
:factor_y: 0.479799498746867
|
@@ -1418,7 +1418,7 @@
|
|
1418
1418
|
- Saw:
|
1419
1419
|
:x: 1088.0
|
1420
1420
|
:y: 54674.3885593251
|
1421
|
-
:angle:
|
1421
|
+
:angle: 243.763506646168
|
1422
1422
|
:zorder: 100
|
1423
1423
|
:factor_x: 0.236591478696738
|
1424
1424
|
:factor_y: 0.239197994987469
|
@@ -1426,7 +1426,7 @@
|
|
1426
1426
|
- Saw:
|
1427
1427
|
:x: 960.0
|
1428
1428
|
:y: 54674.3885593251
|
1429
|
-
:angle:
|
1429
|
+
:angle: 246.763506646169
|
1430
1430
|
:zorder: 100
|
1431
1431
|
:factor_x: 0.236591478696738
|
1432
1432
|
:factor_y: 0.239197994987469
|
@@ -1545,88 +1545,88 @@
|
|
1545
1545
|
:color: 4294967295
|
1546
1546
|
- Saw:
|
1547
1547
|
:x: 2272.0
|
1548
|
-
:y:
|
1549
|
-
:angle:
|
1548
|
+
:y: 1545.89456467036
|
1549
|
+
:angle: 146.639909411433
|
1550
1550
|
:zorder: 100
|
1551
1551
|
:factor_x: 0.398395989974937
|
1552
1552
|
:factor_y: 0.401002506265664
|
1553
1553
|
:color: 4294967295
|
1554
1554
|
- Saw:
|
1555
1555
|
:x: 1792.0
|
1556
|
-
:y:
|
1557
|
-
:angle:
|
1556
|
+
:y: 1492.18378106955
|
1557
|
+
:angle: 352.539543057765
|
1558
1558
|
:zorder: 100
|
1559
1559
|
:factor_x: 0.79859649122807
|
1560
1560
|
:factor_y: 0.801203007518797
|
1561
1561
|
:color: 4294967295
|
1562
1562
|
- Saw:
|
1563
1563
|
:x: 2112.0
|
1564
|
-
:y:
|
1565
|
-
:angle:
|
1564
|
+
:y: 1472.55311973017
|
1565
|
+
:angle: 50.5639527921968
|
1566
1566
|
:zorder: 100
|
1567
1567
|
:factor_x: 0.237794486215539
|
1568
1568
|
:factor_y: 0.240401002506266
|
1569
1569
|
:color: 4294967295
|
1570
1570
|
- Saw:
|
1571
1571
|
:x: 1504.0
|
1572
|
-
:y:
|
1573
|
-
:angle:
|
1572
|
+
:y: 1475.21132713439
|
1573
|
+
:angle: 4.15384615445959
|
1574
1574
|
:zorder: 100
|
1575
1575
|
:factor_x: 0.23719298245614
|
1576
1576
|
:factor_y: 0.239799498746867
|
1577
1577
|
:color: 4294967295
|
1578
1578
|
- Saw:
|
1579
1579
|
:x: 1344.0
|
1580
|
-
:y:
|
1581
|
-
:angle:
|
1580
|
+
:y: 1470.10650887575
|
1581
|
+
:angle: 7.15384615446169
|
1582
1582
|
:zorder: 100
|
1583
1583
|
:factor_x: 0.23719298245614
|
1584
1584
|
:factor_y: 0.239799498746867
|
1585
1585
|
:color: 4294967295
|
1586
1586
|
- Saw:
|
1587
1587
|
:x: 1152.0
|
1588
|
-
:y:
|
1589
|
-
:angle:
|
1588
|
+
:y: 1442.5380388842
|
1589
|
+
:angle: 10.1538461544596
|
1590
1590
|
:zorder: 100
|
1591
1591
|
:factor_x: 0.23719298245614
|
1592
1592
|
:factor_y: 0.239799498746867
|
1593
1593
|
:color: 4294967295
|
1594
1594
|
- Saw:
|
1595
1595
|
:x: 992.0
|
1596
|
-
:y:
|
1597
|
-
:angle:
|
1596
|
+
:y: 1484.67432950191
|
1597
|
+
:angle: 30.4853091222945
|
1598
1598
|
:zorder: 100
|
1599
1599
|
:factor_x: 0.156992481203007
|
1600
1600
|
:factor_y: 0.159598997493734
|
1601
1601
|
:color: 4294967295
|
1602
1602
|
- Saw:
|
1603
1603
|
:x: 800.0
|
1604
|
-
:y:
|
1605
|
-
:angle:
|
1604
|
+
:y: 1484.67432950191
|
1605
|
+
:angle: 33.4853091222945
|
1606
1606
|
:zorder: 100
|
1607
1607
|
:factor_x: 0.156992481203007
|
1608
1608
|
:factor_y: 0.159598997493734
|
1609
1609
|
:color: 4294967295
|
1610
1610
|
- Saw:
|
1611
1611
|
:x: 1248.0
|
1612
|
-
:y:
|
1613
|
-
:angle:
|
1612
|
+
:y: 1538.26656151419
|
1613
|
+
:angle: 184.999590383916
|
1614
1614
|
:zorder: 100
|
1615
1615
|
:factor_x: 0.317794486215539
|
1616
1616
|
:factor_y: 0.320401002506266
|
1617
1617
|
:color: 4294967295
|
1618
1618
|
- Saw:
|
1619
1619
|
:x: 928.0
|
1620
|
-
:y:
|
1621
|
-
:angle:
|
1620
|
+
:y: 1516.67432950192
|
1621
|
+
:angle: 36.4853091222945
|
1622
1622
|
:zorder: 100
|
1623
1623
|
:factor_x: 0.156992481203007
|
1624
1624
|
:factor_y: 0.159598997493734
|
1625
1625
|
:color: 4294967295
|
1626
1626
|
- Saw:
|
1627
1627
|
:x: 672.0
|
1628
|
-
:y:
|
1629
|
-
:angle:
|
1628
|
+
:y: 1454.14495530015
|
1629
|
+
:angle: 33.4853091222945
|
1630
1630
|
:zorder: 100
|
1631
1631
|
:factor_x: 0.156992481203007
|
1632
1632
|
:factor_y: 0.159598997493734
|
@@ -162,13 +162,13 @@ class Droid < Chingu::GameObject
|
|
162
162
|
def update
|
163
163
|
@image = @animation.next
|
164
164
|
self.each_collision(Block.inside_viewport) do |me, stone_wall|
|
165
|
-
if self.velocity_y < 0
|
165
|
+
if self.velocity_y < 0 # Hitting the ceiling
|
166
166
|
me.y = stone_wall.bb.bottom + me.image.height * self.factor_y
|
167
167
|
self.velocity_y = 0
|
168
|
-
else
|
168
|
+
else # Land on ground
|
169
|
+
@jumping = false
|
169
170
|
me.y = stone_wall.bb.top-1
|
170
171
|
end
|
171
|
-
@jumping = false
|
172
172
|
end
|
173
173
|
|
174
174
|
@animation = @animations[:scan] unless moved?
|
data/lib/chingu.rb
CHANGED
data/lib/chingu/game_object.rb
CHANGED
@@ -32,7 +32,7 @@ module Chingu
|
|
32
32
|
#
|
33
33
|
class GameObject < Chingu::BasicGameObject
|
34
34
|
attr_accessor :image, :x, :y, :angle, :center_x, :center_y, :factor_x, :factor_y, :color, :mode, :zorder
|
35
|
-
attr_reader :factor, :center
|
35
|
+
attr_reader :factor, :center, :height, :width
|
36
36
|
|
37
37
|
include Chingu::Helpers::InputClient # Adds input and input=
|
38
38
|
include Chingu::Helpers::RotationCenter # Adds easy and verbose modification of @center_x and @center_y
|
@@ -60,8 +60,8 @@ module Chingu
|
|
60
60
|
@angle = options[:angle] || 0
|
61
61
|
|
62
62
|
self.factor = options[:factor] || options[:scale] || $window.factor || 1.0
|
63
|
-
@factor_x = options[:factor_x] if options[:factor_x]
|
64
|
-
@factor_y = options[:factor_y] if options[:factor_y]
|
63
|
+
@factor_x = options[:factor_x].to_f if options[:factor_x]
|
64
|
+
@factor_y = options[:factor_y].to_f if options[:factor_y]
|
65
65
|
|
66
66
|
self.center = options[:center] || 0.5
|
67
67
|
|
@@ -82,6 +82,11 @@ module Chingu
|
|
82
82
|
@mode = options[:mode] || :default # :additive is also available.
|
83
83
|
@zorder = options[:zorder] || 100
|
84
84
|
|
85
|
+
if @image
|
86
|
+
self.width = options[:width] if options[:width]
|
87
|
+
self.height = options[:height] if options[:height]
|
88
|
+
end
|
89
|
+
|
85
90
|
### super ## This crashes
|
86
91
|
# Call setup, this class holds an empty setup() to be overriden
|
87
92
|
# setup() will be an easier method to override for init-stuff since you don't need to do super etc..
|
@@ -89,6 +94,45 @@ module Chingu
|
|
89
94
|
|
90
95
|
end
|
91
96
|
|
97
|
+
#
|
98
|
+
# Set an effective width for the object on screen.
|
99
|
+
# Chingu does this by setting factor_x depending on imge.width and width given.
|
100
|
+
# Usually better to have a large image and make it smaller then the other way around.
|
101
|
+
#
|
102
|
+
def width=(width)
|
103
|
+
@factor_x = width.to_f / @image.width.to_f
|
104
|
+
end
|
105
|
+
|
106
|
+
# Get effective on width by calculating it from image-width and factor
|
107
|
+
def width
|
108
|
+
(@image.width * @factor_x).abs
|
109
|
+
end
|
110
|
+
|
111
|
+
#
|
112
|
+
# Set an effective height for the object on screen.
|
113
|
+
# Chingu does this by setting factor_x depending on imge.width and width given.
|
114
|
+
# Usually better to have a large image and make it smaller then the other way around.
|
115
|
+
#
|
116
|
+
def height=(height)
|
117
|
+
@factor_y = height.to_f / @image.height.to_f
|
118
|
+
end
|
119
|
+
|
120
|
+
# Get effective on heightby calculating it from image-width and factor
|
121
|
+
def height
|
122
|
+
(@image.height.to_f * @factor_y).abs
|
123
|
+
end
|
124
|
+
|
125
|
+
# Set width and height in one swoop
|
126
|
+
def size=(size)
|
127
|
+
self.width, self.height = *size
|
128
|
+
end
|
129
|
+
|
130
|
+
# Get objects width and height in an array
|
131
|
+
def size
|
132
|
+
[self.width, self.height]
|
133
|
+
end
|
134
|
+
|
135
|
+
|
92
136
|
# Quick way of setting both factor_x and factor_y
|
93
137
|
def factor=(factor)
|
94
138
|
@factor = factor
|
@@ -133,8 +133,8 @@ module Chingu
|
|
133
133
|
# Scale down big objects, don't scale objects under [32, 32]
|
134
134
|
if game_object.image
|
135
135
|
game_object.factor_x = 32.0 / game_object.image.width if game_object.image.width > 32
|
136
|
-
game_object.factor_y = 32.0 / game_object.image.height if game_object.image.height >
|
137
|
-
game_object.cache_bounding_box
|
136
|
+
game_object.factor_y = 32.0 / game_object.image.height if game_object.image.height > 32
|
137
|
+
game_object.cache_bounding_box if game_object.respond_to?(:cache_bounding_box)
|
138
138
|
end
|
139
139
|
x += 40
|
140
140
|
end
|
@@ -166,6 +166,7 @@ module Chingu
|
|
166
166
|
|
167
167
|
if s = @selected_game_object
|
168
168
|
@text.text = "#{s.class.to_s} @ #{s.x.to_i} / #{s.y.to_i}"
|
169
|
+
@text.text = "Size: #{s.width.to_i} x #{s.height.to_i} Ratio: #{sprintf("%.2f",s.width/s.height)}"
|
169
170
|
@text.text += " [Scale: #{sprintf("%.2f", s.factor_x)}/#{sprintf("%.2f", s.factor_y)} Angle: #{s.angle.to_i} Z: #{s.zorder}]"
|
170
171
|
end
|
171
172
|
|
@@ -275,8 +276,8 @@ module Chingu
|
|
275
276
|
# Re-align all objects x/y offset in relevance to the cursor
|
276
277
|
#
|
277
278
|
selected_game_objects.each do |selected_game_object|
|
278
|
-
selected_game_object.options[:mouse_x_offset] = selected_game_object.x - self.mouse_x
|
279
|
-
selected_game_object.options[:mouse_y_offset] = selected_game_object.y - self.mouse_y
|
279
|
+
selected_game_object.options[:mouse_x_offset] = selected_game_object.x - self.mouse_x
|
280
|
+
selected_game_object.options[:mouse_y_offset] = selected_game_object.y - self.mouse_y
|
280
281
|
end
|
281
282
|
else
|
282
283
|
deselect_selected_game_objects unless holding?(:left_ctrl)
|
@@ -459,7 +460,10 @@ module Chingu
|
|
459
460
|
scale_down
|
460
461
|
end
|
461
462
|
end
|
462
|
-
|
463
|
+
|
464
|
+
def recache_bounding_boxes
|
465
|
+
selected_game_objects.each { |game_object| game_object.cache_bounding_box if game_object.respond_to?(:cache_bounding_box)}
|
466
|
+
end
|
463
467
|
def tilt_left
|
464
468
|
selected_game_objects.each { |game_object| game_object.angle -= 5 }
|
465
469
|
end
|
@@ -468,10 +472,13 @@ module Chingu
|
|
468
472
|
end
|
469
473
|
def scale_up
|
470
474
|
scale_up_x && scale_up_y
|
475
|
+
recache_bounding_boxes
|
471
476
|
end
|
472
477
|
def scale_down
|
473
478
|
scale_down_x && scale_down_y
|
479
|
+
recache_bounding_boxes
|
474
480
|
end
|
481
|
+
|
475
482
|
def inc_zorder
|
476
483
|
selected_game_objects.each { |game_object| game_object.zorder += 1 }
|
477
484
|
end
|
@@ -485,33 +492,18 @@ module Chingu
|
|
485
492
|
selected_game_objects.each { |game_object| game_object.alpha -= 1 }
|
486
493
|
end
|
487
494
|
def scale_up_x
|
488
|
-
selected_game_objects.each { |game_object| game_object.
|
495
|
+
selected_game_objects.each { |game_object| game_object.width += grid[0] }
|
489
496
|
end
|
490
497
|
def scale_up_y
|
491
|
-
selected_game_objects.each { |game_object| game_object.
|
498
|
+
selected_game_objects.each { |game_object| game_object.height += grid[1] }
|
492
499
|
end
|
493
500
|
def scale_down_x
|
494
|
-
selected_game_objects.each { |game_object|
|
495
|
-
inc = grid_factor_x_for(game_object)
|
496
|
-
game_object.factor_x -= inc
|
497
|
-
game_object.factor_x = inc if game_object.factor_x <= 0.01
|
498
|
-
}
|
501
|
+
selected_game_objects.each { |game_object| game_object.width -= grid[0] if game_object.width > grid[0] }
|
499
502
|
end
|
500
503
|
def scale_down_y
|
501
|
-
selected_game_objects.each { |game_object|
|
502
|
-
inc = grid_factor_y_for(game_object)
|
503
|
-
game_object.factor_y -= inc
|
504
|
-
game_object.factor_y = inc if game_object.factor_y <= 0.01
|
505
|
-
}
|
504
|
+
selected_game_objects.each { |game_object| game_object.height -= grid[1] if game_object.height > grid[1] }
|
506
505
|
end
|
507
|
-
|
508
|
-
def grid_factor_x_for(object)
|
509
|
-
@grid[0].to_f / object.image.width.to_f
|
510
|
-
end
|
511
|
-
def grid_factor_y_for(object)
|
512
|
-
@grid[0].to_f / object.image.height.to_f
|
513
|
-
end
|
514
|
-
|
506
|
+
|
515
507
|
def esc
|
516
508
|
deselect_selected_game_objects
|
517
509
|
@cursor_game_object = nil
|
@@ -572,6 +564,8 @@ module Chingu
|
|
572
564
|
|
573
565
|
game_object.options[:mouse_x_offset] = game_object.x - self.mouse_x
|
574
566
|
game_object.options[:mouse_y_offset] = game_object.y - self.mouse_y
|
567
|
+
|
568
|
+
game_object.cache_bounding_box if game_object.respond_to?(:cache_bounding_box)
|
575
569
|
return game_object
|
576
570
|
end
|
577
571
|
|
@@ -19,7 +19,6 @@
|
|
19
19
|
#
|
20
20
|
#++
|
21
21
|
|
22
|
-
|
23
22
|
#
|
24
23
|
# Core extensions to GOSU
|
25
24
|
# Some of these require the gem 'texplay'
|
@@ -44,10 +43,19 @@ module Gosu
|
|
44
43
|
# This could be used to make each pixel a sharp 4 pixelblock => retrofeeling.
|
45
44
|
#
|
46
45
|
def retrofy
|
47
|
-
|
48
|
-
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
|
49
|
-
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
|
46
|
+
Gosu::enable_undocumented_retrofication
|
50
47
|
self
|
48
|
+
|
49
|
+
#
|
50
|
+
# The below code depends on the bad opengl gem
|
51
|
+
# And it could affect other images anyhow...
|
52
|
+
# So let's use Gosu::enable_undocumented_retrofication until further notice.
|
53
|
+
#
|
54
|
+
|
55
|
+
#glBindTexture(GL_TEXTURE_2D, self.gl_tex_info.tex_name)
|
56
|
+
#glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
|
57
|
+
#glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
|
58
|
+
#self
|
51
59
|
end
|
52
60
|
end
|
53
61
|
end
|
@@ -56,8 +56,7 @@ module Chingu
|
|
56
56
|
return @cached_bounding_box
|
57
57
|
end
|
58
58
|
|
59
|
-
width = self.
|
60
|
-
height = self.image.height * self.factor_y.abs
|
59
|
+
width, height = self.size
|
61
60
|
|
62
61
|
if trait_options[:bounding_box][:scale]
|
63
62
|
width = width * trait_options[:bounding_box][:scale]
|
data/lib/chingu/window.rb
CHANGED
@@ -65,6 +65,13 @@ module Chingu
|
|
65
65
|
# Placeholder to be overwritten
|
66
66
|
def setup; end;
|
67
67
|
|
68
|
+
#
|
69
|
+
# Make all old and future images use hard borders. Hard borders + scaling = retro feel!
|
70
|
+
#
|
71
|
+
def retrofy
|
72
|
+
Gosu::enable_undocumented_retrofication
|
73
|
+
end
|
74
|
+
|
68
75
|
#
|
69
76
|
# Returns self inside GameState.initialize (a game state is not 'active' inside initialize())
|
70
77
|
# Or returns current active game state (as in a switched to or pushed game state)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chingu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 107
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
9
|
- 6
|
10
|
-
-
|
11
|
-
version: 0.7.6.
|
10
|
+
- 2
|
11
|
+
version: 0.7.6.2
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- ippa
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-06-
|
19
|
+
date: 2010-06-18 00:00:00 +02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|