Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #TouhouDanmakufu[Single]
- #ScriptVersion[3]
- #Title["Test 2"]
- #Text["Boss collision, movement and firing"]
- let bossObj;
- let bossX = 0;
- let bossY = 0;
- let imgBoss = GetCurrentScriptDirectory ~ "shikieiki.png.png";
- #include "script/default_system/Default_ShotConst.txt"
- @Initialize {
- // define a boss in bossObj and register it
- bossObj = ObjEnemy_Create(OBJ_ENEMY_BOSS);
- ObjEnemy_Regist(bossObj);
- // Warp the boss to this location when loaded
- ObjMove_SetPosition(bossObj,192,-100);
- // move boss to desired x y location at desired speed
- ObjMove_SetDestAtSpeed(bossObj,192,120,5);
- mainTask; // run mainTask
- }
- @Event {
- // setting the boss timer and life
- alternative(GetEventType())
- case(EV_REQUEST_LIFE) {
- SetScriptResult(2000);
- }
- case(EV_REQUEST_TIMER) {
- SetScriptResult(45);
- }
- case(EV_REQUEST_SPELL_SCORE){
- SetScriptResult(1000000)
- }
- @MainLoop {
- bossX = ObjMove_GetX(bossObj);
- bossY = ObjMove_GetY(bossObj);
- // collision for the shots and player
- ObjEnemy_SetIntersectionCircleToShot(bossObj,bossX,bossY,24);
- ObjEnemy_SetIntersectionCircleToPlayer(bossObj,bossX,bossY,32);
- yield;
- }
- @Finalize {
- while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){yield;}
- if(ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SHOOTDOWN_COUNT)
- +ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SPELL_COUNT) == 0){
- AddScore(ObjEnemyBossScene_GetInfo(objScene, INFO_SPELL_SCORE));
- }
- // your best friend, forever.
- function wait(w) { loop(w) { yield; } }
- task mainTask {
- fire;
- renderBoss;
- movement;
- }
- task renderBoss {
- let dir;
- let speed;
- // texture the boss, set centre as true centre.
- ObjPrim_SetTexture(bossObj,imgBoss);
- ObjSprite2D_SetSourceRect(bossObj,0,0,148,125);
- ObjSprite2D_SetDestCenter(bossObj);
- ObjRender_SetScaleXYZ(bossObj,0.7,0.7,0);
- while(!Obj_IsDeleted(bossObj)) {
- // update boss speed and direction locally
- dir = ObjMove_GetAngle(bossObj);
- speed = ObjMove_GetSpeed(bossObj);
- // if the boss is idle, show this image/rect
- if(speed == 0) { ObjSprite2D_SetSourceRect(bossObj,0,0,148,125); ObjRender_SetAngleXYZ(bossObj,0,0,0); }
- // boss holding location
- else if(cos(dir) < 0) { ObjSprite2D_SetSourceRect(bossObj,0,0,148,125); ObjRender_SetAngleXYZ(bossObj,0,0,0); }
- // boss moving to the left
- else if(cos(dir) > 0) { ObjSprite2D_SetSourceRect(bossObj,0,0,148,125); ObjRender_SetAngleXYZ(bossObj,0,180,0); }
- // boss moving to the right
- yield;
- }
- }
- task movement {
- wait(60);
- fire;
- wait(30);
- loop {
- ObjMove_SetDestAtSpeed(bossObj,100,120,5); // move to the left
- wait(45);
- fire;
- wait(30);
- ObjMove_SetDestAtSpeed(bossObj,280,120,5); // move to the right
- wait(45);
- fire;
- wait(30);
- }
- }
- function angleToPlayer {
- let dir = atan2(GetPlayerY-bossY,GetPlayerX-bossX);
- return dir;
- }
- task fire {
- while(ObjEnemy_GetInfo(bossObj, INFO_LIFE) > 0){
- let angleT = GetAngleToPlayer(bossObj);
- loop(20){
- ascent(i in 0..1){
- CreateShotA1(ObjMove_GetX(bossObj), ObjMove_GetY(bossObj), 3 - i/3, angleT, DS_BALL_L_SKY + i, 20);
- }
- angleT += 360/ 15;
- }
- wait(60);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement