let CurrentStage = 0;
let CameraX = 0;
let CameraY = 0;
let CameraZ = 0;
let CameraDist = 200;
let CameraAngleX = 90;
let CameraAngleY = 0;

let FogColor = [255, 255, 255];
let FogMin = 500;
let FogMax = 1000;

let bgCounter = 0;

let bgPlayerOffsetX = 0;
let bgPlayerOffsetY = 0;

let imgBackdrop = GetCurrentScriptDirectory ~ "stage\backdrop.png";
let BackdropColor = [255, 255, 255];

sub SetCameraAndFog {
  SetViewTo(CameraX, CameraY, CameraZ);
  SetViewFrom(CameraDist, CameraAngleX, CameraAngleY);
  WriteZBuffer(true);
  UseZBuffer(true);
  SetFog(FogMin, FogMax, FogColor[0], FogColor[1], FogColor[2]);
  
  SetTexture(imgBackdrop);
  SetGraphicRect(0, 0, 2048, 2048);
  SetGraphicAngle(0, 0, 0);
  SetColor(BackdropColor[0], BackdropColor[1], BackdropColor[2]);
  DrawGraphic3D(0, 0, -10);
  
  SetColor(255, 255, 255);
}

function Wait(t){
  loop(t){ yield; }
}

sub WaitForZeroEnemy {
  while(GetCommonDataDefaultEx("temp", "enemy num", 0) > 0){ yield; }
}