Main Menu


Sponsored Links

  


  
  
Web Cartoon Maker: a Fun Way to Learn C++ Contents Previous Next

Cartoonish Example

All the above examples may look artificial and not very usable for cartoons. But actually loops are pretty usable in cartoons. Let's compile an example of rotating coin to demonstrate it:

void Scene1 ()

{

// set some variable

double dScale = 0.5; // scale factor of a coin

double dQuarterTurn = 0.2 ; // time for 1/4th of coin rotation

double dXPos = 0; // coin position

double dYPos = 0; // coin position



// setup a background

Image Back ( "backgrounds/flagstone_floor.svg" );

Back.SetVisible ();

Image CoinHead ( "wcm/nickel-coin-head.svg" ); // coin head image

Image CoinTail ( "wcm/nickel-coin-tail.svg" ); // coin tail image

// set coin images' position and scale factor

CoinHead.SetPos ( dXPos, dYPos );

CoinTail.SetPos ( dXPos, dYPos );

CoinHead.SetScale ( dScale );

CoinTail.SetScale ( dScale );

for ( int i=0; i< 5; i++ )

{

// head image is visible

CoinHead.SetVisible ( true );

CoinTail.SetVisible ( false );

// simulate the first half of rotation cycle

CoinHead.SetAngle ( 0 );

CoinHead.SetXScale ( 0.02 * dScale );

CoinHead.ChangeXScale ( 1 * dScale, dQuarterTurn );

CoinHead.SetAngle ( 5 );

CoinHead.ChangeXScale ( 0.02 * dScale, dQuarterTurn );

CoinHead.SetAngle ( 0 );

// tail image is visible

CoinHead.SetVisible ( false );

CoinTail.SetVisible ( true );

// simulate the second half of rotation cycle

CoinTail.SetAngle ( 0 );

CoinTail.SetXScale ( 0.02 * dScale );

CoinTail.ChangeXScale ( 1 * dScale, dQuarterTurn );

CoinTail.SetAngle ( - 5 );

CoinTail.ChangeXScale ( 0.02 * dScale, dQuarterTurn );

CoinTail.SetAngle ( 0 );

}


}

The result should look like this?

Do you think this is useful in cartoons?


Contents Previous Next
  
News

New Tales Animator Video by Alan Sturgess

Alan Sturgess shared an excellent video he made using Tales Animator! You can still download Tales Animator here. Unfortunately it is only available for Wi

...

Simple Online Character Designer

There is a prototype of simple online character designer available HERE. It is only a prototype, it does not contain many pieces yet but it can already generat

...

Book is updated

Now our book "Web Cartoon Maker: A Fun Way to Learn C++" is fully in synch with WCM 1.5! It is available for download and online reading HERE.

...

Web Cartoon Maker 1.5 is here!

Web Cartoon Maker 1.5 is finally here! You can download it HERE! Here is what was updated in version 1.5: Web Cartoon Maker Desktop Edition is now fully standal

...

read more news...


Poll