Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 48.04 KB | None | 0 0
  1. Information about object: objLink
  2. Sprite: sprLink0ID
  3. Solid: false
  4. Visible: true
  5. Depth: 0
  6. Persistent: true
  7. Parent:
  8. Children:
  9. Mask: sprLinkM
  10.  
  11. No Physics Object
  12. Create Event:
  13.  
  14. execute code:
  15.  
  16. moveable=true; //Is Link ABLE to move?
  17. moving=false; //Is Link moving?
  18. spd=1; //How fast, in pixels, does Link increase his movement speed?
  19. maxspd=2; //Maximum amount of speed Link can achieve.
  20. //Which direction is Link facing? D=Down, U=Up, L=Left, R=Right.
  21. dir='D';
  22. /*
  23. Which direction has the player pressed? This will be used for
  24. double tapping a directional key.
  25. */
  26. doublekeytapdir='';
  27. doublekeytapdly=0; //Frames left before double tapping interval ends.
  28. xoff=0; //The x offset of which to draw Link's sprite.
  29. yoff=0; //The y offset of which to draw Link's sprite.
  30. jumping=false; //Is Link jumping?
  31. z=0; //How high off of the ground, in pixels, Link is.
  32. zmax=0; //How high off of the ground, in pixels, Link needs to reach.
  33. //Has Link peaked at his needed height during the jump?
  34. zreached=false;
  35. zspd=0; //How fast is Link rising/falling, in pixels?
  36. /*
  37. How long, in frames, must Link wait in the air before the next
  38. z motion?
  39. */
  40. zdly=0;
  41. pushing=false; //Is Link pushing?
  42. //How long, in frames, has Link been pushing?
  43. pushtmr=0;
  44. digging=false; //Is Link digging?
  45. //Is Link holding up an item? 0 for 1 hand, 1 for 2 hands.
  46. holding=0;
  47. slashing=false; //Is Link slashing?
  48. charge=0; //How long, in frames, has Link been charging.
  49. tap=false; //Is Link tapping his sword against something?
  50. tapreverse=false; //Is Link recovering from tapping the sword?
  51. tapdly=0; //How long, in frames, Link has to wait before tapping again.
  52. spin=0; //How many spin attacks has Link done.
  53. defend=false; //Is Link using the shield?
  54. shieldspr=sprInvis; //The shield sprite to draw.
  55. rolling=false; //Is Link rolling?
  56. smokedly=0; //Delay before another smoke object is made.
  57. cliff=false; //Is Link jumping down a cliff or not?
  58. cliffdir=''; //Which direction is Link jumping in?
  59. cliffspd=2; //How fast Link is moving for the cliff jump.
  60. hvel=0; //Conserve horizontal velocity when against a solid.
  61. vvel=0; //Conserve vertical velocity when against a solid.
  62. myfriction=.5; //Amount of friction used to slow movement to a halt.
  63. lhspeed=0; //Conserve horizontal speed when the game is paused.
  64. lvspeed=0; //Conserve vertical speed when the game is paused.
  65. gravity_direction=270; //Gravity should point down in sideview areas.
  66. mygravity=.5; //How much gravity Link has.
  67. climbing=false; //Is Link climbing on a ladder?
  68.  
  69. Step Event:
  70.  
  71. execute code:
  72.  
  73. /*********************************************************************
  74. GAME PAUSED SECTION
  75. *********************************************************************/
  76. if (scr_pause_chk())
  77. {
  78. //Conserve vertical speed.
  79. if (vspeed!=0)
  80. {
  81. lvspeed=vspeed;
  82. vspeed=0;
  83. }
  84. //Conserve horizontal speed.
  85. if (hspeed!=0)
  86. {
  87. lhspeed=hspeed;
  88. hspeed=0;
  89. }
  90. image_speed=0; //Stop animating.
  91. exit; //Get out of this script.
  92. }
  93.  
  94. //Restore conserved vertical speed.
  95. if (lvspeed!=0)
  96. {
  97. vspeed=lvspeed;
  98. lvspeed=0;
  99. }
  100.  
  101. //Restore conserved horizontal speed.
  102. if (lhspeed!=0)
  103. {
  104. hspeed=lhspeed;
  105. lhspeed=0;
  106. }
  107.  
  108. //Flag Link as visible.
  109. visible=true;
  110.  
  111. //Keyboard Key variables.
  112. var; down=false; up=false; left=false; right=false;
  113.  
  114. //Restore any conserved movement force, if possible.
  115. if (vvel!=0)
  116. {
  117. if ((vvel>0 && place_free(x,y+1)) || (vvel<0 && place_free(x,y-1)))
  118. {
  119. vspeed=vvel;
  120. vvel=0;
  121. scr_link_collide();
  122. }
  123. }
  124. if (hvel!=0)
  125. {
  126. if ((hvel>0 && place_free(x+1,y)) || (hvel<0 && place_free(x-1,y)))
  127. {
  128. hspeed=hvel;
  129. hvel=0;
  130. scr_link_collide();
  131. }
  132. }
  133. /*******************************************************************
  134. ARROW KEY CHECKING SECTION
  135. *******************************************************************/
  136.  
  137. /*
  138. This block of code checks for the corresponding directional keys,
  139. while considering the opposite. If both up and down are held
  140. together, for example, then they cancel out.
  141. */
  142. down=(keyboard_check(vk_down) && !keyboard_check(vk_up));
  143. up=(keyboard_check(vk_up) && !keyboard_check(vk_down));
  144. left=(keyboard_check(vk_left) && !keyboard_check(vk_right));
  145. right=(keyboard_check(vk_right) && !keyboard_check(vk_left));
  146.  
  147. /*
  148. This section checks for double tapping a directional key.
  149. */
  150.  
  151. /*
  152. If there was an interval for double tapping an arrow key, subtract
  153. a frame now. If it becomes 0 (or smaller, somehow) reset the double
  154. tap checking direction, because it's no longer valid.
  155. */
  156. if (doublekeytapdly)
  157. {
  158. doublekeytapdly-=1;
  159. if (doublekeytapdly<=0)
  160. {
  161. doublekeytapdir='';
  162. }
  163. }
  164.  
  165. //Temporary variable to see if Link is told to roll.
  166. var; tempcanroll=false;
  167.  
  168. //If the player presses down...
  169. if (keyboard_check_pressed(vk_down) && !global.sideview)
  170. {
  171. scr_link_doubletap('D') //Check for down double tapping.
  172. }
  173.  
  174. //If the player presses up...
  175. if (keyboard_check_pressed(vk_up) && !global.sideview)
  176. {
  177. scr_link_doubletap('U') //Check for up double tapping.
  178. }
  179.  
  180. //If the player presses left...
  181. if (keyboard_check_pressed(vk_left))
  182. {
  183. scr_link_doubletap('L') //Check for left double tapping.
  184. }
  185.  
  186. //If the player presses right...
  187. if (keyboard_check_pressed(vk_right))
  188. {
  189. scr_link_doubletap('R') //Check for right double tapping.
  190. }
  191.  
  192. /*
  193. If Link was told to roll, we will allow for it, if he's able to.
  194. */
  195. if (tempcanroll && moveable && !rolling && !charge && !slashing && !jumping && !tap && !cliff && !spin && !digging)
  196. {
  197. /*
  198. This block of if statements just assigns Link velocity based on
  199. which direction he's facing.
  200. */
  201. if (dir=='D'){vspeed=maxspd*2.5;}
  202. else if (dir=='U'){vspeed=-maxspd*2.5;}
  203. else if (dir=='L'){hspeed=-maxspd*2.5;}
  204. else if (dir=='R'){hspeed=maxspd*2.5;}
  205.  
  206. scr_link_collide(); //Check for collision.
  207. doublekeytapdir=''; //Reset the double key tap check direction.
  208. doublekeytapdly=0; //Reset the interval for double key tapping.
  209.  
  210. moving=false; //Unflag him as moving.
  211. pushing=false; //And don't flag him as pushing either.
  212. pushtmr=0; //And reset the pushing frame counter.
  213. defend=false; //Unflag Link as defending.
  214. image_index=0; //Reset his animation frame.
  215. rolling=true; //Flag Link as rolling.
  216. sound_play(sndRoll) //Play the rolling sound effect.
  217. scr_link_sprite_change(); //Update Link's sprite.
  218. }
  219.  
  220. /*******************************************************************
  221. MOVEMENT SPEED AND FRICTION ALTERATION SECTION
  222. *******************************************************************/
  223.  
  224. //If Link is STANDING on a slow-walking tile...
  225. if (scr_link_foot_check(objSlowWalk) && !jumping)
  226. {
  227. //Temporary variable to store the calculated slow-walk speed.
  228. var; walkspd=1-(.5*defend);
  229.  
  230. maxspd=walkspd; //Assign the slow walking speed.
  231. }
  232. else
  233. {
  234. //Temporary variable for the calculated normal movement speed.
  235. var; walkspd=2-(1*defend);
  236.  
  237. maxspd=walkspd; //Assign standard walking speed.
  238. }
  239.  
  240. //If Link is rolling...
  241. if (rolling)
  242. {
  243. myfriction=.25; //Less friction during rolling.
  244. }
  245. else
  246. {
  247. myfriciton=.5; //Regular friction.
  248. }
  249.  
  250. /*********************************************************************
  251. JUMPING IN THE AIR SECTION
  252. *********************************************************************/
  253. if (jumping && moveable && !global.sideview)
  254. {
  255. /*
  256. If the Link hasn't peaked yet, the zspd should be smaller the
  257. closer he gets to his peak. Otherwise it should be larger as
  258. he approaches the ground.
  259. */
  260. zspd=max(abs(round((zmax-z) div 3)),1);
  261.  
  262. /*
  263. If Link hasn't peaked in height yet, subtract the zspd
  264. from the z value. Otherwise, add it.
  265. */
  266. if (!zpeak)
  267. {
  268. if (z-zspd>=zmax)
  269. {
  270. z-=zspd;
  271. }
  272. else
  273. {
  274. z=zmax;
  275. zpeak=true;
  276. }
  277. }
  278. else
  279. {
  280. /*
  281. Link shouldn't come down if he's jumping off a cliff,
  282. unless he's already made it down the cliff.
  283. */
  284. if (!cliff || (cliff && place_free(x,y)))
  285. {
  286. if (z+zspd<=0)
  287. {
  288. z+=zspd;
  289. }
  290. else
  291. {
  292. z=0;
  293. zpeak=false;
  294. zmax=0;
  295. cliff=false;
  296. jumping=false;
  297. sound_play(sndLand);
  298. }
  299. }
  300. }
  301. }
  302. else
  303. {
  304. zpeak=false; //Reset Link peaking at his jump.
  305. }
  306.  
  307. /********************************************************************
  308. SIDEVIEW GRAVITY SECTION
  309. ********************************************************************/
  310.  
  311. if (global.sideview)
  312. {
  313. //If Link is in the air...
  314. if (place_free(x,y+1))
  315. {
  316. //If Link is hugging the ceiling...
  317. if (vvel<0)
  318. {
  319. vvel+=mygravity; //Add the gravity to it.
  320. //Then make sure Link isn't considered hugging the floor.
  321. if (vvel>0)
  322. {
  323. vvel=0;
  324. }
  325. }
  326. else
  327. {
  328. gravity=mygravity; //Otherwise, apply gravity.
  329. }
  330. //If he wasn't jumping or rolling, reset his frame of animation.
  331. if (!jumping && !rolling)
  332. {
  333. image_index=0;
  334. }
  335. jumping=true; //Flag him as jumping.
  336. rolling=false; //Unflag him as rolling.
  337. scr_link_collide(); //Check for collision.
  338. }
  339. else
  340. {
  341. gravity=0; //Otherwise, unapply gravity.
  342. //If he was jumping, play the landing sound.
  343. if (jumping)
  344. {
  345. sound_play(sndLand);
  346. }
  347. jumping=false; //Unflag him as jumping.
  348. }
  349.  
  350. //Cap his vertical velocity at a max of 4 pixels per frame.
  351. if (vspeed>4)
  352. {
  353. vspeed=4;
  354. }
  355. }
  356. else
  357. {
  358. gravity=0; //Otherwise, no gravity.
  359. }
  360.  
  361. /********************************************************************
  362. MOVEMENT SECTION
  363. *********************************************************************/
  364.  
  365. //If Link is in a proper state to move...
  366. if (moveable && !digging && (!slashing or jumping) && !tap && !rolling && !cliff && (!spin || spin>1))
  367. {
  368. /*
  369. Store the direction Link was just facing in a temporary variable.
  370. */
  371. var; lastdir=dir;
  372.  
  373. //If any directional key held...
  374. if ((down && !global.sideview) || (up && !global.sideview) || left || right)
  375. {
  376. moving=true; //Flag Link as moving.
  377. //Apply friction to the plane he's not moving in.
  378. scr_link_friction(false);
  379. scr_link_collide(); //Check for collision with a wall.
  380. }
  381. else
  382. {
  383. //Otherwise, unflag Link as moving and pushing.
  384. moving=false;
  385. pushing=false;
  386.  
  387. scr_link_friction(true); //Apply friction in all planes.
  388. scr_link_collide(); //Check for collision with a wall.
  389. }
  390.  
  391. /*
  392. Change the direction Link is facing based on which directional
  393. keys are held down. Link's facing is locked depending on which
  394. direction he was facing before moving diagonally. So you won't
  395. have that problem some engines have where Link will always face
  396. down when holding down and left for example. He'll stay facing
  397. left if he was facing left to begin with, or down. No, Link
  398. cannot moonwalk in this engine =P. No directional change if
  399. Link is charging, using the spin attack or jumping.
  400. */
  401. if (!charge && !spin && !jumping && !defend)
  402. {
  403. if (down && ((!left && !right) || (left && dir!='L') || (right && dir!='R')))
  404. {
  405. dir='D';
  406. }
  407. if (up && ((!left && !right) || (left && dir!='L') || (right && dir!='R')))
  408. {
  409. dir='U';
  410. }
  411. if (left && ((!down && !up) || (down && dir!='D') || (up && dir!='U')))
  412. {
  413. dir='L';
  414. }
  415. if (right && ((!down && !up) || (down && dir!='D') || (up && dir!='U')))
  416. {
  417. dir='R';
  418. }
  419. }
  420.  
  421. /*
  422. If Link changed directions, the pushing frame counter needs to
  423. be reset, since he is no longer pushing in the same direction.
  424. */
  425. if (dir!=lastdir)
  426. {
  427. pushtmr=0;
  428. }
  429.  
  430. /*
  431. Movement for DOWN.
  432. */
  433. if (down && !global.sideview)
  434. {
  435. //If there's no wall below link...
  436. if (place_free(x,y+spd))
  437. {
  438. /*
  439. If he's not hugging the wall vertically, then add the
  440. momentem to his vertical motion. Otherwise, add it to
  441. his wall-hugging momentum.
  442. */
  443. if (vvel==0)
  444. {
  445. scr_link_add_vspeed(spd-((spd/2)*jumping));
  446. }
  447. else
  448. {
  449. scr_link_add_vvel(spd-((spd/2)*jumping));
  450. }
  451. scr_link_collide(); //Check for collision.
  452. pushing=false; //Unflag Link as pushing.
  453. pushtmr=0; //Reset the pushing timer.
  454. }
  455. else if (place_free(x-6,y+spd) && !left && !right && dir=='D')
  456. {
  457. /*
  458. Otherwise, try to add momentum to the left, to try and
  459. cut around the corner of a wall.
  460. */
  461. if (hvel==0)
  462. {
  463. scr_link_add_hspeed(-spd+((spd/2)*jumping));
  464. }
  465. else
  466. {
  467. scr_link_add_hvel(-spd+((spd/2)*jumping));
  468. }
  469. scr_link_collide(); //Check for collision.
  470. pushing=false; //Unflag Link as pushing.
  471. pushtmr=0; //Reset the pushing timer.
  472. }
  473. else if (place_free(x+6,y+spd) && !left && !right && dir=='D')
  474. {
  475. /*
  476. Otherwise, try to add momentum to the right, to try and
  477. cut around the corner of a wall.
  478. */
  479. if (hvel==0)
  480. {
  481. scr_link_add_hspeed(spd-((spd/2)*jumping));
  482. }
  483. else
  484. {
  485. scr_link_add_hvel(spd-((spd/2)*jumping));
  486. }
  487. scr_link_collide(); //Check for collision.
  488. pushing=false; //Unflag Link as pushing.
  489. pushtmr=0; //Reset the pushing timer.
  490. }
  491. else
  492. {
  493. scr_link_collide(); //Check for collision.
  494. if (dir=='D' && !defend && !jumping)
  495. {
  496. /*
  497. Flag Link as pushing if he isn't charging the sword,
  498. otherwise, make him perform a sword tap.
  499. */
  500. if (!charge)
  501. {
  502. pushing=true;
  503. }
  504. else if (!tapdly)
  505. {
  506. tap=true;
  507. }
  508. }
  509. }
  510. }
  511.  
  512. /*
  513. Movement for UP.
  514. */
  515. if (up && !global.sideview)
  516. {
  517. /*
  518. If Link can go directly UP without running into a solid,
  519. then make him move UP, and unflag him as pushing. Otherwise,
  520. check to see if he can slide around a corner, and isn't
  521. already holding that directional key. If so, do that, unflag
  522. him as pushing and reset the pushing frame counter. Otherwise,
  523. get as close to the wall as possible and go no further, and
  524. flag him as pushing if he is facing in this direction.
  525. */
  526. if (place_free(x,y-spd))
  527. {
  528. /*
  529. If he's not hugging the wall vertically, then add the
  530. momentem to his vertical motion. Otherwise, add it to
  531. his wall-hugging momentum.
  532. */
  533. if (vvel==0)
  534. {
  535. scr_link_add_vspeed(-spd+((spd/2)*jumping));
  536. }
  537. else
  538. {
  539. scr_link_add_vvel(-spd+((spd/2)*jumping));
  540. }
  541. scr_link_collide(); //Check for collision.
  542. pushing=false; //Unflag Link as pushing.
  543. pushtmr=0; //Reset the pushing timer.
  544. }
  545. else if (place_free(x-6,y-spd) && !left && !right && dir=='U')
  546. {
  547. /*
  548. Otherwise, try to add momentum to the left, to try and
  549. cut around the corner of a wall.
  550. */
  551. if (hvel==0)
  552. {
  553. scr_link_add_hspeed(-spd+((spd/2)*jumping));
  554. }
  555. else
  556. {
  557. scr_link_add_hvel(-spd+((spd/2)*jumping));
  558. }
  559. scr_link_collide(); //Check for collision.
  560. pushing=false; //Unflag Link as pushing.
  561. pushtmr=0; //Reset the pushing timer.
  562. }
  563. else if (place_free(x+6,y-spd) && !left && !right && dir=='U')
  564. {
  565. /*
  566. Otherwise, try to add momentum to the right, to try and
  567. cut around the corner of a wall.
  568. */
  569. if (hvel==0)
  570. {
  571. scr_link_add_hspeed(spd-((spd/2)*jumping));
  572. }
  573. else
  574. {
  575. scr_link_add_hvel(spd-((spd/2)*jumping));
  576. }
  577. scr_link_collide(); //Check for collision.
  578. pushing=false; //Unflag Link as pushing.
  579. pushtmr=0; //Reset the pushing timer.
  580. }
  581. else
  582. {
  583. scr_link_collide(); //Check for collision.
  584. if (dir=='U' && !defend && !jumping)
  585. {
  586. /*
  587. Flag Link as pushing if he isn't charging the sword,
  588. otherwise, make him perform a sword tap.
  589. */
  590. if (!charge)
  591. {
  592. pushing=true;
  593. }
  594. else if (!tapdly)
  595. {
  596. tap=true;
  597. }
  598. }
  599. }
  600. }
  601.  
  602. /*
  603. Movement for LEFT.
  604. */
  605. if (left)
  606. {
  607. /*
  608. If Link can go directly LEFT without running into a solid,
  609. then make him move LEFT, and unflag him as pushing. Otherwise,
  610. check to see if he can slide around a corner, and isn't
  611. already holding that directional key. If so, do that, unflag
  612. him as pushing and reset the pushing frame counter. Otherwise,
  613. get as close to the wall as possible and go no further, and
  614. flag him as pushing if he is facing in this direction.
  615. */
  616. if (place_free(x-spd,y))
  617. {
  618. /*
  619. If he's not hugging the wall horizontally, then add the
  620. momentem to his horizontal motion. Otherwise, add it to
  621. his wall-hugging momentum.
  622. */
  623. if (hvel==0)
  624. {
  625. scr_link_add_hspeed(-spd+((spd/2)*jumping));
  626. }
  627. else
  628. {
  629. scr_link_add_hvel(-spd+((spd/2)*jumping));
  630. }
  631. scr_link_collide(); //Check for collision.
  632. pushing=false; //Unflag Link as pushing.
  633. pushtmr=0; //Reset the pushing timer.
  634. }
  635. else if (place_free(x-spd,y-6) && !global.sideview && !down && !up && dir=='L')
  636. {
  637. /*
  638. Otherwise, try to add momentum to the north, to try and
  639. cut around the corner of a wall.
  640. */
  641. if (vvel==0)
  642. {
  643. scr_link_add_vspeed(-spd+((spd/2)*jumping));
  644. }
  645. else
  646. {
  647. scr_link_add_vvel(-spd+((spd/2)*jumping));
  648. }
  649. scr_link_collide(); //Check for collision.
  650. pushing=false; //Unflag Link as pushing.
  651. pushtmr=0; //Reset the pushing timer.
  652. }
  653. else if (place_free(x-spd,y+6) && !global.sideview && !down && !up && dir=='L')
  654. {
  655. /*
  656. Otherwise, try to add momentum to the south, to try and
  657. cut around the corner of a wall.
  658. */
  659. if (vvel==0)
  660. {
  661. scr_link_add_vspeed(spd-((spd/2)*jumping));
  662. }
  663. else
  664. {
  665. scr_link_add_vvel(spd-((spd/2)*jumping));
  666. }
  667. scr_link_collide(); //Check for collision.
  668. pushing=false; //Unflag Link as pushing.
  669. pushtmr=0; //Reset the pushing timer.
  670. }
  671. else
  672. {
  673. scr_link_collide(); //Check for collision.
  674. if (dir=='L' && !defend && !jumping)
  675. {
  676. /*
  677. Flag Link as pushing if he isn't charging the sword,
  678. otherwise, make him perform a sword tap.
  679. */
  680. if (!charge)
  681. {
  682. pushing=true;
  683. }
  684. else if (!tapdly)
  685. {
  686. tap=true;
  687. }
  688. }
  689. }
  690. }
  691.  
  692. /*
  693. Movement for RIGHT.
  694. */
  695. if (right)
  696. {
  697. /*
  698. If Link can go directly RIGHT without running into a solid,
  699. then make him move RIGHT, and unflag him as pushing. Otherwise,
  700. check to see if he can slide around a corner, and isn't
  701. already holding that directional key. If so, do that, unflag
  702. him as pushing and reset the pushing frame counter. Otherwise,
  703. get as close to the wall as possible and go no further, and
  704. flag him as pushing if he is facing in this direction.
  705. */
  706. if (place_free(x+spd,y))
  707. {
  708. /*
  709. If he's not hugging the wall horizontally, then add the
  710. momentem to his horizontal motion. Otherwise, add it to
  711. his wall-hugging momentum.
  712. */
  713. if (hvel==0)
  714. {
  715. scr_link_add_hspeed(spd-((spd/2)*jumping));
  716. }
  717. else
  718. {
  719. scr_link_add_hvel(spd-((spd/2)*jumping));
  720. }
  721. scr_link_collide(); //Check for collision.
  722. pushing=false; //Unflag Link as pushing.
  723. pushtmr=0; //Reset the pushing timer.
  724. }
  725. else if (place_free(x+spd,y-6) && !global.sideview && !down && !up && dir=='R')
  726. {
  727. /*
  728. Otherwise, try to add momentum to the north, to try and
  729. cut around the corner of a wall.
  730. */
  731. if (vvel==0)
  732. {
  733. scr_link_add_vspeed(-spd+((spd/2)*jumping));
  734. }
  735. else
  736. {
  737. scr_link_add_vvel(-spd+((spd/2)*jumping));
  738. }
  739. scr_link_collide(); //Check for collision.
  740. pushing=false; //Unflag Link as pushing.
  741. pushtmr=0; //Reset the pushing timer.
  742. }
  743. else if (place_free(x+spd,y+6) && !global.sideview && !down && !up && dir=='R')
  744. {
  745. /*
  746. Otherwise, try to add momentum to the south, to try and
  747. cut around the corner of a wall.
  748. */
  749. if (vvel==0)
  750. {
  751. scr_link_add_vspeed(spd-((spd/2)*jumping));
  752. }
  753. else
  754. {
  755. scr_link_add_vvel(spd-((spd/2)*jumping));
  756. }
  757. scr_link_collide(); //Check for collision.
  758. pushing=false; //Unflag Link as pushing.
  759. pushtmr=0; //Reset the pushing timer.
  760. }
  761. else
  762. {
  763. scr_link_collide(); //Check for collision.
  764. if (dir=='R' && !defend && !jumping)
  765. {
  766. /*
  767. Flag Link as pushing if he isn't charging the sword,
  768. otherwise, make him perform a sword tap.
  769. */
  770. if (!charge)
  771. {
  772. pushing=true;
  773. }
  774. else if (!tapdly)
  775. {
  776. tap=true;
  777. }
  778. }
  779. }
  780. }
  781.  
  782. /*
  783. Pushing Segment
  784. */
  785. if (pushing){
  786. /*
  787. If Link has been pushing for about 1/4 of a second...
  788. */
  789. if (pushtmr>=7)
  790. {
  791. //Temporary variable for a possible cliff ahead of Link.
  792. var; cliffobj=scr_link_ahead_chk(objCliff,1);
  793.  
  794. /*
  795. If there is a cliff, and Link is in a state to jump
  796. down...
  797. */
  798. if (cliffobj!=-1 && !cliff && !jumping && dir==cliffobj.dir)
  799. {
  800. hspeed=0; //Reset his horizontal speed.
  801. vspeed=0; //Reset his vertical speed.
  802. pushing=false; //Unflag Link as pushing.
  803. zmax=-16; //Have Link leave the ground a full tile.
  804. jumping=true; //Flag Link as jumping.
  805. //Jump in the direction the cliff wants.
  806. cliffdir=cliffobj.dir;
  807. sound_play(sndCliff); //Play the cliff jumping sound.
  808. cliff=true; //Flag Link as jumping off of a cliff.
  809. image_index=0; //Reset Link's animation frame.
  810. scr_link_sprite_change(); //Update Link's sprite.
  811. /*
  812. Move Link forward a bit depending on which direction he's
  813. jumping down.
  814. */
  815. if (cliffdir=='D')
  816. {
  817. y+=2;
  818. }
  819. else if (cliffdir=='U')
  820. {
  821. y-=2;
  822. }
  823. else if (cliffdir=='L')
  824. {
  825. x-=2;
  826. }
  827. else
  828. {
  829. x+=2;
  830. }
  831. }
  832. }
  833.  
  834. /*
  835. If Link hasn't been pushing for 15 frames (1/2 second), add this
  836. frame to the timer. Otherwise, check for other things.
  837. */
  838. if (pushtmr<15)
  839. {
  840. pushtmr+=1;
  841. }
  842. else
  843. {
  844. /*
  845. Define a temporary variable for checking if a pushable
  846. object is in front of Link.
  847. */
  848. var; pushobjchk=scr_link_ahead_chk(objPushable,1);
  849.  
  850. /*
  851. If there was a pushable object in front of Link, then we
  852. can do things with it.
  853. */
  854. if (pushobjchk!=-1)
  855. {
  856. /*
  857. If the object can still be pushed, and Link is trying
  858. to push the object in the right direction, if
  859. applicable...
  860. */
  861. if (pushobjchk.pushes!=0 && pushobjchk.pushx==0 && pushobjchk.pushy==0 && (pushobjchk.pushdir=='' || (pushobjchk.pushdir==dir)))
  862. {
  863. /*
  864. Then set it's pushing distance to one tile ahead,
  865. if the object can move forward and isn't at the edge
  866. of the room, and play the pushing sound effect.
  867. */
  868. if (dir=='D')
  869. {
  870. if (place_free(pushobjchk.x,pushobjchk.y+16) && pushobjchk.y+16<room_height)
  871. {
  872. pushobjchk.pushy=16;
  873. sound_play(sndPush);
  874. }
  875. }
  876. else if (dir=='U')
  877. {
  878. if (place_free(pushobjchk.x,pushobjchk.y-16) && pushobjchk.y-16>=0)
  879. {
  880. pushobjchk.pushy=-16;
  881. sound_play(sndPush);
  882. }
  883. }
  884. else if (dir=='L')
  885. {
  886. if (place_free(pushobjchk.x-16,pushobjchk.y) && pushobjchk.x-16>=0)
  887. {
  888. pushobjchk.pushx=-16;
  889. sound_play(sndPush);
  890. }
  891. }
  892. else
  893. {
  894. if (place_free(pushobjchk.x+16,pushobjchk.y) && pushobjchk.x+16<room_width)
  895. {
  896. pushobjchk.pushx=16;
  897. sound_play(sndPush);
  898. }
  899. }
  900. }
  901. }
  902. }
  903. }
  904. else
  905. {
  906. //Reset the pushing frame counter if he's not pushing.
  907. pushtmr=0;
  908. }
  909. }
  910. else if (rolling)
  911. {
  912. //Otherwise if Link is rolling...
  913.  
  914. //If there is a delay on the next smoke object...
  915. if (smokedly)
  916. {
  917. smokedly-=1; //Subtract a frame from the delay.
  918. }
  919. else
  920. {
  921. //Otherwise, make a new smoke object here.
  922. s=instance_create(x,y,objRollSmoke);
  923. /*
  924. If Link is facing down, the smoke should appear behind
  925. him. Otherwise, it should be above him.
  926. */
  927. if (dir=='D')
  928. {
  929. s.depth=depth+2;
  930. }
  931. else
  932. {
  933. s.depth=depth-2;
  934. }
  935. smokedly=4; //Set the delay to 4 frames away.
  936. }
  937.  
  938. doublekeytapdir=''; //Reset the double key tap check direction.
  939. doublekeytapdly=0; //Reset the interval for double key tapping.
  940. scr_link_friction(true); //Apply friction in all planes.
  941. scr_link_collide(); //Check for wall collission.
  942. }
  943. else
  944. {
  945. /*
  946. If Link isn't able to move at all or is using an item that locks
  947. his movement, don't flag him as moving.
  948. */
  949. moving=false;
  950. doublekeytapdir=''; //Reset the double key tap check direction.
  951. doublekeytapdly=0; //Reset the interval for double key tapping.
  952. pushing=false; //And don't flag him as pushing either.
  953. pushtmr=0; //And reset the pushing frame counter.
  954. defend=false; //Unflag him as defending.
  955. hspeed=0; //Reset his horizontal speed.
  956. vspeed=0; //Reset his vertical speed.
  957. }
  958.  
  959. /*********************************************************************
  960. ACTION/ITEM KEY PRESS SECTION
  961. *********************************************************************/
  962.  
  963. /*
  964. This section of code is for the item button checks. When these buttons
  965. are pressed, Link needs to use the items that are equipped. That is,
  966. if he is able to at all.
  967. */
  968.  
  969. //If the player presses Z...
  970. if keyboard_check_pressed(ord('Z'))
  971. {
  972. //Temporary variable for a possible interaction in front of Link.
  973. var; interactchk=scr_link_ahead_chk(objInteractable,4);
  974.  
  975. //If there isn't an interaction in front of Link, use what's on Z.
  976. if (interactchk==-1 || jumping)
  977. {
  978. scr_use_item(global.Z);
  979. }
  980. else if (!rolling)
  981. {
  982. /*
  983. Otherwise, if Link is facing in the right direction,
  984. flag the object as interacted.
  985. */
  986. if (dir==interactchk.interactdir || interactchk.interactdir=='')
  987. {
  988. interactchk.interacted=true;
  989. }
  990. }
  991. }
  992.  
  993. //If the player presses X, use what's on X.
  994. if keyboard_check_pressed(ord('X'))
  995. {
  996. scr_use_item(global.X);
  997. }
  998.  
  999. //If the player releases Z, do what needs to be done.
  1000. if keyboard_check_released(ord('Z'))
  1001. {
  1002. scr_release_button(global.Z);
  1003. }
  1004.  
  1005. //If the player releases X, do what needs to be done.
  1006. if keyboard_check_released(ord('X'))
  1007. {
  1008. scr_release_button(global.X);
  1009. }
  1010.  
  1011. /********************************************************************
  1012. SWORD CHARGING SECTION
  1013. ********************************************************************/
  1014. if (charge)
  1015. {
  1016. //If there is still a delay on the next tap, subtract a frame.
  1017. if (tapdly)
  1018. {
  1019. tapdly-=1;
  1020. }
  1021.  
  1022. //If the charge isn't fully done, add a frame to the counter.
  1023. if (charge<30 && !tap)
  1024. {
  1025. charge+=1;
  1026. /*
  1027. If the charging has just reached maximum, play the charge
  1028. sound.
  1029. */
  1030. if (charge>=30)
  1031. {
  1032. sound_play(sndCharge);
  1033. }
  1034. }
  1035. }
  1036. else
  1037. {
  1038. tapdly=0;
  1039. }
  1040.  
  1041. /*
  1042. Call Link's sprite changing script. This will change his sprite
  1043. depending on the current actions he is performing. It should be
  1044. called after the keychecks and movement, so his sprite can change
  1045. immediately after the flags for such actions are set.
  1046. */
  1047. scr_link_sprite_change();
  1048.  
  1049.  
  1050. /*********************************************************************
  1051. ANIMATION SPEED SECTION
  1052. *********************************************************************/
  1053.  
  1054. /*
  1055. This section is for Link's animation speed. He should animate at
  1056. various speeds depending on what actions he is performing. Otherwise
  1057. he'll slowly animate for his idle pose, letting him blink, and not
  1058. stare into space infinitely.
  1059. */
  1060.  
  1061. //If Link is moving or using an item that requires animation...
  1062. if (moving || digging || slashing || jumping || rolling || tap)
  1063. {
  1064. if (tap)
  1065. {
  1066. //2nd frame for tapping.
  1067. image_index=1;
  1068. }
  1069. else if (digging)
  1070. {
  1071. //Standard Digging Animation Speed.
  1072. image_speed=.25;
  1073. }
  1074. else if (slashing)
  1075. {
  1076. //Standard Slashing Animation Speed.
  1077. image_speed=.5;
  1078. }
  1079. else if (jumping)
  1080. {
  1081. //Standard Jumping Animation Speed.
  1082. image_speed=.5;
  1083. }
  1084. else if (rolling)
  1085. {
  1086. //Standard Rolling Animation Speed.
  1087. image_speed=.5;
  1088. }
  1089. else{
  1090. //Standard Walking Animation Speed.
  1091. image_speed=.5;
  1092. }
  1093. }
  1094. else
  1095. {
  1096. //If Link isn't charging, go in here.
  1097. if (!charge)
  1098. {
  1099. /*
  1100. Store the current image of animation to see if he's on the
  1101. blinking frames. If he is, he should animate faster, to finish
  1102. blinking faster. Otherwise, it should slow to a crawl, at a
  1103. purely random speed, so his intervals of not blinking aren't
  1104. consistent.
  1105. */
  1106. var; img=floor(image_index);
  1107.  
  1108. if (img==0)
  1109. {
  1110. //Standard First Frame Blinking Animation Speed.
  1111. image_speed=.0125+random(.00625);
  1112. }
  1113. else
  1114. {
  1115. //Standard After-First Frame Blinking Animation Speed.
  1116. image_speed=.25;
  1117. }
  1118. }
  1119. else
  1120. {
  1121. //Otherwise, freeze his animation entirely.
  1122. image_speed=0;
  1123. image_index=0;
  1124. }
  1125. }
  1126.  
  1127. /*********************************************************************
  1128. SLASHING AND SWORD TAPPING SECTION
  1129. *********************************************************************/
  1130.  
  1131. /*
  1132. This is for offsetting Link's sprite when he is attacking.
  1133. */
  1134. if (slashing)
  1135. {
  1136. //Store which image Link's animation is on.
  1137. var; img=floor(image_index);
  1138.  
  1139. //If he's facing Down or Up, the sprite offset is all vertical.
  1140. if (dir=='D' or dir=='U')
  1141. {
  1142. xoff=0;
  1143. yoff=img*2-(4*(img==3));
  1144. if (dir=='U')
  1145. {
  1146. yoff*=-1;
  1147. }
  1148. }
  1149. else
  1150. {
  1151. //Otherwise, the offset is all horizontal.
  1152. xoff=img*2-(4*(img==3));
  1153. yoff=0;
  1154. if (dir=='L')
  1155. {
  1156. xoff*=-1;
  1157. }
  1158. }
  1159. }
  1160. else if (tap)
  1161. {
  1162. /*
  1163. This section is for things revolving around Link tapping
  1164. the sword against a wall.
  1165. */
  1166.  
  1167. charge=1; //Reset the charging.
  1168.  
  1169. //Make his sprite move a pixel.
  1170. if (dir=='D')
  1171. {
  1172. yoff+=2-(4*tapreverse);
  1173. }
  1174. else if (dir=='U'){
  1175. yoff-=2-(4*tapreverse);
  1176. }
  1177. else if (dir=='L'){
  1178. xoff-=2-(4*tapreverse);
  1179. }
  1180. else if (dir=='R'){
  1181. xoff+=2-(4*tapreverse);
  1182. }
  1183.  
  1184. //If Link's sprite is forward by a quarter tile, do tapping stuff.
  1185. if (!tapreverse && (yoff==4 || yoff==-4 || xoff==-4 || xoff==4))
  1186. {
  1187. //Temp. variable for bush checking.
  1188. var; bushchk=scr_link_ahead_chk(objBush,8);
  1189.  
  1190. tapreverse=true; //Flag the tapping for the second phase.
  1191.  
  1192. /*
  1193. If there is a bush in front of Link, apply an appropriate
  1194. force based on which direction Link is facing, and then get rid
  1195. of the bush.
  1196. */
  1197. if (bushchk!=-1)
  1198. {
  1199. var; global.hspeedgive=0; global.vspeedgive=0;
  1200.  
  1201. if (dir=='D')
  1202. {
  1203. global.vspeedgive=3;
  1204. }
  1205. else if (dir=='U')
  1206. {
  1207. global.vspeedgive=-3;
  1208. }
  1209. else if (dir=='L')
  1210. {
  1211. global.hspeedgive=-3;
  1212. }
  1213. else
  1214. {
  1215. global.hspeedgive=3;
  1216. }
  1217.  
  1218. with bushchk
  1219. {
  1220. hspeed=global.hspeedgive;
  1221. vspeed=global.vspeedgive;
  1222. instance_destroy();
  1223. }
  1224. }
  1225. else
  1226. {
  1227. //Otherwise, play the clanking sound effect.
  1228. sound_play(sndClank);
  1229. }
  1230. }
  1231.  
  1232. //If Link's sprite made it back after tapping, go in here.
  1233. if (tapreverse && xoff==0 && yoff==0)
  1234. {
  1235. tap=false; //Unflag the tapping.
  1236. tapreverse=false; //Unflag the finishing of the tapping.
  1237. tapdly=6; //Make Link wait for a bit before the next tap.
  1238.  
  1239. //Get rid of the sword if the key is no longer held.
  1240. if (!scr_held_button_chk("sword"))
  1241. {
  1242. charge=0;
  1243. if instance_exists(objSword)
  1244. {
  1245. with objSword
  1246. {
  1247. instance_destroy();
  1248. }
  1249. }
  1250. }
  1251. scr_link_sprite_change(); //Finally, have Link update his sprite.
  1252. }
  1253. }
  1254. else
  1255. {
  1256. //Reset the sprite offset.
  1257. xoff=0;
  1258. yoff=0;
  1259. }
  1260.  
  1261. /*
  1262. if (place_meeting(x,y,objEnemy))
  1263. {
  1264. var; e=-1;
  1265. e=instance_place(x,y,objEnemy);
  1266.  
  1267. direction=point_direction(e.x,e.y,x,y);
  1268. speed=4;
  1269. }
  1270. */
  1271.  
  1272. Begin Step Event:
  1273.  
  1274. execute code:
  1275.  
  1276. //If the game is paused, get out of here.
  1277. if (scr_pause_chk())
  1278. {
  1279. exit;
  1280. }
  1281.  
  1282. /*
  1283. If Link is jumping down a cliff and he's still not at a free space,
  1284. do what's in here.
  1285. */
  1286. if (cliff && !place_free(x,y))
  1287. {
  1288. /*
  1289. Move forward, depending on which way Link is jumping down a
  1290. cliff.
  1291. */
  1292. if (cliffdir=='D')
  1293. {
  1294. y+=cliffspd;
  1295. }
  1296. else if (cliffdir=='U')
  1297. {
  1298. y-=cliffspd;
  1299. }
  1300. else if (cliffdir=='L')
  1301. {
  1302. x-=cliffspd;
  1303. }
  1304. else
  1305. {
  1306. x+=cliffspd;
  1307. }
  1308. }
  1309. else
  1310. {
  1311. cliffspd=2; //Reset the cliff jumping speed.
  1312. }
  1313.  
  1314. //Get the camera moving to where it needs to be.
  1315. scr_align_view(false);
  1316.  
  1317. End Step Event:
  1318.  
  1319. execute code:
  1320.  
  1321. /*
  1322. This section of code checks for when Link steps outside of the screen.
  1323. As soon as he does, if there is a room in that direction, a scrolling
  1324. transition should happen. Otherwise, he should be locked into the
  1325. screen, as if an invisible barrier were holding him in.
  1326. */
  1327.  
  1328. //If Link steps off of the north boundary of the screen...
  1329. if (y<0)
  1330. {
  1331. //If there is a room north of this one...
  1332. if (global.northroom!=-1)
  1333. {
  1334. //Set the next transition to the scrolling up transition.
  1335. transition_kind=17
  1336. //Flag Link as invisible, so he won't show up on the surface.
  1337. visible=false;
  1338. //Flag the Control as invisible as well for the same reason.
  1339. objControl.visible=false;
  1340. //Flag the Weather as invisible as well for the same reason.
  1341. objWeather.visible=false;
  1342. //Flag any of Link's weapons as invisible as well.
  1343. objLinkWeapon.visible=false;
  1344. scr_reset_weather(); //Reset the weather.
  1345. //If Link is jumping down a cliff, reset his animation.
  1346. if (cliff && image_index>=3)
  1347. {
  1348. image_index=0;
  1349. }
  1350. scr_align_view(true); //Orient the screen just right.
  1351. room_goto(global.northroom); //Go to the northern room.
  1352. //Now place Link at the bottom of the room.
  1353. y=room_height-sprite_height;
  1354. //And get out of this code for this frame.
  1355. exit;
  1356. }
  1357. else
  1358. {
  1359. //Otherwise, place Link back at the south edge of the screen.
  1360. y=0;
  1361. }
  1362. }
  1363.  
  1364. //If Link steps off of the south boundary of the screen...
  1365. if (y+16>room_height)
  1366. {
  1367. //If there is a room south of this one...
  1368. if (global.southroom!=-1)
  1369. {
  1370. //Set the next transition to the scrolling down transition.
  1371. transition_kind=16;
  1372. //Flag Link as invisible, so he won't show up on the surface.
  1373. visible=false;
  1374. //Flag the Control as invisible as well for the same reason.
  1375. objControl.visible=false;
  1376. //Flag the Weather as invisible as well for the same reason.
  1377. objWeather.visible=false;
  1378. //Flag any of Link's weapons as invisible as well.
  1379. objLinkWeapon.visible=false;
  1380. scr_reset_weather(); //Reset the weather.
  1381. //If Link is jumping down a cliff, reset his animation.
  1382. if (cliff && image_index>=3)
  1383. {
  1384. image_index=0;
  1385. }
  1386. scr_align_view(true); //Orient the screen just right.
  1387. room_goto(global.southroom); //Go to the southern room.
  1388. y=0; //Place Link at the top of the room now.
  1389. //And get out of this code for this frame.
  1390. exit;
  1391. }
  1392. else
  1393. {
  1394. //Otherwise, place Link back at the south edge of the screen.
  1395. y=room_height-16;
  1396. }
  1397. }
  1398.  
  1399. //If Link steps off of the west boundary of the screen...
  1400. if (x<0)
  1401. {
  1402. //If there is a room west of this one...
  1403. if (global.westroom!=-1)
  1404. {
  1405. //Set the next transition to the scrolling left transition.
  1406. transition_kind=15;
  1407. //Flag Link as invisible, so he won't show up on the surface.
  1408. visible=false;
  1409. //Flag the Control as invisible as well for the same reason.
  1410. objControl.visible=false;
  1411. //Flag the Weather as invisible as well for the same reason.
  1412. objWeather.visible=false;
  1413. //Flag any of Link's weapons as invisible as well.
  1414. objLinkWeapon.visible=false;
  1415. scr_reset_weather(); //Reset the weather.
  1416. //If Link is jumping down a cliff, reset his animation.
  1417. if (cliff && image_index>=3)
  1418. {
  1419. image_index=0;
  1420. }
  1421. scr_align_view(true); //Orient the screen just right.
  1422. room_goto(global.westroom); //Go to the western room.
  1423. //Now place Link at the right of the room.
  1424. x=room_width-sprite_width;
  1425. //And get out of this code for this frame.
  1426. exit;
  1427. }
  1428. else
  1429. {
  1430. //Otherwise, place Link back at the west edge of the screen.
  1431. x=0;
  1432. }
  1433. }
  1434.  
  1435. //If Link steps off of the east boundary of the screen...
  1436. if (x+16>room_width)
  1437. {
  1438. //If there is a room east of this one...
  1439. if (global.eastroom!=-1)
  1440. {
  1441. //Set the next transition to the scrolling right transition.
  1442. transition_kind=14;
  1443. //Flag Link as invisible, so he won't show up on the surface.
  1444. visible=false;
  1445. //Flag the Control as invisible as well for the same reason.
  1446. objControl.visible=false;
  1447. //Flag the Weather as invisible as well for the same reason.
  1448. objWeather.visible=false;
  1449. //Flag any of Link's weapons as invisible as well.
  1450. objLinkWeapon.visible=false;
  1451. scr_reset_weather(); //Reset the weather.
  1452. //If Link is jumping down a cliff, reset his animation.
  1453. if (cliff && image_index>=3)
  1454. {
  1455. image_index=0;
  1456. }
  1457. scr_align_view(true); //Orient the screen just right.
  1458. room_goto(global.eastroom); //Go to the eastern room.
  1459. x=0; //Place Link at the left of the room now.
  1460. //And get out of this code for this frame.
  1461. exit;
  1462. }
  1463. else
  1464. {
  1465. //Otherwise, place Link back at the east edge of the screen.
  1466. x=room_width-16;
  1467. }
  1468. }
  1469.  
  1470. Other Event: Room Start:
  1471.  
  1472. execute code:
  1473.  
  1474. scr_align_view(true); //Align the view instantly.
  1475. doublekeytapdir=''; //Reset the double key tap check direction.
  1476. doublekeytapdly=0; //Reset the interval for double key tapping.
  1477.  
  1478. Other Event: Animation End:
  1479.  
  1480. execute code:
  1481.  
  1482. /*
  1483. If Link was digging when his animation finished, he shouldn't
  1484. be now.
  1485. */
  1486. if (digging)
  1487. {
  1488. digging=false;
  1489. image_index=0; //Reset his animation frame.
  1490. scr_link_sprite_change(); //And have Link update his sprite.
  1491. }
  1492. else if (slashing)
  1493. {
  1494. /*
  1495. If Link was slashing...
  1496. */
  1497.  
  1498. //Temp. variable for bush checking.
  1499. var; bushchk=scr_link_ahead_chk(objBush,8);
  1500. /*
  1501. If there is a bush in front of Link, apply an appropriate
  1502. force based on which direction Link is facing, and then get rid
  1503. of the bush.
  1504. */
  1505. if (bushchk!=-1)
  1506. {
  1507. var; global.hspeedgive=0; global.vspeedgive=0;
  1508.  
  1509. if (dir=='D')
  1510. {
  1511. global.vspeedgive=3;
  1512. }
  1513. else if (dir=='U')
  1514. {
  1515. global.vspeedgive=-3;
  1516. }
  1517. else if (dir=='L')
  1518. {
  1519. global.hspeedgive=-3;
  1520. }
  1521. else
  1522. {
  1523. global.hspeedgive=3;
  1524. }
  1525.  
  1526. with bushchk
  1527. {
  1528. hspeed=global.hspeedgive;
  1529. vspeed=global.vspeedgive;
  1530. instance_destroy();
  1531. }
  1532. }
  1533.  
  1534. /*
  1535. If Link is at full health, has at least the Master Sword,
  1536. and there isn't a sword beam already on the screen...
  1537. */
  1538. if (global.hearts==global.heartmax && global.sword>=2 && !instance_exists(objSwordBeam))
  1539. {
  1540. //Create a Sword Beam right on the sword.
  1541. beam=instance_create(x+objSword.xoff,y+objSword.yoff,objSwordBeam);
  1542. //Give the beam the same sprite as the sword.
  1543. beam.sprite_index=objSword.sprite_index;
  1544. //The beam should travel in the direction Link is facing.
  1545. beam.dir=dir;
  1546. //Play the sword beam sound effect.
  1547. sound_play(sndSwordBeam);
  1548. }
  1549.  
  1550. slashing=false; //Unflag him as slashing.
  1551.  
  1552. /*
  1553. If the player is still holding the sword button, flag Link
  1554. as charging.
  1555. */
  1556. if (scr_held_button_chk("sword"))
  1557. {
  1558. charge=1;
  1559. }
  1560. else{
  1561. //Otherwise delete the sword.
  1562. if instance_exists(objSword)
  1563. {
  1564. with objSword
  1565. {
  1566. instance_destroy();
  1567. }
  1568. }
  1569. }
  1570. image_index=0; //Reset his animation frame.
  1571. scr_link_sprite_change(); //Finally, have Link update his sprite.
  1572. }
  1573. else if (jumping)
  1574. {
  1575. //If Link was jumping...
  1576. image_index=7; //Stay on the final frame.
  1577. }
  1578. else if (rolling)
  1579. {
  1580. //If Link was rolling...
  1581. rolling=false; //He's not now.
  1582. image_index=0; //Reset his animation frame.
  1583. scr_link_sprite_change(); //Finally, have Link update his sprite.
  1584. }
  1585.  
  1586. Draw Event:
  1587.  
  1588. execute code:
  1589.  
  1590. /*
  1591. Temporary variables for having drawn the shield or not, and Link's
  1592. current frame of animation.
  1593. */
  1594. var; drewshield=false; img=floor(image_index);
  1595.  
  1596. /*
  1597. Draw the shadow below Link's sprite, 1 pixel further down, if he's
  1598. not in a sideview area.
  1599. */
  1600. if (!global.sideview)
  1601. {
  1602. draw_sprite_ext(sprShadow,-1,round(x),round(y)+1,image_xscale,image_yscale,image_angle,image_blend,image_alpha-.125);
  1603. }
  1604.  
  1605. /*
  1606. If Link isn't defending, the shield should be drawn under him
  1607. only if he's facing left. Otherwise, it should be under him if he's
  1608. facing Left, Up or Right.
  1609. */
  1610. if (holding!=1 && ((!defend && ((dir=='L') || (dir=='D' && img>=1 && img<=3) || (dir=='U' && img>=5 && img<=7))) || (defend && dir!='D')))
  1611. {
  1612. //Draw the shield sprite.
  1613. draw_sprite_ext(shieldspr,-1,round(x)+xoff,round(y)+yoff+z,image_xscale,image_yscale,image_angle,image_blend,image_alpha);
  1614. drewshield=true; //Flag as having already drawn the shield.
  1615. }
  1616.  
  1617. //Draw Link's sprite.
  1618. draw_sprite_ext(sprite_index,-1,round(x)+xoff,round(y)+yoff+z,image_xscale,image_yscale,image_angle,image_blend,image_alpha);
  1619.  
  1620. //If the shield hasn't been drawn yet...
  1621. if (!drewshield)
  1622. {
  1623. //Draw the shield sprite.
  1624. draw_sprite_ext(shieldspr,-1,round(x)+xoff,round(y)+yoff+z,image_xscale,image_yscale,image_angle,image_blend,image_alpha);
  1625. }
  1626.  
  1627. //If Link is digging, he needs to draw his shovel item sprite above him.
  1628. if (digging)
  1629. {
  1630. var; shovelspr=sprInvis;
  1631. script_execute('shovelspr=sprShovel'+string(global.shovel)+dir);
  1632.  
  1633. draw_sprite_ext(shovelspr,-1,round(x)+xoff,round(y)+yoff+z,image_xscale,image_yscale,image_angle,image_blend,image_alpha);
  1634. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement