#include<iostream>
#include<graphics.h>
using namespace std;

#define WIDTH  getwidth()
#define HEIGHT getheight()

#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME)&0x8000)?1:0)

void getZoomImage(PIMAGE pimg,const char*fileName,int width,int height){
	PIMAGE temp=newimage();
	getimage(temp,fileName);
	if(getwidth(pimg)!=width||getheight(pimg)!=height)resize(pimg, width, height);
	putimage(pimg, 0, 0, width, height, temp, 0, 0, getwidth(temp), getheight(temp));
	delimage(temp);
}

PIMAGE ad=newimage();
PIMAGE logo=newimage(); 

MUSIC music;

int main(){
	setinitmode(1);
	initgraph(-1,-1);
	
	int k=(WIDTH/2)/0.38067;
	getZoomImage(ad,"adexe\\ad.png",WIDTH/2,k);
	getZoomImage(logo,"adexe\\logo.png",WIDTH,HEIGHT);
	
	music.OpenFile("adexe\\admusic.mp3");
	music.Play();
	
	int y=HEIGHT;
	
	for(;;){
		cleardevice();
		
		y--;
		
		putimage(WIDTH/4,y,ad);
		
		delay_fps(50);
		
		if(y<=-k){
			break;
		}
	}
	putimage(0,0,logo);
	for(;;){
		delay_fps(100);
		
		if(KEY_DOWN(VK_ESCAPE)){
			exit(0);
		}
		if(KEY_DOWN(VK_LBUTTON)){
			exit(0);
		}
	}
}
