Esempio n. 1
0
void SceneManager::Update(AppEnv& env)
{
	ChanageScene();

	if (env.isPushKey(GLFW_KEY_S)){
		sceneType = GameMain_;
	}

	scene->Update();
}
Esempio n. 2
0
void gameMainUpdate(AppEnv& env) {
  using namespace GameMainVar;
  state.update();
  stage.Update();
  enemy_manager.Update();
  gimic_manager.Update(player);
  player.Update(env);

  Getter::get().patern = player.gimic_patern;
  if (stage.isClear()) {
    Getter::get().isClear = true;
    setSceneState(SceneState::Result);
  }

  if (env.isPushKey('R')) {
    Getter::get().isClear = true;
    setSceneState(SceneState::Result);
  }
}
Esempio n. 3
0
void resultUpdate(AppEnv& env) {
  using namespace ResultVar;
  if (env.isPushKey('T')) {
    setSceneState(SceneState::Title);
  }
}
Esempio n. 4
0
void gameMainUpdate(AppEnv& env) {
  using namespace GameMainVar;
  if (env.isPushKey('R')) {
    setSceneState(SceneState::Result);
  }
}
Esempio n. 5
0
void Player::hitcheck(AppEnv& app,int& map_id,bool& change){
  /*
  //右側の判定
  if (Square_Hit(this->x,this->y,this->tex_x,this->tex_y,X_MIN + x*CHIP_X,Y_MAX - (y+1)*CHIP_Y,CHIP_X,CHIP_Y)){
  if (this->x>X_MIN + CHIP_X * x + CHIP_X - 6){
  if (this->y + this->tex_y>Y_MAX - (y + 1)*CHIP_Y + 6 && this->y < Y_MAX - (y + 1)*CHIP_Y + CHIP_Y - 6){
  this->x = X_MIN + CHIP_X * x + CHIP_X;
  }
  }
  //左側の判定
  if (this->x + this->tex_x < X_MIN + CHIP_X * x + 6){
  if (this->y + this->tex_y>Y_MAX - (y + 1)*CHIP_Y + 6 && this->y < Y_MAX - (y + 1)*CHIP_Y + CHIP_Y - 6){
  this->x = X_MIN + CHIP_X*x - this->tex_x;
  }
  }
  //上部の判定
  if (this->y>Y_MAX - y * CHIP_Y - 10){
  this->y = Y_MAX - y * CHIP_Y;
  if (!jumping){
  on_foot = true;
  }
  }
  //下部の判定
  if (this->y + this->tex_y <Y_MAX - (y+1) * CHIP_Y + 6){
  if (this->x>X_MIN + CHIP_X * x + 6 && this->x + this->tex_x < X_MIN + CHIP_X * x + CHIP_X){
  this->y = Y_MAX - (y+1) * CHIP_Y - this->tex_y;
  }
  }
  }*/
  for (int y = 0; y < 20; y++){
    for (int x = 0; x < 32; x++){
      //ワープチップ
      if (map[y][x] == 8){
        if (Square_Hit(this->x, this->y, this->tex_x, this->tex_y, X_MIN + x*CHIP_X, Y_MAX - (y + 1)*CHIP_Y, CHIP_X, CHIP_Y)){
          on_platform = false;
          on_foot = false;
          if (app.isPushKey('Z')){
            warp(app, map_id,x,y);
          /*switch (this->map_id){
            case ALPHA01:
              map_id = ALPHA02;
              break;
            case ALPHA02:
              if (x >= 0 && x <= 3){
                map_id = ALPHA03;
              }
              if (x >= 29 && x <= 31){
                map_id = ALPHA04;
              }
              break;
            case ALPHA03:
            case ALPHA04:
              map_id = ALPHA01;
              break;
            }*/
            change = true;
          }
        }
      }
      //上辺のみ当り判定チップ
      else if (map[y][x] == 2){
        if (Square_Hit(this->x, this->y, this->tex_x, this->tex_y, X_MIN + x*CHIP_X, Y_MAX - (y + 1)*CHIP_Y, CHIP_X, CHIP_Y)){
          if (this->y > Y_MAX - CHIP_Y * y - 15){
            if (!jumping){
              on_foot = true;
              on_platform = true;
            }
            this->y = Y_MAX - CHIP_Y * y;
          }
        }
      }
      //上辺&左当り判定チップ
      else if (map[y][x] == 3){
        if (Square_Hit(this->x, this->y, this->tex_x, this->tex_y, X_MIN + x*CHIP_X, Y_MAX - (y + 1)*CHIP_Y, CHIP_X, CHIP_Y)){
          if (this->x + this->tex_x < X_MIN + CHIP_X * x + 10){
            if (this->y + this->tex_y > Y_MAX - (y + 1)*CHIP_Y - 6 && this->y < Y_MAX - (y + 1)*CHIP_Y + CHIP_Y + 6){
              this->x = X_MIN + CHIP_X*x - this->tex_x;
              on_platform = true;
            }
          }
          else if (this->y > Y_MAX - CHIP_Y * y - 15){
            if (!jumping){
              on_foot = true;
              on_platform = true;
            }
            this->y = Y_MAX - CHIP_Y * y;
          }
        }
      }
      //上辺&右当り判定チップ
      else if (map[y][x] == 4){
        if (Square_Hit(this->x, this->y, this->tex_x, this->tex_y, X_MIN + x*CHIP_X, Y_MAX - (y + 1)*CHIP_Y, CHIP_X, CHIP_Y)){
          if (this->x>X_MIN + CHIP_X * x + CHIP_X - 10){
            if (this->y + this->tex_y > Y_MAX - (y + 1)*CHIP_Y - 6 && this->y < Y_MAX - (y + 1)*CHIP_Y + CHIP_Y + 6){
              this->x = X_MIN + CHIP_X * x + CHIP_X;
            }
          }
          else if (this->y > Y_MAX - CHIP_Y * y - 15){
            if (!jumping){
              on_foot = true;
              on_platform = true;
            }
            this->y = Y_MAX - CHIP_Y * y;
          }
        }
      }
      //上辺、下辺当り判定チップ
      else if (map[y][x] == 5){
        if (Square_Hit(this->x, this->y, this->tex_x, this->tex_y, X_MIN + x*CHIP_X, Y_MAX - (y + 1)*CHIP_Y, CHIP_X, CHIP_Y)){
          if (this->y > Y_MAX - CHIP_Y * y - 15){
            if (!jumping){
              on_foot = true;
              on_platform = true;
            }
            this->y = Y_MAX - CHIP_Y * y;
          }
          if (this->y + this->tex_y < Y_MAX - CHIP_Y * (y+1) + 15){
            jumping = false;
            on_platform = false;
            y_speed = 0;
            this->y = Y_MAX - CHIP_Y*(y + 1) -1 - this->tex_y;
          }
        }
      }
      //上辺&左当り判定チップ
      else if (map[y][x] == 6){
        if (Square_Hit(this->x, this->y, this->tex_x, this->tex_y, X_MIN + x*CHIP_X, Y_MAX - (y + 1)*CHIP_Y, CHIP_X, CHIP_Y)){
          if (this->x + this->tex_x < X_MIN + CHIP_X * x + 10){
            if (this->y + this->tex_y > Y_MAX - (y + 1)*CHIP_Y - 6 && this->y < Y_MAX - (y + 1)*CHIP_Y + CHIP_Y + 6){
              this->x = X_MIN + CHIP_X*x - this->tex_x;
              on_platform = true;
            }
          }
          else if (this->y > Y_MAX - CHIP_Y * y - 15){
            if (!jumping){
              on_foot = true;
              on_platform = true;
            }
            this->y = Y_MAX - CHIP_Y * y;
          }
        }
      }
      //上辺&右当り判定チップ
      else if (map[y][x] == 7){
        if (Square_Hit(this->x, this->y, this->tex_x, this->tex_y, X_MIN + x*CHIP_X, Y_MAX - (y + 1)*CHIP_Y, CHIP_X, CHIP_Y)){
          if (this->x>X_MIN + CHIP_X * x + CHIP_X - 10){
            if (this->y + this->tex_y > Y_MAX - (y + 1)*CHIP_Y - 6 && this->y < Y_MAX - (y + 1)*CHIP_Y + CHIP_Y + 6){
              this->x = X_MIN + CHIP_X * x + CHIP_X;
            }
          }
          else if (this->y > Y_MAX - CHIP_Y * y - 15){
            if (!jumping){
              on_foot = true;
              on_platform = true;
            }
            this->y = Y_MAX - CHIP_Y * y;
          }
        }
      }
      //ステージベースチップ
      else if (map[y][x] == 1){
        if (Square_Hit(this->x, this->y, this->tex_x, this->tex_y, X_MIN + x*CHIP_X, Y_MAX - (y + 1)*CHIP_Y, CHIP_X, CHIP_Y)){
          if (!jumping){
            on_foot = true;
            on_platform = true;
          }
          this->y = Y_MAX - (y + 1)*CHIP_Y + CHIP_Y;
        }
      }
      //チップ無し
      else if (map[y][x] == 0){
        if (Square_Hit(this->x, this->y, this->tex_x, this->tex_y, X_MIN + x*CHIP_X, Y_MAX - (y + 1)*CHIP_Y, CHIP_X, CHIP_Y)){
          on_platform = false;
          on_foot = false;
        }
      }
    }
  }
}
Esempio n. 6
0
//移動処理
void Player::move(AppEnv& app){
  this->y += y_speed;
  
  /*---上---*/
  if (app.isPushKey(GLFW_KEY_UP) && on_foot){
    y_speed = 20;
    on_foot = false;
    jumping = true;
  }
  if (!on_platform){
    y_speed -= 0.75;
  }
  if (y_speed < 0){
    jumping = false;
  }
  if (y_speed <= -10){
    y_speed = -10;
  }
  if (on_foot){
    y_speed = 0;
  }

  if (!c_ex.UP && this->y >= UP_X){
    this->y = UP_X;
    ex.UP = true;
  }
  else ex.UP = false;

  if (!c_ex.UP && ex.UP){
    cam_y += 10;
  }

  if (cam_y >= 800){
    cam_y = 800;
    c_ex.UP = true;
    if (y + tex_y >= 400){
      y = 400 - tex_y;
      y_speed = -0.75;
    }
  }

  if (c_ex.UP && this->y<UP_X){
    c_ex.UP = false;
  }

  /*///--左--///*/
  //!カメラのx軸最少値(左) && ボタン判定 && 動ける範囲内
  if (!c_ex.LEFT && app.isPressKey(GLFW_KEY_LEFT) && x > LEFT_X){
    x -= speed;
    if (x <= LEFT_X){
      x = LEFT_X;
    }
  }

  //ボタン判定 && 動ける範囲のx軸最小値(左)
  if (app.isPressKey(GLFW_KEY_LEFT) && x <= LEFT_X){
    ex.LEFT = true;
  }
  else ex.LEFT = false;//それ以外はfalse


  //!カメラx軸最小値(左) && 動ける範囲のx軸最小値(左)
  if (!c_ex.LEFT && ex.LEFT){
    //カメラが動く
    cam_x -= speed;
    if (cam_x < 0){     //最小値により小さくなれば、カメラ固定
      cam_x = 0;
      c_ex.LEFT = true; //カメラのx軸最少値(左)に居る判定
    }
  }

  //カメラのx軸最小値(左)に居る判定
  if (c_ex.LEFT && app.isPressKey(GLFW_KEY_LEFT)){
    //カメラが固定されたら、カメラ方向に行ける
    x -= speed;
    if (x <= -640){
      x = -640;
    }
  }

  //フラグがtrue && 動ける範囲に戻った
  if (c_ex.LEFT && x > LEFT_X){
    c_ex.LEFT = false;//カメラの最小値には居ない
  }

  /*---下---*/

  if (!c_ex.DOWN && this->y <= DOWN_X){
    this->y = DOWN_X;
    ex.DOWN = true;
  }
  else ex.DOWN = false;

  if (!c_ex.DOWN && ex.DOWN){
    cam_y -= 10;
  }

  if (cam_y <= 0){
    cam_y = 0;
    c_ex.DOWN = true;
  }

  if (c_ex.DOWN && this->y > DOWN_X){
    c_ex.DOWN = false;
  }

  /*///--右--///*/
  //!カメラのx軸最大値(右) && ボタン判定 && 動ける範囲内
  if (!c_ex.RIGHT && app.isPressKey(GLFW_KEY_RIGHT) && x < RIGHT_X){
    x += speed;
    if (x >= RIGHT_X){
      x = RIGHT_X;
    }
  }

  //ボタン判定 && 動ける範囲のx軸最大値(右)
  if (app.isPressKey(GLFW_KEY_RIGHT) && x >= RIGHT_X){
    ex.RIGHT = true;
  }
  else ex.RIGHT = false;//それ以外はfalse

  //!カメラのx軸最大値(右) && 動ける範囲のx軸最大値(右)
  if (!c_ex.RIGHT && ex.RIGHT){
    //カメラが動く
    cam_x += speed;
    if (cam_x > 1280){  //最小値により小さくなれば、カメラ固定
      cam_x = 1280;
      c_ex.RIGHT = true;//カメラのx軸最大値(右)に居る判定
    }
  }

  //カメラのx軸最大値(右)に居る判定
  if (c_ex.RIGHT && app.isPressKey(GLFW_KEY_RIGHT)){
    //カメラが固定されたら、カメラ方向に行ける
    x += speed;
    if (x + tex_x >= 640){
      x = 640 - tex_x;
    }
  }

  //フラグがtrue && 動ける範囲に戻った
  if (c_ex.RIGHT && x < RIGHT_X){
    c_ex.RIGHT = false;//カメラの最大値には居ない
  }

  std::cout << "X " << this->x << std::endl;
  std::cout << "Y " << this->y << std::endl;
  std::cout << "cam_X " << this->cam_x << std::endl;
  std::cout << "cam_Y " << this->cam_y << std::endl;
  std::cout << "ex " << this->ex.UP << this->ex.LEFT << this->ex.DOWN << this->ex.RIGHT << std::endl;
  std::cout << "c_ex " << this->c_ex.UP << this->c_ex.LEFT << this->c_ex.DOWN << this->c_ex.RIGHT << std::endl;
}