#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "GrWin.h"

/* アニメーション */

int main()
{
  float x, y, dx, dy;

  GWopen(0);
  GWindow(0.0, 0.0, 200.0, 200.0);

  x=80.0; y=30.0; /* 最初の位置 */
  dx=2.0; dy=0.4; /* ステップごとの進行速度 */

  while(1) {
    GWxrect(10.0, 20.0, 160.0, 160.0, 13); /* 赤枠を表示 */
    if( (x >= 150.0) || (x <= 10.0) ) {
      /* 左右の壁に当たったら方向転換 */
      dx= -1.0 * dx;
    }
    x+=dx; /* x 軸方向にワンステップ進む */
    if(y >= 150.0) {
      break; /* while ループから脱出 */
    }
    y+=dy; /* y 軸方向にワンステップ進む */
    GWsrect(x, y, x+10.0, y+10.0, 16);
    GWsleep(20);
    GWclear(-1);
  }
  return 0;
}

