chingu 0.7.6 → 0.7.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/chingu.gemspec +1 -1
- data/examples/example21.yml +71 -71
- data/examples/example21_sidescroller_with_edit.rb +8 -12
- data/lib/chingu.rb +1 -1
- data/lib/chingu/game_states/edit.rb +18 -6
- metadata +3 -2
data/chingu.gemspec
CHANGED
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: 244.888555657521
|
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: 230.558601188561
|
14
14
|
:zorder: 88
|
15
15
|
:factor_x: 1.68525252525252
|
16
16
|
:factor_y: 1.68525252525252
|
@@ -156,16 +156,16 @@
|
|
156
156
|
:y: 384.0
|
157
157
|
:angle: 0
|
158
158
|
:zorder: 100
|
159
|
-
:factor_x: 0.
|
160
|
-
:factor_y: 0.
|
159
|
+
:factor_x: 0.0717488789237668
|
160
|
+
:factor_y: 0.0717488789237668
|
161
161
|
:color: 4294967295
|
162
162
|
- Block:
|
163
163
|
:x: 192.0
|
164
164
|
:y: 384.0
|
165
165
|
:angle: 0
|
166
166
|
:zorder: 100
|
167
|
-
:factor_x: 0.
|
168
|
-
:factor_y: 0.
|
167
|
+
:factor_x: 0.0717488789237668
|
168
|
+
:factor_y: 0.0717488789237668
|
169
169
|
:color: 4294967295
|
170
170
|
- Block:
|
171
171
|
:x: 1664.0
|
@@ -580,16 +580,16 @@
|
|
580
580
|
:y: 384.0
|
581
581
|
:angle: 0
|
582
582
|
:zorder: 100
|
583
|
-
:factor_x: 0.
|
584
|
-
:factor_y: 0.
|
583
|
+
:factor_x: 0.0717488789237668
|
584
|
+
:factor_y: 0.0717488789237668
|
585
585
|
:color: 4294967295
|
586
586
|
- Block:
|
587
587
|
:x: 32.0
|
588
588
|
:y: 352.0
|
589
589
|
:angle: 0
|
590
590
|
:zorder: 100
|
591
|
-
:factor_x: 0.
|
592
|
-
:factor_y: 0.
|
591
|
+
:factor_x: 0.0717488789237668
|
592
|
+
:factor_y: 0.0717488789237668
|
593
593
|
:color: 4294967295
|
594
594
|
- Block:
|
595
595
|
:x: 32.0
|
@@ -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.44144144144144
|
936
|
+
:factor_y: 1.44144144144144
|
937
937
|
:color: 4294967295
|
938
938
|
- CogWheel:
|
939
939
|
:x: 1792.0
|
940
940
|
:y: 320.0
|
941
|
-
:angle:
|
941
|
+
:angle: 199.112003270741
|
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: 357.54187620404
|
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: 201.112003270741
|
966
966
|
:zorder: 95
|
967
967
|
:factor_x: 1.68525252525252
|
968
968
|
:factor_y: 1.68525252525252
|
@@ -1028,8 +1028,8 @@
|
|
1028
1028
|
:y: 480.0
|
1029
1029
|
:angle: 0
|
1030
1030
|
:zorder: 100
|
1031
|
-
:factor_x: 0.
|
1032
|
-
:factor_y: 0.
|
1031
|
+
:factor_x: 0.286995515695067
|
1032
|
+
:factor_y: 0.286995515695067
|
1033
1033
|
:color: 4294967295
|
1034
1034
|
- Block:
|
1035
1035
|
:x: 448.0
|
@@ -1073,40 +1073,40 @@
|
|
1073
1073
|
:color: 4294967295
|
1074
1074
|
- Saw:
|
1075
1075
|
:x: 2304.0
|
1076
|
-
:y:
|
1077
|
-
:angle:
|
1076
|
+
:y: 42973.9722397467
|
1077
|
+
:angle: 244.651419558422
|
1078
1078
|
:zorder: 100
|
1079
1079
|
:factor_x: 0.317794486215539
|
1080
1080
|
:factor_y: 0.320401002506266
|
1081
1081
|
:color: 4294967295
|
1082
1082
|
- Saw:
|
1083
1083
|
:x: 2016.0
|
1084
|
-
:y:
|
1085
|
-
:angle:
|
1084
|
+
:y: 32173.9806240522
|
1085
|
+
:angle: 130.22068444929
|
1086
1086
|
:zorder: 100
|
1087
1087
|
:factor_x: 0.398395989974937
|
1088
1088
|
:factor_y: 0.401002506265664
|
1089
1089
|
:color: 4294967295
|
1090
1090
|
- Saw:
|
1091
1091
|
:x: 1696.0
|
1092
|
-
:y: 14500.
|
1093
|
-
:angle:
|
1092
|
+
:y: 14500.9946086338
|
1093
|
+
:angle: 324.233721499835
|
1094
1094
|
:zorder: 100
|
1095
1095
|
:factor_x: 0.958395989974934
|
1096
1096
|
:factor_y: 0.961002506265664
|
1097
1097
|
:color: 4294967295
|
1098
1098
|
- Saw:
|
1099
1099
|
:x: 1056.0
|
1100
|
-
:y:
|
1101
|
-
:angle:
|
1100
|
+
:y: 24036.9954416873
|
1101
|
+
:angle: 193.151996227564
|
1102
1102
|
:zorder: 100
|
1103
1103
|
:factor_x: 0.637794486215539
|
1104
1104
|
:factor_y: 0.640401002506266
|
1105
1105
|
:color: 4294967295
|
1106
1106
|
- Saw:
|
1107
1107
|
:x: 1344.0
|
1108
|
-
:y:
|
1109
|
-
:angle:
|
1108
|
+
:y: 24036.9954416873
|
1109
|
+
:angle: 196.151996227565
|
1110
1110
|
:zorder: 100
|
1111
1111
|
:factor_x: 0.637794486215539
|
1112
1112
|
:factor_y: 0.640401002506266
|
@@ -1361,72 +1361,72 @@
|
|
1361
1361
|
:color: 4294967295
|
1362
1362
|
- Saw:
|
1363
1363
|
:x: 2176.0
|
1364
|
-
:y:
|
1365
|
-
:angle:
|
1364
|
+
:y: 42813.9722397467
|
1365
|
+
:angle: 247.651419558422
|
1366
1366
|
:zorder: 100
|
1367
1367
|
:factor_x: 0.317794486215539
|
1368
1368
|
:factor_y: 0.320401002506266
|
1369
1369
|
:color: 4294967295
|
1370
1370
|
- Saw:
|
1371
1371
|
:x: 1280.0
|
1372
|
-
:y:
|
1373
|
-
:angle:
|
1372
|
+
:y: 30824.098278027
|
1373
|
+
:angle: 92.0967151668047
|
1374
1374
|
:zorder: 100
|
1375
1375
|
:factor_x: 0.47739348370927
|
1376
1376
|
:factor_y: 0.48
|
1377
1377
|
:color: 4294967295
|
1378
1378
|
- Saw:
|
1379
1379
|
:x: 1055.0
|
1380
|
-
:y:
|
1381
|
-
:angle:
|
1380
|
+
:y: 91481.6743590043
|
1381
|
+
:angle: 202.536947145858
|
1382
1382
|
:zorder: 100
|
1383
1383
|
:factor_x: 0.156390977443606
|
1384
1384
|
:factor_y: 0.158997493734336
|
1385
1385
|
:color: 4294967295
|
1386
1386
|
- Saw:
|
1387
1387
|
:x: 960.0
|
1388
|
-
:y:
|
1389
|
-
:angle:
|
1388
|
+
:y: 91545.6743590044
|
1389
|
+
:angle: 205.536947145856
|
1390
1390
|
:zorder: 100
|
1391
1391
|
:factor_x: 0.156390977443606
|
1392
1392
|
:factor_y: 0.158997493734336
|
1393
1393
|
:color: 4294967295
|
1394
1394
|
- Saw:
|
1395
1395
|
:x: 1120.0
|
1396
|
-
:y:
|
1397
|
-
:angle:
|
1396
|
+
:y: 91545.6743590044
|
1397
|
+
:angle: 205.536947145856
|
1398
1398
|
:zorder: 100
|
1399
1399
|
:factor_x: 0.156390977443606
|
1400
1400
|
:factor_y: 0.158997493734336
|
1401
1401
|
:color: 4294967295
|
1402
1402
|
- Saw:
|
1403
1403
|
:x: 864.0
|
1404
|
-
:y:
|
1405
|
-
:angle:
|
1404
|
+
:y: 91481.6743590043
|
1405
|
+
:angle: 208.536947145856
|
1406
1406
|
:zorder: 100
|
1407
1407
|
:factor_x: 0.156390977443606
|
1408
1408
|
:factor_y: 0.158997493734336
|
1409
1409
|
:color: 4294967295
|
1410
1410
|
- Saw:
|
1411
1411
|
:x: 1247.0
|
1412
|
-
:y:
|
1413
|
-
:angle:
|
1412
|
+
:y: 27755.9489495749
|
1413
|
+
:angle: 107.917046020636
|
1414
1414
|
:zorder: 100
|
1415
1415
|
:factor_x: 0.477192982456137
|
1416
1416
|
:factor_y: 0.479799498746867
|
1417
1417
|
:color: 4294967295
|
1418
1418
|
- Saw:
|
1419
1419
|
:x: 1088.0
|
1420
|
-
:y:
|
1421
|
-
:angle:
|
1420
|
+
:y: 54674.3885593251
|
1421
|
+
:angle: 248.721133764806
|
1422
1422
|
:zorder: 100
|
1423
1423
|
:factor_x: 0.236591478696738
|
1424
1424
|
:factor_y: 0.239197994987469
|
1425
1425
|
:color: 4294967295
|
1426
1426
|
- Saw:
|
1427
1427
|
:x: 960.0
|
1428
|
-
:y:
|
1429
|
-
:angle:
|
1428
|
+
:y: 54674.3885593251
|
1429
|
+
:angle: 251.721133764807
|
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: 1486.65953699044
|
1549
|
+
:angle: 295.794413689238
|
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: 1457.122269646
|
1557
|
+
:angle: 247.355008787115
|
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: 1515.61720067452
|
1565
|
+
:angle: 57.317747058639
|
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: 1509.95012679627
|
1573
|
+
:angle: 10.0118343201395
|
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: 1513.27726120035
|
1581
|
+
:angle: 13.0118343201416
|
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: 1544.73245984785
|
1589
|
+
:angle: 16.0118343201395
|
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: 1447.47254150702
|
1597
|
+
:angle: 215.427837857925
|
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: 1447.47254150702
|
1605
|
+
:angle: 218.427837857925
|
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: 1476.34100946372
|
1613
|
+
:angle: 280.677823822402
|
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: 1415.77522349937
|
1621
|
+
:angle: 221.427837857925
|
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: 1467.90102171139
|
1629
|
+
:angle: 218.427837857925
|
1630
1630
|
:zorder: 100
|
1631
1631
|
:factor_x: 0.156992481203007
|
1632
1632
|
:factor_y: 0.159598997493734
|
@@ -2084,16 +2084,16 @@
|
|
2084
2084
|
:y: 224.0
|
2085
2085
|
:angle: 0
|
2086
2086
|
:zorder: 100
|
2087
|
-
:factor_x: 0.
|
2088
|
-
:factor_y: 0.
|
2087
|
+
:factor_x: 0.0717488789237668
|
2088
|
+
:factor_y: 0.0717488789237668
|
2089
2089
|
:color: 4294967295
|
2090
2090
|
- Block:
|
2091
2091
|
:x: 128.0
|
2092
2092
|
:y: 224.0
|
2093
2093
|
:angle: 0
|
2094
2094
|
:zorder: 100
|
2095
|
-
:factor_x: 0.
|
2096
|
-
:factor_y: 0.
|
2095
|
+
:factor_x: 0.0717488789237668
|
2096
|
+
:factor_y: 0.0717488789237668
|
2097
2097
|
:color: 4294967295
|
2098
2098
|
- Block:
|
2099
2099
|
:x: 608.0
|
@@ -52,7 +52,7 @@ class Example21 < GameState
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def save_player_position
|
55
|
-
@saved_x, @saved_y = @droid.x, @droid.y if @droid.
|
55
|
+
@saved_x, @saved_y = @droid.x, @droid.y if @droid.collidable && !@jumping
|
56
56
|
end
|
57
57
|
|
58
58
|
def update
|
@@ -84,18 +84,10 @@ class Example21 < GameState
|
|
84
84
|
|
85
85
|
self.viewport.center_around(@droid)
|
86
86
|
|
87
|
-
$window.caption = "Haunted Factory.
|
87
|
+
$window.caption = "Haunted Factory. 'E' toggles Edit. x/y: #{@droid.x.to_i}/#{@droid.y.to_i} - viewport x/y: #{self.viewport.x.to_i}/#{self.viewport.y.to_i} - FPS: #{$window.fps}"
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
-
#
|
92
|
-
#
|
93
|
-
class GameFinished < GameState
|
94
|
-
def setup
|
95
|
-
self.input
|
96
|
-
Text.create("MMMM... Battery ACID, YUM!")
|
97
|
-
end
|
98
|
-
end
|
99
91
|
|
100
92
|
#
|
101
93
|
# DROID
|
@@ -104,11 +96,12 @@ class Droid < Chingu::GameObject
|
|
104
96
|
trait :bounding_box, :scale => 0.80
|
105
97
|
traits :timer, :collision_detection , :timer, :velocity
|
106
98
|
|
99
|
+
attr_reader :jumpign
|
100
|
+
|
107
101
|
def setup
|
108
102
|
self.input = { [:holding_left, :holding_a] => :holding_left,
|
109
103
|
[:holding_right, :holding_d] => :holding_right,
|
110
104
|
[:up, :w] => :jump,
|
111
|
-
:space => :fire
|
112
105
|
}
|
113
106
|
|
114
107
|
# Load the full animation from tile-file media/droid.bmp
|
@@ -117,6 +110,7 @@ class Droid < Chingu::GameObject
|
|
117
110
|
|
118
111
|
@animation = @animations[:scan]
|
119
112
|
@speed = 3
|
113
|
+
@jumping = false
|
120
114
|
|
121
115
|
self.zorder = 300
|
122
116
|
self.factor = 3
|
@@ -152,7 +146,8 @@ class Droid < Chingu::GameObject
|
|
152
146
|
end
|
153
147
|
|
154
148
|
def jump
|
155
|
-
return if
|
149
|
+
return if @jumping
|
150
|
+
@jumping = true
|
156
151
|
self.velocity_y = -10
|
157
152
|
@animation = @animations[:up]
|
158
153
|
end
|
@@ -173,6 +168,7 @@ class Droid < Chingu::GameObject
|
|
173
168
|
else
|
174
169
|
me.y = stone_wall.bb.top-1
|
175
170
|
end
|
171
|
+
@jumping = false
|
176
172
|
end
|
177
173
|
|
178
174
|
@animation = @animations[:scan] unless moved?
|
data/lib/chingu.rb
CHANGED
@@ -162,7 +162,7 @@ module Chingu
|
|
162
162
|
|
163
163
|
super
|
164
164
|
|
165
|
-
@status_text.text = "#{self.mouse_x} / #{self.mouse_y}"
|
165
|
+
@status_text.text = "#{self.mouse_x.to_i} / #{self.mouse_y.to_i}"
|
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}"
|
@@ -265,7 +265,11 @@ module Chingu
|
|
265
265
|
selected_game_objects.each { |object| object.options[:selected] = nil } unless holding?(:left_ctrl)
|
266
266
|
end
|
267
267
|
|
268
|
-
|
268
|
+
if holding?(:left_ctrl)
|
269
|
+
@selected_game_object.options[:selected] = !@selected_game_object.options[:selected]
|
270
|
+
else
|
271
|
+
@selected_game_object.options[:selected] = true
|
272
|
+
end
|
269
273
|
|
270
274
|
#
|
271
275
|
# Re-align all objects x/y offset in relevance to the cursor
|
@@ -319,7 +323,7 @@ module Chingu
|
|
319
323
|
# Call destroy on all selected game objects
|
320
324
|
#
|
321
325
|
def destroy_selected_game_objects
|
322
|
-
selected_game_objects.each
|
326
|
+
selected_game_objects.each { |game_object| game_object.destroy }
|
323
327
|
end
|
324
328
|
|
325
329
|
def deselect_selected_game_objects
|
@@ -484,13 +488,21 @@ module Chingu
|
|
484
488
|
selected_game_objects.each { |game_object| game_object.factor_x += grid_factor_x_for(game_object) }
|
485
489
|
end
|
486
490
|
def scale_up_y
|
487
|
-
selected_game_objects.each { |game_object| game_object.factor_y +=
|
491
|
+
selected_game_objects.each { |game_object| game_object.factor_y += grid_factor_x_for(game_object) }
|
488
492
|
end
|
489
493
|
def scale_down_x
|
490
|
-
selected_game_objects.each { |game_object|
|
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
|
+
}
|
491
499
|
end
|
492
500
|
def scale_down_y
|
493
|
-
selected_game_objects.each { |game_object|
|
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
|
+
}
|
494
506
|
end
|
495
507
|
|
496
508
|
def grid_factor_x_for(object)
|
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chingu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 109
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
9
|
- 6
|
10
|
-
|
10
|
+
- 1
|
11
|
+
version: 0.7.6.1
|
11
12
|
platform: ruby
|
12
13
|
authors:
|
13
14
|
- ippa
|