/*****************************************
  xjump version 3

*****************************************/

#include<stdio.h>
#include<X11/Intrinsic.h>
#include<X11/StringDefs.h>
#include<X11/Xaw/Form.h>
#include<X11/Xaw/Viewport.h>
#include<X11/Xaw/Label.h>
#include<X11/Shell.h>
#include<X11/xpm.h>

#include"xjump.h"

/* 変数 */

static int T_speed,T_count;   /* スクロールスピード関係 */
static hero_t Hero;

void GAME_init( int level )
{
  T_speed = 200;
  T_count = 0;

  FLOOR_init(level);
  HERO_init(&Hero);

  Hero.key[KEY_UP] = 0;
}

int GAME_main( void )
{
  int scroll;
  int floor;

  scroll = 0;

#if 1
  if( T_speed < 5000 )
    T_speed++;
  T_count += T_speed;
  if( T_count > 20000 ){
    T_count -= 20000;
    scroll = 1;
  }
#endif

#if 1
  if( Hero.y < 48 )
    scroll = 1;
#endif
  FLOOR_move_all(scroll);
  floor = HERO_move(&Hero);
  HERO_delete(&Hero);
  HERO_draw(&Hero);
  FLOOR_refresh();
  if( Hero.y > HEIGHT*16 )
    return -1;
  return floor;
}

int GAME_key_press( int key )
{
  Hero.key[key] = 1;
}

int GAME_key_release( int key )
{
  Hero.key[key] = 0;
}
