void level_three() { vector<DPipe> DirectPipes(13); vector<DoublePipe> DoublePipes(13); vector<CrossPipe> CrossPipes(2); DPipe a0(50,SCREEN_HEIGHT-50,100,40); DoublePipe b0(150,SCREEN_HEIGHT-50,70,40); DPipe a1(150,SCREEN_HEIGHT-150,100,40); DoublePipe b1(150,SCREEN_HEIGHT-250,70,40); DPipe a2(250,SCREEN_HEIGHT-350,100,40); DoublePipe b2(350,SCREEN_HEIGHT-250,70,40); DPipe a3(350,SCREEN_HEIGHT-350,100,40); DPipe a4(350,SCREEN_HEIGHT-150,100,40); DoublePipe b3(250,SCREEN_HEIGHT-450,70,40); DoublePipe b4(350,SCREEN_HEIGHT-450,70,40); CrossPipe c0(250,SCREEN_HEIGHT-250,100,40); DPipe a5(550,SCREEN_HEIGHT-50,100,40); DoublePipe b5(250,SCREEN_HEIGHT-150,70,40); DoublePipe b6(450,SCREEN_HEIGHT-50,70,40); DoublePipe b7(650,SCREEN_HEIGHT-150,70,40); DPipe a6(550,SCREEN_HEIGHT-50,100,40); DPipe a7(550,SCREEN_HEIGHT-150,100,40); DoublePipe b8(750,SCREEN_HEIGHT-50,70,40); DPipe a8(550,SCREEN_HEIGHT-250,100,40); DoublePipe b9(750,SCREEN_HEIGHT-350,70,40); CrossPipe c1(450,SCREEN_HEIGHT-150,100,40); DoublePipe b10(350,SCREEN_HEIGHT-450,70,40); DPipe a9(750,SCREEN_HEIGHT-150,100,40); DPipe a10(750,SCREEN_HEIGHT-250,100,40); DoublePipe b11(450,SCREEN_HEIGHT-250,70,40); DoublePipe b12(650,SCREEN_HEIGHT-250,70,40); DPipe a11(650,SCREEN_HEIGHT-50,100,40); DPipe a12(850,SCREEN_HEIGHT-350,100,40); DirectPipes[0] = a0; DoublePipes[0] = b0; DirectPipes[1] = a1; DoublePipes[1] = b1; DirectPipes[2] = a2; DoublePipes[2] = b2; DirectPipes[3] = a3; DoublePipes[3] = b3; DirectPipes[4] = a4; DoublePipes[4] = b4; DirectPipes[5] = a5; DoublePipes[5] = b5; DirectPipes[6] = a6; DoublePipes[6] = b6; DirectPipes[7] = a7; DoublePipes[7] = b7; DirectPipes[8] = a8; DoublePipes[8] = b8; DirectPipes[9] = a9; DoublePipes[9] = b9; DirectPipes[10] = a10; DoublePipes[10] = b10; DirectPipes[11] = a11; DoublePipes[11] = b11; DirectPipes[12] = a12; DoublePipes[12] = b12; CrossPipes[0] = c0; CrossPipes[1] = c1; Water a(20,SCREEN_HEIGHT-50,40,40); }
TEST(CollisionTest, CollisionTestAll) { int a_x = 10; int a_y = 10; int a_width = 10; int a_height = 10; int b1_x = 10; int b1_y = 30; int b1_width = 10; int b1_height = 10; int b2_x = 10; int b2_y = 20; int b2_width = 10; int b2_height = 1; int b3_x = 20; int b3_y = 10; int b3_width = 1; int b3_height = 10; int b4_x = 30; int b4_y = 10; int b4_width = 10; int b4_height = 10; int b5_x = 30; int b5_y = 30; int b5_width = 10; int b5_height = 10; int b6_x = 9; int b6_y = 10; int b6_width = 1; int b6_height = 10; int b7_x = 10; int b7_y = 9; int b7_width = 10; int b7_height = 1; int b8_x = 10; int b8_y = 10; int b8_width = 10; int b8_height = 10; int b9_x = 10; int b9_y = 15; int b9_width = 10; int b9_height = 5; int b10_x = 13; int b10_y = 13; int b10_width = 2; int b10_height = 2; int b11_x = 18; int b11_y = 2; int b11_width = 10; int b11_height = 10; int b12_x = 5; int b12_y = 15; int b12_width = 10; int b12_height = 10; BoxShape a(a_x, a_y, a_width, a_height); BoxShape b1(b1_x, b1_y, b1_width, b1_height); BoxShape b2(b2_x, b2_y, b2_width, b2_height); BoxShape b3(b3_x, b3_y, b3_width, b3_height); BoxShape b4(b4_x, b4_y, b4_width, b4_height); BoxShape b5(b5_x, b5_y, b5_width, b5_height); BoxShape b6(b6_x, b6_y, b6_width, b6_height); BoxShape b7(b7_x, b7_y, b7_width, b7_height); BoxShape b8(b8_x, b8_y, b8_width, b8_height); BoxShape b9(b9_x, b9_y, b9_width, b9_height); BoxShape b10(b10_x, b10_y, b10_width, b10_height); BoxShape b11(b11_x, b11_y, b11_width, b11_height); BoxShape b12(b12_x, b12_y, b12_width, b12_height); ASSERT_FALSE(collision_detection(a, b1)) << "Should not return collision. They are apart"; ASSERT_FALSE(collision_detection(a, b2)) << "Should not return collision. They are adjacent"; ASSERT_FALSE(collision_detection(a, b3)) << "Should not return collision. They are adjacent"; ASSERT_FALSE(collision_detection(a, b4)) << "Should not return collision. They are apart"; ASSERT_FALSE(collision_detection(a, b5)) << "Should not return collision. They are apart"; ASSERT_FALSE(collision_detection(a, b6)) << "Should not return collision. They are adjacent"; ASSERT_FALSE(collision_detection(a, b7)) << "Should not return collision. They are adjacent"; ASSERT_TRUE(collision_detection(a, b8)) << "Should return collision. They are on top of each other"; ASSERT_TRUE(collision_detection(a, b9)) << "Should return collision. They intersect"; ASSERT_TRUE(collision_detection(a, b10)) << "Should return collision. One is inside the other"; ASSERT_TRUE(collision_detection(a, b11)) << "Should return collision. They intersect"; ASSERT_TRUE(collision_detection(a, b12)) << "Should return collision. They intersect"; }
void level_two() { vector<DPipe> DPIPES(44); vector<DoublePipe> DOUBPIPES(18); vector<CrossPipe> CROSSPIPES(3); DPipe background(600,400,1200,800); DPipe a0(50,750,100,40); DPipe a1(150,650,100,40); DPipe a2(150,550,100,40); DPipe a3(650,450,100,40); DPipe a4(550,550,100,40); DPipe a5(450,350,100,40); DPipe a6(550,250,100,40); DPipe a7(650,250,100,40); DPipe a8(750,350,100,40); DPipe a9(750,450,100,40); DPipe a10(750,550,100,40); DPipe a11(650,650,100,40); DPipe a12(550,650,100,40); DPipe a13(450,650,100,40); DPipe a14(350,550,100,40); DPipe a15(350,350,100,40); DPipe a16(350,250,100,40); DPipe a17(450,150,100,40); DPipe a18(550,150,100,40); DPipe a19(650,150,100,40); DPipe a20(750,150,100,40); DPipe a21(850,250,100,40); DPipe a22(850,350,100,40); DPipe a23(850,450,100,40); DPipe a24(850,550,100,40); DPipe a25(850,650,100,40); DPipe a26(750,750,100,40); DPipe a27(650,750,100,40); DPipe a28(550,750,100,40); DPipe a29(450,750,100,40); DPipe a30(350,750,100,40); DPipe a31(250,650,100,40); DPipe a32(250,550,100,40); DPipe a33(250,350,100,40); DPipe a34(250,250,100,40); DPipe a35(250,150,100,40); DPipe a36(350,50,100,40); DPipe a37(450,50,100,40); DPipe a38(550,50,100,40); DPipe a39(650,50,100,40); DPipe a40(750,50,100,40); DPipe a41(850,50,100,40); DPipe a42(950,150,100,40); DPipe a43(950,250,100,40); DoublePipe b0(150,750,70,40); DoublePipe b1(150,450,70,40); DoublePipe b2(550,450,70,40); DoublePipe b3(550,350,70,40); DoublePipe b4(650,350,70,40); DoublePipe b5(650,550,70,40); DoublePipe b6(450,550,70,40); DoublePipe b7(450,250,70,40); DoublePipe b8(750,250,70,40); DoublePipe b9(750,650,70,40); DoublePipe b10(350,650,70,40); DoublePipe b11(350,150,70,40); DoublePipe b12(850,150,70,40); DoublePipe b13(850,750,70,40); DoublePipe b14(250,750,70,40); DoublePipe b15(250,50,70,40); DoublePipe b16(950,50,70,40); DoublePipe b17(950,350,70,40); CrossPipe c0(250,450,100,40); CrossPipe c1(350,450,100,40); CrossPipe c2(450,450,100,40); DPIPES[0]=a0; DPIPES[1]=a1; DPIPES[2]=a2; DPIPES[3]=a3; DPIPES[4]=a4; DPIPES[5]=a5; DPIPES[6]=a6; DPIPES[7]=a7; DPIPES[8]=a8; DPIPES[9]=a9; DPIPES[10]=a10; DPIPES[11]=a11; DPIPES[12]=a12; DPIPES[13]=a13; DPIPES[14]=a14; DPIPES[15]=a15; DPIPES[16]=a16; DPIPES[17]=a17; DPIPES[18]=a18; DPIPES[19]=a19; DPIPES[20]=a20; DPIPES[21]=a21; DPIPES[22]=a22; DPIPES[23]=a23; DPIPES[24]=a24; DPIPES[25]=a25; DPIPES[26]=a26; DPIPES[27]=a27; DPIPES[28]=a28; DPIPES[29]=a29; DPIPES[30]=a30; DPIPES[31]=a31; DPIPES[32]=a32; DPIPES[33]=a33; DPIPES[34]=a34; DPIPES[35]=a35; DPIPES[36]=a36; DPIPES[37]=a37; DPIPES[38]=a38; DPIPES[39]=a39; DPIPES[40]=a40; DPIPES[41]=a41; DPIPES[42]=a42; DPIPES[43]=a43; DOUBPIPES[0]=b0; DOUBPIPES[1]=b1; DOUBPIPES[2]=b2; DOUBPIPES[3]=b3; DOUBPIPES[4]=b4; DOUBPIPES[5]=b5; DOUBPIPES[6]=b6; DOUBPIPES[7]=b7; DOUBPIPES[8]=b8; DOUBPIPES[9]=b9; DOUBPIPES[10]=b10; DOUBPIPES[11]=b11; DOUBPIPES[12]=b12; DOUBPIPES[13]=b13; DOUBPIPES[14]=b14; DOUBPIPES[15]=b15; DOUBPIPES[16]=b16; DOUBPIPES[17]=b17; CROSSPIPES[0]=c0; CROSSPIPES[1]=c1; CROSSPIPES[2]=c2; }
int main() { tQ4 a4( 1.1 ); tQ4 b4( 1 ); tQ12 a12( 3.3 ); tQ12 b12( 3 ); tQ18 a18; double ad; double bd; tQ8 a8( -2.3 ); tQ8 b8( 2 ); tQ8 c8( Q8CONST( -2,3 ) ); tQ8 d8( a8 ); tQ8 e8( a4 ); // tQ8 f8( a12 ); // Warning: left shift count is negative tQ8 g8( a12.roundedTo< tQ8 >() ); tQ8 h8( a12.roundedTo< 8 >() ); // a8 = a4.roundedTo( h8 ); //Warning: left/right shift is negative a8 = 1; a8 = -2; a8 = 3; a8 = Q8CONST( 3,001 ); a8 = tQ8( 3.001 ); a8 = tQ8::truncated( 3.001 ); a8 = tQ8::rounded( 3.001 ); a8.setTruncated( 3.2 ); a8.setRounded( 3.3 ); a8 = tQ8( 123, 8 ); a8 = tQ8::create( 123 << 8 ); a8 = a4; a8 = a8; // a8 = a12; // Warning: left shift count is negative a8 = a12.roundedTo< tQ8 >(); a8 = a12.roundedTo( a8 ); a8.setRounded( a12 ); a8 = -a4; a8 = -a8; a8 += 3; a8 += 4u; a8 += 5l; a8 += 6lu; a8 += tQ8( 3.2 ); a8 += truncatedTo( a8, 3.3 ); a8 += roundedTo( a8, 3.4 ); a8 += a4; // a8 += a12; // Warning: left shift count is negative a8 += a12.roundedTo< tQ8 >(); a8 += a12.roundedTo( a8 ); a8 = a8 + 2; a8 = 3 + a8; a8 = a8 + a4; // a8 = a4 + a8; // Warning: left shift count is negative a8 -= 3; a8 -= 4u; a8 -= 5l; a8 -= 6lu; a8 -= roundedTo< tQ8::cQBits >( 3.2 ); a8 -= roundedTo( a8, 3.3 ); a8 -= a4; // a8 -= a12; // Warning: left shift count is negative a8 -= a12.roundedTo< tQ8 >(); a8 -= a12.roundedTo( a8 ); a8 = a8 - 2; a8 = 3 - a8; a8 = a8 - a4; // a8 = a4 - a8; // Warning: left shift count is negative a8 *= 3; a8 *= 4u; a8 *= 5l; a8 *= 6lu; // a8 *= 3.2; // Warning: converting to int from double a8 *= a4; a8 *= a12; a8 = a8 * 2; a8 = 3 * a8; a12 = a8 * a4; a12 = a4 * a8; a8 /= 3; a8 /= 4u; a8 /= 5l; a8 /= 6lu; // a8 /= 3.2; // Warning: converting to int from double a8 /= a4; // Note: possible overflow due to pre-shifting "(a8 << 4) / a4" // a8 /= a12; // Warning: left shift count is negative a8 = a8.increasedBy( a12 ) / a12; a8 = a8 / 2; // a8 = 3 / a8; // Error: no match for 'operator/' a8 = tQ16( 3 ) / a8; a12 = a8 / a4; a12 = a4 / a8; a8 == 3; a8 == 4u; a8 == 5l; a8 == 6lu; a8 == tQ8( 3.2 ); a8 == truncatedTo( a8, 3.3 ); a8 == roundedTo( a8, 3.4 ); a8 == a4; // a8 == a12; // Warning: left shift count is negative a8 == a12.roundedTo< tQ8 >(); a8 == a12.roundedTo( a8 ); 3 == a8; int(4u) == a8; int(5l) == a8; int(6lu) == a8; a8 < 3; a8 < 4u; a8 < 5l; a8 < 6lu; a8 < tQ8( 3.2 ); a8 < a4; // a8 < a12; // Warning: left shift count is negative 3 < a8; int(4u) < a8; int(5l) < a8; int(6lu) < a8; a8 > 3; a8 > 4u; a8 > 5l; a8 > 6lu; a8 > tQ8( 3.2 ); a8 > a4; // a8 > a12; // Warning: left shift count is negative 3 > a8; int(4u) > a8; int(5l) > a8; int(6lu) > a8; !a8; int intPart = a8.intPart(); int fracPart = a8.fracPart(); int fracPlaces = a8.fracPlaces( 3 ); unsigned abs = a8.absolute(); ad = a8.toDouble(); a8 = ad; // a8.set( ad ); // Warning: conversion from int to double, possible loss of data a8.setRounded( ad ); a8 = truncatedTo( a8, ad ); a8 = truncatedTo<8>( ad ); a8 = truncatedTo<tQ8>( ad ); // tBigQ36 aB36( 123567890 ); // Error: ambiguous tBigQ36 aB36( 123567890ll ); tBigQ36 bB36( a8 ); aB36 = tBigQ18( a18 ) * a18; }