Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #TouhouDanmakufu[Single]
- #ScriptVersion[3]
- #Title["Project"]
- #Text["Let's try this out"]
- let bossObj;
- let bossX = 0;
- let bossY = 0;
- let count = 0;
- let count2 = 0;
- let animFrame = 0;
- let animFrame2 = 0;
- let imgBoss = GetCurrentScriptDirectory ~ "texture/cirno.png";
- let background = GetCurrentScriptDirectory ~ "texture/background.png";
- let overlay = GetCurrentScriptDirectory ~ "texture/blizzard.png";
- let spellcardSFX = GetCurrentScriptDirectory ~ "sfx/spellcard.wav";
- let bossdeathSFX = GetCurrentScriptDirectory ~ "sfx/death.wav";
- #include "script/default_system/Default_Shotconst.txt"
- #include "script/default_system/Default_Effect.txt"
- @Initialize {
- // automatically deletes objects when this script ends
- SetAutoDeleteObject(true);
- bossObj = ObjEnemy_Create(OBJ_ENEMY_BOSS);
- ObjEnemy_Regist(bossObj);
- // warp boss when loaded
- ObjMove_SetPosition(bossObj,192,-100);
- // move boss to certain place at certain speed
- ObjMove_SetDestAtSpeed(bossObj,192,120,8);
- // Loads the sounds
- LoadSound(spellcardSFX);
- LoadSound(bossdeathSFX);
- // Plays sound effect as attack starts up
- PlaySE(spellcardSFX);
- mainTask;
- }
- @Event {
- // Life and time
- alternative(GetEventType())
- case(EV_REQUEST_LIFE) {
- SetScriptResult(1500);
- }
- case(EV_REQUEST_TIMER) {
- SetScriptResult(60);
- }
- }
- @MainLoop {
- bossX = ObjMove_GetX(bossObj);
- bossY = ObjMove_GetY(bossObj);
- // Collision for shots and player 24 is boss hitbox 32 is boss collision box
- ObjEnemy_SetIntersectionCircleToShot(bossObj,bossX,bossY,24);
- ObjEnemy_SetIntersectionCircleToPlayer(bossObj,bossX,bossY,32);
- yield;
- }
- @Finalize {
- }
- function wait(w) {
- loop(w) {
- yield;
- }
- }
- function angleToPlayer {
- let dir = GetAngleToPlayer(bossObj);
- return dir;
- }
- task mainTask {
- renderBoss;
- renderBG;
- movement;
- TEnd;
- }
- task renderBG {
- let scrollTex = 0;
- // background, priority is roman 1, so I
- let obj = ObjPrim_Create(OBJ_SPRITE_2D);
- Obj_SetRenderPriorityI(obj,20);
- ObjPrim_SetTexture(obj,background);
- ObjSprite2D_SetSourceRect(obj,0,0,384,210);
- ObjSprite2D_SetDestRect(obj,0,0,GetStgFrameWidth,GetStgFrameHeight);
- // spell card overlay texture
- let overlayObj = ObjPrim_Create(OBJ_SPRITE_2D);
- Obj_SetRenderPriorityI(overlayObj,21);
- ObjPrim_SetTexture(overlayObj,overlay);
- ObjRender_SetBlendType(overlayObj,BLEND_ADD_ARGB); // blend type ADDITIVE with alpha ability and RGB color
- ObjRender_SetAlpha(overlayObj,200); // set Alpha value to make it transparent, 0-250, most visible at 250
- ObjSprite2D_SetSourceRect(overlayObj,0,0,256,256);
- ObjSprite2D_SetDestRect(overlayObj,0,0,GetStgFrameWidth,GetStgFrameHeight);
- // as long as boss is alive, scroll overlay from top left to bottom right
- while(!Obj_IsDeleted(bossObj)) {
- ObjSprite2D_SetSourceRect(overlayObj,0-scrollTex,0-scrollTex,256-scrollTex,256-scrollTex);
- scrollTex += 2;
- yield;
- }
- Obj_Delete(overlayObj);
- }
- task renderBoss {
- let dir;
- let speed;
- ObjPrim_SetTexture(bossObj,imgBoss);
- ObjSprite2D_SetSourceRect(bossObj,0,0,64,64);
- ObjSprite2D_SetDestCenter(bossObj);
- ObjRender_SetScaleXYZ(bossObj,1.0,1.0,0);
- while(!Obj_IsDeleted(bossObj)) {
- dir = ObjMove_GetAngle(bossObj);
- speed = ObjMove_GetSpeed(bossObj);
- // animation handling
- if(speed == 0) {
- // the 64 in the second line says when the last picture ends, 128 is where the next starts
- // first value is left side of picture, third is right side, second is top side, fourth is bottom side
- ObjRender_SetAngleXYZ(bossObj,0,0,0);
- if(animFrame < 15) { ObjSprite2D_SetSourceRect(bossObj,0,0,64,64); }
- if(animFrame >= 15 && animFrame < 30) { ObjSprite2D_SetSourceRect(bossObj,64,0,128,64); }
- if(animFrame >= 30 && animFrame < 45) { ObjSprite2D_SetSourceRect(bossObj,128,0,192,64); }
- if(animFrame >= 45) { ObjSprite2D_SetSourceRect(bossObj,192,0,256,64); }
- animFrame2 = 0;
- // boss idle
- }
- else if(cos(dir) < 0) {
- ObjRender_SetAngleXYZ(bossObj,0,180,0); // 180 flips sprite around
- if(animFrame2 < 15) { ObjSprite2D_SetSourceRect(bossObj,0,64,64,128); }
- if(animFrame2 >= 15 && animFrame2 < 30) { ObjSprite2D_SetSourceRect(bossObj,64,64,128,128); }
- if(animFrame2 >= 30 && animFrame2 < 45) { ObjSprite2D_SetSourceRect(bossObj,128,64,192,128); }
- if(animFrame2 >= 45) { ObjSprite2D_SetSourceRect(bossObj,192,64,256,128); }
- // boss moving right
- }
- else if(cos(dir) > 0) {
- ObjRender_SetAngleXYZ(bossObj,0,180,0); // 180 flips sprite around
- if(animFrame2 < 15) { ObjSprite2D_SetSourceRect(bossObj,0,128,64,192); }
- if(animFrame2 >= 15 && animFrame2 < 30) { ObjSprite2D_SetSourceRect(bossObj,64,128,128,192); }
- if(animFrame2 >= 30 && animFrame2 < 45) { ObjSprite2D_SetSourceRect(bossObj,128,128,192,192); }
- if(animFrame2 >= 45) { ObjSprite2D_SetSourceRect(bossObj,192,128,256,192); }
- // boss moving to right, 180 mirrors image
- }
- animFrame++; // count animFrame (++ makes value go up each frame, -- goes down each frame) you can also do things like +=2 to make it go up by 2 every frame
- animFrame2++; // count animFrame2
- if(animFrame > 60) { animFrame = 0; } // makes frame count reset after reaching 60
- yield;
- }
- }
- task movement {
- wait(60);
- while(ObjEnemy_GetInfo(bossObj, INFO_LIFE) > 0) {
- fire;
- wait(25);
- if(count >= 60) { shoot; }
- count++;
- yield;
- }
- }
- task fire {
- loop(20) {
- CreateShotA1(bossX,bossY,2,count2+90,14,0);
- wait(3);
- count2++;
- if(count >=360) { count = 0; }
- }
- }
- task shoot {
- loop(20) {
- CreateShotA1(bossX,bossY,1,count2-180,10,0);
- CreateShotA1(bossX,bossY,3,count2,20,0);
- wait(20); // try 20 or 3
- count2+=10;
- if(count >=360) { count = 0; }
- }
- }
- task TEnd {
- // as long as boss HP is above 0, this part is ignored
- while(ObjEnemy_GetInfo(bossObj, INFO_LIFE) > 0) {
- wait(20);
- }
- // plays sound before boss explodes, in this case
- PlaySE(bossdeathSFX);
- // the last two numbers are the opacity of explosion and speed of explosion, respectively
- TExplosionA(bossX,bossY,10,0.5);
- Obj_Delete(bossObj);
- DeleteShotAll(TYPE_ALL, TYPE_ITEM); // turns remaining bullets on screen into points
- wait(120);
- CloseScript(GetOwnScriptID);
- }
- Pictures: http://imgur.com/a/TnLqg
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement