Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #TouhouDanmakufu
- #Title[Profielwerkstuk 1]
- #Text[(easy)]
- #Player[FREE]
- #ScriptVersion[2]
- script_enemy_main{
- let CSD = GetCurrentScriptDirectory;
- let imgBoss = CSD ~ "img/Death Ball.png";
- let bg = CSD ~ "img/Stars.png";
- let slide = 0;
- @Initialize{
- SetLife(1000);
- SetTimer(60);
- SetScore(100000);
- SetX(GetCenterX);
- SetY(GetClipMaxY/4);
- LoadGraphic(imgBoss);
- LoadGraphic(bg);
- CutIn(YOUMU,"Wind Bullets - easy -",imgBoss,0,0,100,100);
- LoadMusic(CSD ~ "bgm\Bad Situation.mp3");
- PlayMusic(CSD ~ "bgm\Bad Situation.mp3");
- mainTask;
- }
- @MainLoop{
- SetCollisionA(GetX,GetY,50);
- SetCollisionB(GetX,GetY,40);
- yield;
- }
- @DrawLoop{
- SetTexture(imgBoss);
- SetRenderState(ALPHA);
- SetAlpha(255);
- SetGraphicRect(0,0,100,100);
- SetGraphicScale(1,1);
- SetGraphicAngle(0,0,0);
- DrawGraphic(GetX,GetY);
- }
- @BackGround{
- SetTexture(bg);
- SetRenderState(ALPHA);
- SetAlpha(255);
- SetGraphicRect(0,0-slide,512,512-slide);
- SetGraphicScale(1,1);
- SetGraphicAngle(0,0,0);
- DrawGraphic(GetCenterX,GetCenterY);
- slide +=2;
- }
- @Finalize{
- DeleteGraphic(imgBoss);
- DeleteGraphic(bg);
- }
- //main task, activates stuff
- task mainTask{
- yield;
- //movement;
- hypocycloid1(GetEnemyX,GetEnemyY,100,0.7,0.8);
- hypocycloid2(GetEnemyX,GetEnemyY,100,0.7,0.8);
- }
- task movement{
- wait(120);
- loop{
- SetMovePosition01(GetCenterX-100,120,5);
- wait(120);
- SetMovePosition01(GetCenterX+100,120,5);
- wait(120);
- yield;
- }
- }
- task hypocycloid1(a,b,r,k,l){
- let t = 0;
- let obj = Obj_Create(OBJ_SHOT);
- ObjShot_SetGraphic(obj,RED01);
- while(Obj_BeDeleted(obj)==false) {
- t += 3;
- let x = a + r * ( (1 - k) * cos(t) + l * k * cos((1 - k) / k * t));
- let y = b + r * ( (1 - k) * sin(t) - l * k * sin((1 - k) / k * t));
- Obj_SetPosition(obj,x,y);
- yield;
- }
- }
- task hypocycloid2(a,b,r,k,l){
- loop{
- k = absolute(trunc(10*k)/10 - trunc(k));
- let limit = 360 * (ToFractionNom(k) / GCD(ToFractionNom(k), ToFractionDeNom(k)));
- let t = 0;
- loop(200){
- t += limit/200;
- let x = a + r * ( (1 - k) * cos(t) + l * k * cos((1 - k) / k * t));
- let y = b + r * ( (1 - k) * sin(t) - l * k * sin((1 - k) / k * t));
- RotatingBullet(a, b, x, y, GetAngleToPlayer, RED01);
- }
- wait(300);
- }
- }
- task RotatingBullet(a, b, x, y, angle, graphic) {
- let obj=Obj_Create(OBJ_SHOT);
- Obj_SetPosition(obj, x, y);
- ObjShot_SetGraphic(obj, graphic);
- ObjShot_SetBombResist (obj, true);
- let angle2 = atan3(x-a,y-b);
- let t2 = 0;
- let r = dist(x,y,a,b);
- while(Obj_BeDeleted(obj)==false) {
- t2 += 1;
- a += 2*cos(angle);
- b += 2*sin(angle);
- x = a + r * cos(t2 + angle2);
- y = b + r * sin(t2 + angle2);
- Obj_SetPosition(obj, x, y);
- yield;
- }
- }
- function dist(x1,y1,x2,y2){
- let d = ((x1-x2)^2 + (y1-y2)^2)^0.5;
- return d;
- }
- function atan3(x,y){
- if ( x == 0 && y == 0 ){
- break;
- }
- if ( x == 0 ){
- if ( y > 0 ){
- return 90;
- }else{
- return 270;
- }
- }
- if ( y == 0 ){
- if ( x > 0 ){
- return 0;
- }else{
- return 180;
- }
- }
- let a = atan(y/x);
- if ( x < 0 ){a = -a;}
- return a;
- }
- function GCD(a,b){
- let c;
- loop{
- if ( b == 0 ){return a;}
- c = b;
- b = a % b;
- a = c;
- }
- }
- function ToFractionNom(a){
- loop{
- a *= 10;
- if( a == trunc(a) ){return a;}
- }
- }
- function ToFractionDeNom(a){
- let b = 1;
- loop{
- a *= 10;
- b *= 10;
- if( a == trunc(a) ){return b;}
- }
- }
- //wait function
- function wait (w){
- loop(w){yield;}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment