Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #TouhouDanmakufu[Single]
- #ScriptVersion[3]
- #Title["Test"]
- #Text["Test"]
- //load the default shotsheet
- #include"script/default_system/Default_ShotConst.txt"
- //----------------------------------------------------
- //Declaring Global Variables
- //----------------------------------------------------
- let objEnemy; //enemy object
- let objPlayer; //player object
- let frame = 0; //Counter for timing enemy movements
- //----------------------------------------------------
- //Enemy movement
- //----------------------------------------------------
- @Event
- {
- alternative(GetEventType())
- case(EV_REQUEST_LIFE)
- {
- //Script requests for the enemy life
- SetScriptResult(500);//setting enemy life to 500
- }
- }
- @Initialize
- {
- //Sets variable "objPlayer" to the Player ID
- objPlayer = GetPlayerObjectID();
- //Create and register enemy object
- objEnemy = ObjEnemy_Create(OBJ_ENEMY_BOSS);
- ObjEnemy_Regist(objEnemy);
- //Setting the enemy's image
- let imgExRumia = GetCurrentScriptDirectory ~ "ExRumia/ExRumia.png"; //file path to enemy image
- ObjPrim_SetTexture(objEnemy, imgExRumia); //Setting the above image file as a texture to the enemy object(objEnemy)
- ObjSprite2D_SetSourceRect(objEnemy, 64, 1, 127, 64); //Setting the rectangle coordinates in the enemy image to use(Left, Top, Right, Bottom).
- ObjSprite2D_SetDestCenter(objEnemy); //Positioning the center of the rectangle(w/texture) at (0, 0) on the stage(top left corner).
- //Moving to the coordinate (cx, 120) in 60 frames
- let cx = GetStgFrameWidth() / 2;//defines the variable cx as the horizontal middle of the stage. (Stage width / 2)
- ObjMove_SetDestAtFrame(objEnemy, cx, 120, 60);
- }
- @MainLoop
- {
- //retrieving enemy coordinates
- let ex = ObjMove_GetX(objEnemy);
- let ey = ObjMove_GetY(objEnemy);
- if(frame == 180)
- {
- //executes when frame is equal to 180
- //retrieves player coordinates
- let px = GetPlayerX();
- let py = GetPlayerY();
- //calculats angle between enemy and player
- let angleToPlayer = atan2(py - ey, px - ex);
- //Creates a 5-way shot by increasing the angle by 15, starting from -30 degrees.
- let angle=0;
- while(angle<360)
- {//(Executes while "angle" is less than 360, while increasing by 15 degrees each loop)
- //Creates bullets that will
- //angle towards the player at the same time
- let obj = CreateLooseLaserA1(ex, ey, 2, angle, 100, 20, DS_BEAM_RED, 30);
- //60 frames after being fired, the bullets are angled and aimed at the player
- ObjMove_AddPatternA4(obj, 60, 3, 0, 0, 0, 3, objPlayer, NO_CHANGE);
- angle += 15;
- }
- frame = 0;//frame is returned to 0 after firing
- }
- //Setting the enemy hit box
- ObjEnemy_SetIntersectionCircleToShot(objEnemy, ex, ey, 32);//hitbox against player bullets. 32 is the radius.
- ObjEnemy_SetIntersectionCircleToPlayer(objEnemy, ex, ey, 24);//hitbox against the player. 24 is the radius.
- //adding +1 to frame. "frame++" is equivalent to "frame = frame + 1;" or "frame += 1;"
- frame++;
- //if the enemy's life is 0
- if(ObjEnemy_GetInfo(objEnemy, INFO_LIFE) <= 0)
- {
- //The enemy is killed immediately when life is 0
- //As this is a beginner sample script,
- //the script is ended immediately without waiting for an explosion effect.
- Obj_Delete(objEnemy);
- CloseScript(GetOwnScriptID());
- return;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement