Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #TouhouDanmakufu[Single]
- #ScriptVersion[3]
- #Title["Tutorial 01"]
- #Text["Simple enemy bullet tutorial"]
- let bossObj;
- let bossX=0;
- let bossY=0;
- let imgBoss = GetCurrentScriptDirectory ~ "Ichirin.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 ocation when loaded
- ObjMove_SetPosition(bossObj,192,-100);
- //Warp boss to desired x y location at desired speed
- ObjMove_SetDestAtSpeed(bossObj,192,120,5);
- //move boss
- ObjMove_SetDestAtSpeed(bossObj,192,120,5);
- mainTask;
- }
- @Event {
- //setting the boss timer and life
- alternative(GetEventType())
- case(EV_REQUEST_LIFE) {
- SetScriptResult(1000);
- }
- case(EV_REQUEST_TIMER){
- SetScriptResult(45);
- }
- }
- @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{
- }
- // your best friend forever.
- function wait(w){loop(w){yield;}}
- task mainTask{
- 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,32,32);
- ObjSprite2D_SetDestCenter(bossObj);
- ObjRender_SetScaleXYZ(bossObj,5,5,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,32,32); ObjRender_SetScaleXYZ(bossObj,0,0,0);} //boss holding location
- else if(cos(dir)<0){ObjSprite2D_SetSourceRect(bossObj,0,0,32,32); ObjRender_SetScaleXYZ(bossObj,0,0,0);} //hence moving to the left
- else if(cos(dir)>0){ObjSprite2D_SetSourceRect(bossObj,0,0,32,32); ObjRender_SetScaleXYZ(bossObj,0,180,0);} //boss moving to the right
- yield;
- }
- }
- task movement{
- wait(60);
- fire;
- wait(30);
- loop{
- ObjMove_SetDestAtSpeed(bossObj,100,130,5);
- wait(45);
- fire;
- wait(30);
- ObjMove_SetDestAtSpeed(bossObj,280,120,5);
- wait(45);
- fire;
- wait(30);
- }
- }
- function angleToPlayer{
- let dir=atan2(GetPlayerY-bossY,GetPlayerX-bossX);
- return dir;
- }
- task fire{
- let dir = angleToPlayer;
- loop(10) {
- CreateShotA1(bossX,bossY,3,angleToPlayer-20,14,0);
- CreateShotA1(bossX,bossY,3,angleToPlayer,14,0);
- CreateShotA1(bossX,bossY,3,angleToPlayer+20,14,0);
- wait(3);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement