#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "GrWin.h"

int back(){
 int iro2, iro4;

 iro2=GWkrgb(153, 255, 0);
 iro4=GWkrgb(153, 255, 100);

 /* 木（幹）*/
 GWsrect(0, 0, 75, 600, 1);
 /* 木（葉）*/
 GWscircle(-100, 400, 150, 800, iro2);
 /* 木（葉2）*/
 GWscircle(0, 400, 220, 800, iro2);
 /* 木（葉3）*/
 GWscircle(100, 500, 270, 700, iro2);
 /* 木の実1 */
 GWscircle(20, 500, 45, 530, 13);
 /* 木の実2 */
 GWscircle(40, 450, 65, 480, 13);
 /* 木の実3 */
 GWscircle(200, 550, 225, 580, 13);
 /* 木の実4 */
 GWscircle(150, 490, 175, 520, 13);
 /* 地面 */
 GWsrect(0, 0, 700, 70, iro4);
 /* 雲 */
 GWscircle(490, 520, 520, 560, 19);
 GWscircle(500, 500, 540, 580, 19);
 GWscircle(520, 500, 560, 580, 19);
 GWscircle(540, 500, 580, 580, 19);
 GWscircle(560, 500, 600, 580, 19);
 GWscircle(580, 520, 610, 560, 19);
 /* 雲2 */
 GWscircle(290, 520, 320, 560, 19);
 GWscircle(300, 500, 340, 580, 19);
 GWscircle(320, 500, 360, 580, 19);
 GWscircle(340, 500, 380, 580, 19);
 GWscircle(360, 500, 400, 580, 19);
 GWscircle(380, 520, 410, 560, 19);

return 0;

};

int panda(int x, int y){
  
  /* 右耳 */
  GWscircle(x, y+275, x+25, y+300, 0);
  /* 左耳 */
  GWscircle(x+75, y+275, x+100, y+300, 0);
  /* 輪郭 */
  GWscircle(x, y+200, x+100, y+300, 9); 
  /* 右目 外 */
  GWscircle(x+15, y+265, x+35, y+285, 0); 
  /* 左目 外 */
  GWscircle(x+65, y+265, x+85, y+285, 0);
  /* 右目 中 */
  GWscircle(x+20, y+270, x+30, y+280, 9);
  /* 左目 中 */
  GWscircle(x+70, y+270, x+80, y+280, 9);
  /* 右手 */
  GWscircle(x+20, y+180, x-5, y+165, 0);
  /* 左手 */
  GWscircle(x+70, y+180, x+105, y+165, 0);
  /* 右足 */
  GWscircle(x+25, y+20, x+35, y+115, 0);
  /* 左足 */
  GWscircle(x+65, y+20, x+75, y+115, 0);
  /* 胴体 */
  GWscircle(x+10, y+50, x+90, y+215, 9);
  /* 噴出し1 */
  GWscircle(x+100, y+300, x+135, y+335, 19);
  /* 噴出し2 */
  GWscircle(x+125, y+330, x+190, y+400, 19);

return 0;

};

int main(){
 int x, y, y1, iro, iro3;

 GWopen(0); 
 GWindow(0.0, 0.0, 600.0, 600.0);

 iro=GWkrgb(204, 102, 80);
 iro3=GWkrgb(150, 200, 230);

 /* 背景 */
 back();
 /* 落ちる木の実 */
 GWscircle(100, 540, 125, 570, 13);

 /* パンダ登場位置 */
 x=500;
 y=50;

while( x > 75 ) {
 
 panda(x, y);
 x-=3.0;
 GWsleep(80);
 GWclear(iro3);
 
 /* 背景 */
 back();
 /* 妄想木の実 */
 GWscircle(x+145, y+350, x+170, y+380, 13);
 /* 落ちる木の実 */
 GWscircle(100, 540, 125, 570, 13);

 };

 x=75;
 y=50;
 panda(x, y);
 /* 妄想木の実 */
 GWscircle(x+145, y+350, x+170, y+380, 13);

 y1=540;
 while( y1 > 350 ) {
 
 GWscircle(100, y1, 125, y1+30, 13);
 y1-=6.0;
 GWsleep(80);
 GWclear(iro3);

 /* 背景 */
 back();
 
 x=75; y=50;
 panda(x, y);

 };

 /* 落ちた木の実 */
 GWscircle(100, 350, 125, 380, 13);
 /* 口 */
 GWxpie(110, 280, 140, 320, 0.5, 0.5,iro);
 /* 字 */
 GWputtxt( 300.0, 300.0, "やったね！");
 /* 笑顔 */
 GWxarc(x+140, y+370, x+150, y+380, 0, 0.5, 0);
 GWxarc(x+160, y+370, x+170, y+380, 0, 0.5, 0);
 GWxarc(x+150, y+350, x+160, y+360, 0.5, 0.5, 0);

return 0;

}

