Commit cefbe1c4 authored by Claes Sjofors's avatar Claes Sjofors

Misc PingPong, adjustable ball radius

parent 4e60b7f4
...@@ -176,17 +176,19 @@ void Misc_PingPongFo_exec( plc_sThread *tp, pwr_sClass_Misc_PingPongFo *o) ...@@ -176,17 +176,19 @@ void Misc_PingPongFo_exec( plc_sThread *tp, pwr_sClass_Misc_PingPongFo *o)
co->Speed = BASE_SPEED * co->LeftLevel * co->LevelFactor; co->Speed = BASE_SPEED * co->LeftLevel * co->LevelFactor;
} }
if ( co->XCoordinate + co->BallRadius > co->Width) { if ( co->XCoordinate + co->BallRadius > co->Width) {
if ( co->YCoordinate >= co->RightPos - co->RacketWidth/2 && if ( co->YCoordinate >= co->RightPos - co->RacketWidth/2 - co->BallRadius &&
co->YCoordinate <= co->RightPos + co->RacketWidth/2) { co->YCoordinate <= co->RightPos + co->RacketWidth/2 + co->BallRadius) {
// Hit on racket // Hit on racket
co->XCoordinate = co->Width - co->BallRadius - if ( co->Direction > 0) {
(co->XCoordinate + co->BallRadius - co->Width);
if ( co->Direction > 0)
co->Direction = -co->Direction + 180 + my_random() * 10; co->Direction = -co->Direction + 180 + my_random() * 10;
else }
else {
co->Direction = -co->Direction - 180 + my_random() * 10; co->Direction = -co->Direction - 180 + my_random() * 10;
}
if ( fabs(co->Direction) < 135) if ( fabs(co->Direction) < 135)
co->Direction = my_random() * 10; co->Direction = my_random() * 10;
co->XCoordinate = co->Width - co->BallRadius -
(co->XCoordinate + co->BallRadius - co->Width);
co->Speed = BASE_SPEED * co->RightLevel * co->LevelFactor; co->Speed = BASE_SPEED * co->RightLevel * co->LevelFactor;
co->BallCount++; co->BallCount++;
} }
...@@ -252,8 +254,8 @@ void Misc_PingPongFo_exec( plc_sThread *tp, pwr_sClass_Misc_PingPongFo *o) ...@@ -252,8 +254,8 @@ void Misc_PingPongFo_exec( plc_sThread *tp, pwr_sClass_Misc_PingPongFo *o)
co->LevelFactor = 1.0 + time_DToFloat( 0, &diff) * co->LevelIncrement / 20; co->LevelFactor = 1.0 + time_DToFloat( 0, &diff) * co->LevelIncrement / 20;
if ( co->XCoordinate - co->BallRadius < 0) { if ( co->XCoordinate - co->BallRadius < 0) {
if ( co->YCoordinate >= co->LeftPos - co->RacketWidth/2 && if ( co->YCoordinate >= co->LeftPos - co->RacketWidth/2 - co->BallRadius &&
co->YCoordinate <= co->LeftPos + co->RacketWidth/2) { co->YCoordinate <= co->LeftPos + co->RacketWidth/2 + co->BallRadius) {
// Hit on racket // Hit on racket
co->XCoordinate = co->BallRadius - (co->XCoordinate - co->BallRadius); co->XCoordinate = co->BallRadius - (co->XCoordinate - co->BallRadius);
if ( co->Direction > 0) if ( co->Direction > 0)
...@@ -272,8 +274,8 @@ void Misc_PingPongFo_exec( plc_sThread *tp, pwr_sClass_Misc_PingPongFo *o) ...@@ -272,8 +274,8 @@ void Misc_PingPongFo_exec( plc_sThread *tp, pwr_sClass_Misc_PingPongFo *o)
} }
} }
if ( co->XCoordinate + co->BallRadius > co->Width) { if ( co->XCoordinate + co->BallRadius > co->Width) {
if ( co->YCoordinate >= co->RightPos - co->RacketWidth/2 && if ( co->YCoordinate >= co->RightPos - co->RacketWidth/2 - co->BallRadius &&
co->YCoordinate <= co->RightPos + co->RacketWidth/2) { co->YCoordinate <= co->RightPos + co->RacketWidth/2 + co->BallRadius) {
// Hit on racket // Hit on racket
co->XCoordinate = co->Width - co->BallRadius - co->XCoordinate = co->Width - co->BallRadius -
(co->XCoordinate + co->BallRadius - co->Width); (co->XCoordinate + co->BallRadius - co->Width);
...@@ -663,4 +665,4 @@ void Misc_DemoPattern_exec( plc_sThread *tp, pwr_sClass_Misc_DemoPattern *o) ...@@ -663,4 +665,4 @@ void Misc_DemoPattern_exec( plc_sThread *tp, pwr_sClass_Misc_DemoPattern *o)
} }
o->Out = (pwr_tInt32)(o->Mask1 | o->Mask2); o->Out = (pwr_tInt32)(o->Mask1 | o->Mask2);
} }
\ No newline at end of file
0! DefaultWidth 531 0! DefaultWidth 531
0! DefaultHeight 203 0! DefaultHeight 245
1 1
100 20 100 20
135 20 135 20
101 20 101 20
102 -125 102 -125
103 -105 103 -105
104 3.711 104 3.89525
136 3.711 136 3.89525
105 100 105 100
106 -23 106 -24
107 -19 107 -20
108 28 108 28
109 0.5 109 0.5
110 9.5 110 11.5
111 -2.5 111 -2.5
116 0 116 0
117 0 117 0
118 135 118 145
119 112 119 118
120 1 120 1
121 Claes context 121 Claes context
122 0 122 0
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
134 134
22 22
2200 0 2200 0
2201 40 2201 42
2202 misc_pingpong_settings 2202 misc_pingpong_settings
2203 310 2203 310
2205 0 2205 0
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
2209 0.9 2209 0.9
2210 -1.6 2210 -1.6
2211 27.5 2211 27.5
2212 8.6 2212 10.65
2213 4 2213 4
2214 2214
pwrp_pop: pwrp_pop:
...@@ -92,6 +92,7 @@ pwr_exe: ...@@ -92,6 +92,7 @@ pwr_exe:
2249 2249
48 48
4802 0 4802 0
4803 0
4800 360 4800 360
4801 4801
1 1 1 1 1 1
...@@ -484,6 +485,9 @@ pwr_exe: ...@@ -484,6 +485,9 @@ pwr_exe:
1921 0 1921 0
1922 2 1922 2
1923 0 1923 0
1924 0
1925 10000
1926 0
1907 0 1907 0
1906 1906
1905 1905
...@@ -582,6 +586,7 @@ pwr_exe: ...@@ -582,6 +586,7 @@ pwr_exe:
99 99
2608 0 2608 0
2609 41 2609 41
2629 10000
2610 41 2610 41
2611 1 2611 1
2616 0 2616 0
...@@ -604,11 +609,14 @@ pwr_exe: ...@@ -604,11 +609,14 @@ pwr_exe:
2613 1 2613 1
2619 0 2619 0
2620 0 2620 0
2626 0
2627 0
2621 0 2621 0
2622 0 2622 0
2623 0 2623 0
2624 4 2624 4
2625 1 2625 1
2628 0
99 99
29 29
2907 2907
...@@ -717,6 +725,9 @@ pwr_exe: ...@@ -717,6 +725,9 @@ pwr_exe:
1921 0 1921 0
1922 2 1922 2
1923 0 1923 0
1924 0
1925 10000
1926 0
1907 0 1907 0
1906 1906
1905 1905
...@@ -842,6 +853,9 @@ pwr_exe: ...@@ -842,6 +853,9 @@ pwr_exe:
1921 0 1921 0
1922 2 1922 2
1923 0 1923 0
1924 0
1925 10000
1926 0
1907 0 1907 0
1906 1906
1905 1905
...@@ -955,6 +969,7 @@ pwr_exe: ...@@ -955,6 +969,7 @@ pwr_exe:
2408 0 2408 0
2409 293 2409 293
2410 293 2410 293
2423 10000
2411 1 2411 1
2415 0 2415 0
2413 15 2413 15
...@@ -966,6 +981,7 @@ pwr_exe: ...@@ -966,6 +981,7 @@ pwr_exe:
2419 4 2419 4
2420 0 2420 0
2422 0 2422 0
2424 0
2407 0 2407 0
2406 2406
2405 2405
...@@ -1149,10 +1165,12 @@ pwr_exe: ...@@ -1149,10 +1165,12 @@ pwr_exe:
27 27
2703 334 2703 334
2704 330 2704 330
2731 10000
2722 338 2722 338
2705 330 2705 330
2723 338 2723 338
2706 334 2706 334
2732 10000
2708 0 2708 0
2709 0 2709 0
2710 0 2710 0
...@@ -1262,7 +1280,7 @@ pwr_exe: ...@@ -1262,7 +1280,7 @@ pwr_exe:
2724 0 2724 0
2727 0 2727 0
2728 303 2728 303
2729 9999 2729 4
2730 0 2730 0
2721 2721
1 1
...@@ -1325,10 +1343,12 @@ pwr_exe: ...@@ -1325,10 +1343,12 @@ pwr_exe:
27 27
2703 394 2703 394
2704 390 2704 390
2731 10000
2722 398 2722 398
2705 390 2705 390
2723 398 2723 398
2706 394 2706 394
2732 10000
2708 0 2708 0
2709 0 2709 0
2710 0 2710 0
...@@ -1438,7 +1458,7 @@ pwr_exe: ...@@ -1438,7 +1458,7 @@ pwr_exe:
2724 0 2724 0
2727 0 2727 0
2728 303 2728 303
2729 9999 2729 4
2730 0 2730 0
2721 2721
1 1
...@@ -1454,6 +1474,8 @@ pwr_exe: ...@@ -1454,6 +1474,8 @@ pwr_exe:
1202 1 1202 1
1203 1 1203 1
1204 0 1204 0
1205
1206 0
99 99
13 13
1302 0 1302 0
...@@ -1464,6 +1486,8 @@ pwr_exe: ...@@ -1464,6 +1486,8 @@ pwr_exe:
1307 1307
1308 1308
1309 0 1309 0
1310 0
1311 0
99 99
99 99
99 99
...@@ -1504,10 +1528,12 @@ pwr_exe: ...@@ -1504,10 +1528,12 @@ pwr_exe:
27 27
2703 394 2703 394
2704 390 2704 390
2731 10000
2722 398 2722 398
2705 390 2705 390
2723 398 2723 398
2706 394 2706 394
2732 10000
2708 0 2708 0
2709 0 2709 0
2710 0 2710 0
...@@ -1617,7 +1643,7 @@ pwr_exe: ...@@ -1617,7 +1643,7 @@ pwr_exe:
2724 0 2724 0
2727 0 2727 0
2728 303 2728 303
2729 9999 2729 4
2730 0 2730 0
2721 2721
1 1
...@@ -1633,6 +1659,8 @@ pwr_exe: ...@@ -1633,6 +1659,8 @@ pwr_exe:
1202 1 1202 1
1203 1 1203 1
1204 0 1204 0
1205
1206 0
99 99
13 13
1302 0 1302 0
...@@ -1643,16 +1671,20 @@ pwr_exe: ...@@ -1643,16 +1671,20 @@ pwr_exe:
1307 1307
1308 1308
1309 0 1309 0
1310 0
1311 0
99 99
99 99
99 99
27 27
2703 394 2703 394
2704 390 2704 390
2731 10000
2722 398 2722 398
2705 390 2705 390
2723 398 2723 398
2706 394 2706 394
2732 10000
2708 0 2708 0
2709 0 2709 0
2710 0 2710 0
...@@ -1762,7 +1794,7 @@ pwr_exe: ...@@ -1762,7 +1794,7 @@ pwr_exe:
2724 0 2724 0
2727 0 2727 0
2728 303 2728 303
2729 9999 2729 4
2730 0 2730 0
2721 2721
1 1
...@@ -1778,6 +1810,8 @@ pwr_exe: ...@@ -1778,6 +1810,8 @@ pwr_exe:
1202 1 1202 1
1203 1 1203 1
1204 0 1204 0
1205
1206 0
99 99
13 13
1302 1 1302 1
...@@ -1788,16 +1822,20 @@ pwr_exe: ...@@ -1788,16 +1822,20 @@ pwr_exe:
1307 1307
1308 1308
1309 0 1309 0
1310 0
1311 0
99 99
99 99
99 99
27 27
2703 394 2703 394
2704 390 2704 390
2731 10000
2722 398 2722 398
2705 390 2705 390
2723 398 2723 398
2706 394 2706 394
2732 10000
2708 0 2708 0
2709 0 2709 0
2710 0 2710 0
...@@ -1907,7 +1945,7 @@ pwr_exe: ...@@ -1907,7 +1945,7 @@ pwr_exe:
2724 0 2724 0
2727 0 2727 0
2728 303 2728 303
2729 9999 2729 4
2730 0 2730 0
2721 2721
1 1
...@@ -1923,6 +1961,8 @@ pwr_exe: ...@@ -1923,6 +1961,8 @@ pwr_exe:
1202 1 1202 1
1203 1 1203 1
1204 0 1204 0
1205
1206 0
99 99
13 13
1302 1 1302 1
...@@ -1933,6 +1973,8 @@ pwr_exe: ...@@ -1933,6 +1973,8 @@ pwr_exe:
1307 1307
1308 1308
1309 0 1309 0
1310 0
1311 0
99 99
99 99
99 99
...@@ -1973,10 +2015,12 @@ pwr_exe: ...@@ -1973,10 +2015,12 @@ pwr_exe:
27 27
2703 454 2703 454
2704 450 2704 450
2731 10000
2722 458 2722 458
2705 450 2705 450
2723 458 2723 458
2706 454 2706 454
2732 10000
2708 0 2708 0
2709 0 2709 0
2710 0 2710 0
...@@ -2141,10 +2185,12 @@ pwr_exe: ...@@ -2141,10 +2185,12 @@ pwr_exe:
27 27
2703 10000 2703 10000
2704 410 2704 410
2731 10000
2722 10000 2722 10000
2705 410 2705 410
2723 10000 2723 10000
2706 10000 2706 10000
2732 10000
2708 0 2708 0
2709 0 2709 0
2710 0 2710 0
...@@ -2273,10 +2319,12 @@ pwr_exe: ...@@ -2273,10 +2319,12 @@ pwr_exe:
27 27
2703 454 2703 454
2704 450 2704 450
2731 10000
2722 458 2722 458
2705 450 2705 450
2723 458 2723 458
2706 454 2706 454
2732 10000
2708 0 2708 0
2709 0 2709 0
2710 0 2710 0
...@@ -2441,10 +2489,12 @@ pwr_exe: ...@@ -2441,10 +2489,12 @@ pwr_exe:
27 27
2703 10000 2703 10000
2704 410 2704 410
2731 10000
2722 10000 2722 10000
2705 410 2705 410
2723 10000 2723 10000
2706 10000 2706 10000
2732 10000
2708 0 2708 0
2709 0 2709 0
2710 0 2710 0
...@@ -2607,10 +2657,12 @@ pwr_exe: ...@@ -2607,10 +2657,12 @@ pwr_exe:
27 27
2703 454 2703 454
2704 450 2704 450
2731 10000
2722 458 2722 458
2705 450 2705 450
2723 458 2723 458
2706 454 2706 454
2732 10000
2708 0 2708 0
2709 0 2709 0
2710 0 2710 0
...@@ -2741,10 +2793,12 @@ pwr_exe: ...@@ -2741,10 +2793,12 @@ pwr_exe:
27 27
2703 10000 2703 10000
2704 410 2704 410
2731 10000
2722 10000 2722 10000
2705 410 2705 410
2723 10000 2723 10000
2706 10000 2706 10000
2732 10000
2708 0 2708 0
2709 0 2709 0
2710 0 2710 0
...@@ -2873,10 +2927,12 @@ pwr_exe: ...@@ -2873,10 +2927,12 @@ pwr_exe:
27 27
2703 454 2703 454
2704 450 2704 450
2731 10000
2722 458 2722 458
2705 450 2705 450
2723 458 2723 458
2706 454 2706 454
2732 10000
2708 0 2708 0
2709 0 2709 0
2710 0 2710 0
...@@ -3007,10 +3063,12 @@ pwr_exe: ...@@ -3007,10 +3063,12 @@ pwr_exe:
27 27
2703 10000 2703 10000
2704 410 2704 410
2731 10000
2722 10000 2722 10000
2705 410 2705 410
2723 10000 2723 10000
2706 10000 2706 10000
2732 10000
2708 0 2708 0
2709 0 2709 0
2710 0 2710 0
...@@ -3191,6 +3249,9 @@ pwr_exe: ...@@ -3191,6 +3249,9 @@ pwr_exe:
1921 0 1921 0
1922 4 1922 4
1923 0 1923 0
1924 0
1925 10000
1926 0
1907 0 1907 0
1906 1906
1905 1905
...@@ -3225,8 +3286,8 @@ pwr_exe: ...@@ -3225,8 +3286,8 @@ pwr_exe:
1904 O36 1904 O36
1900 28 1900 28
1901 0.5 1901 0.5
1902 9.5 1902 11.5
1903 8 1903 10
1908 0 1908 0
1909 318 1909 318
1910 318 1910 318
...@@ -3242,6 +3303,9 @@ pwr_exe: ...@@ -3242,6 +3303,9 @@ pwr_exe:
1921 0 1921 0
1922 4 1922 4
1923 0 1923 0
1924 0
1925 10000
1926 0
1907 0 1907 0
1906 1906
1905 1905
...@@ -3265,10 +3329,10 @@ pwr_exe: ...@@ -3265,10 +3329,10 @@ pwr_exe:
28 28
2800 1 2800 1
2801 0 2801 0
2802 0 2802 1.66533e-16
2803 0 2803 0
2804 1 2804 1
2805 0 2805 2
2806 0 2806 0
99 99
99 99
...@@ -3276,7 +3340,7 @@ pwr_exe: ...@@ -3276,7 +3340,7 @@ pwr_exe:
1904 O37 1904 O37
1900 1.5 1900 1.5
1901 0.5 1901 0.5
1902 8 1902 10
1903 -1.5 1903 -1.5
1908 0 1908 0
1909 318 1909 318
...@@ -3293,6 +3357,9 @@ pwr_exe: ...@@ -3293,6 +3357,9 @@ pwr_exe:
1921 0 1921 0
1922 4 1922 4
1923 0 1923 0
1924 0
1925 10000
1926 0
1907 0 1907 0
1906 1906
1905 1905
...@@ -3318,8 +3385,8 @@ pwr_exe: ...@@ -3318,8 +3385,8 @@ pwr_exe:
2801 0 2801 0
2802 0 2802 0
2803 0 2803 0
2804 1 2804 1.21053
2805 0 2805 0.315789
2806 0 2806 0
99 99
99 99
...@@ -3327,7 +3394,7 @@ pwr_exe: ...@@ -3327,7 +3394,7 @@ pwr_exe:
1904 O38 1904 O38
1900 13 1900 13
1901 12.5 1901 12.5
1902 8 1902 10
1903 -1.5 1903 -1.5
1908 0 1908 0
1909 318 1909 318
...@@ -3344,6 +3411,9 @@ pwr_exe: ...@@ -3344,6 +3411,9 @@ pwr_exe:
1921 0 1921 0
1922 4 1922 4
1923 0 1923 0
1924 0
1925 10000
1926 0
1907 0 1907 0
1906 1906
1905 1905
...@@ -3369,8 +3439,8 @@ pwr_exe: ...@@ -3369,8 +3439,8 @@ pwr_exe:
2801 0 2801 0
2802 0 2802 0
2803 0 2803 0
2804 1 2804 1.21053
2805 0 2805 0.315789
2806 0 2806 0
99 99
99 99
...@@ -3378,7 +3448,7 @@ pwr_exe: ...@@ -3378,7 +3448,7 @@ pwr_exe:
1904 O39 1904 O39
1900 28 1900 28
1901 27 1901 27
1902 8 1902 10
1903 -1.5 1903 -1.5
1908 0 1908 0
1909 318 1909 318
...@@ -3395,6 +3465,9 @@ pwr_exe: ...@@ -3395,6 +3465,9 @@ pwr_exe:
1921 0 1921 0
1922 4 1922 4
1923 0 1923 0
1924 0
1925 10000
1926 0
1907 0 1907 0
1906 1906
1905 1905
...@@ -3420,10 +3493,195 @@ pwr_exe: ...@@ -3420,10 +3493,195 @@ pwr_exe:
2801 0 2801 0
2802 0 2802 0
2803 0 2803 0
2804 1.21053
2805 0.315789
2806 0
99
99
30
3004 O40
3000 5.2
3001 1.95
3002 9.25
3003 8.65
3008 326
3010 4
3011 2
3007 0
3006
3005
9
900 2
901 303
904 326
902 Ball radius
903
7
700 1.95
701 2.15
99
99
3009
28
2800 1
2801 0
2802 0
2803 0
2804 1 2804 1
2805 0 2805 7
2806 0 2806 0
99 99
99 99
27
2703 394
2704 390
2731 10000
2722 398
2705 390
2723 398
2706 394
2732 10000
2708 0
2709 0
2710 0
2711 0
2712 0
2713 0
2714 0
2715 0
2720 0
2725 0
2726 0
2702 0
2701
2700
10
1000 pwr_valuemediumright
1002 O41
1005
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1006 11.55
1007 8.55
1008 9.4
1009 8.4
1013 11.55
1014 8.55
1015 9.4
1016 8.4
1003
0
0
0
0
0
0
0
0
0
0
1004
1001
7
700 11.5
701 5.75
99
1010
1011
1018
1019
1020
1021
1022
1023
1024
1025
1012 0
1017 9999
1027 9999
1026 33619964
1028 0
1029
99
2707
28
2800 1
2801 0
2802 8.55
2803 0
2804 1
2805 8.4
2806 0
99
2716 0
2718
2717
2719 0
2724 0
2727 0
2728 303
2729 4
2730 0
2721
1
100 1
105 0
101 4097
106 0
102 33619964
103 0
12
1200 $object.BallRadius##Float32
1201 %4.1f
1202 1
1203 1
1204 0
1205
1206 0
99
13
1302 0.2
1303 5
1304 0
1305 0
1306 0
1307
1308
1309 0
1310 0
1311 0
99
99
99
99 99
99 99
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment