Advertisement
ZoriaRPG

2.54 Lifting Objects Template

Feb 1st, 2018
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. ```cpp
  2. //scan combo next to link based on facing dir:
  3. int offsets[2]; //x,y
  4. combodata liftcombo; int facingcombo;
  5.  
  6. while(true)
  7. {
  8. if (Input->Press[CB_A])
  9. {
  10. if ( liftcombo == Null() )
  11. {
  12. switch(Link->Dir)
  13. {
  14. case DIR_UP: { offsets[0] = 8; offsets[1] = 8; break; }
  15. case DIR_LEFT: { offsets[0] = 8; offsets[1] = 8; break; }
  16. case DIR_UPRIGHT{ offsets[0] = 9; offsets[1] = 8; break; }
  17. case DIR_DOWN: { offsets[0] = 8; offsets[1] = 9; break; }
  18. default: { offsets[0] = 8; offsets[1] = 8; beak;}
  19. }
  20. facingcombo = AdjacentCombo(ComboAt(Link->X+offsets[0], Link->Y+offsets[1]), Link->Dir);
  21.  
  22. //compare for lift type
  23. if ( Screen->ComboT[facingcombo] == CT_LIFT )
  24. {
  25. liftcombo = Game->LoadComboData(ld);
  26. }
  27. else
  28. {
  29. liftcombo = Null();
  30. }
  31. }
  32. else
  33. {
  34. //pressing A while holding a combo
  35. //if we finished the animation
  36. if ( Link->Misc[LM_LIFT] >= min )
  37. {
  38. //throw the object
  39. Audio->PlaySound(SFX_THROW);
  40. spritedata throwsd = Game->LoadSpriteData(SPRITE_THROW);
  41. throwsd->Tile = liftcombo->Tile;
  42. throwsd->CSet = liftcombo->CSet;
  43. throwsd->AFrames = liftcombo->AFrames;
  44. throwsd->ASpeed = liftcombo->ASpeed;
  45. lweapon toss = Screen->CreateLWeapon(LW_TOSS);
  46. toss->UseSprite(SPRITE_THROW);
  47. toss->X = Link->X; //plus dir offsets
  48. toss->Y = Link->Y; //...
  49. toss->Dir = Link->Dir;
  50. //toss jump based on a lw->Misc[] index
  51. toss->Step = THROW_SPEED;
  52. liftcombo = Null();
  53. Link->Action = LA_THROW; //uses custom toss sprite
  54. }
  55. }
  56. }
  57.  
  58. //if not pressing A but holding a combo
  59. if ( liftcombo != Null() )
  60. {
  61. Audio->PlaySound(SFX_LIFT);
  62. ComboD[facingcombo] = 0;
  63. //do custom sprite animation with
  64. //for ( Link->Misc[LM_LIFT] = n ... )
  65. {
  66. // drawtile(3, liftcombo->Tile, LiftCombo->CSet ... )
  67. //use Link->Misc[] to store the lift frame
  68. }
  69. // if we've reached the end of the lift frames
  70. if ( Link->Misc[LM_LIFT >= m )
  71. {
  72. //until Link throws it, draw the tile over him
  73. }
  74. }
  75. Waitdraw(); Waitframe();
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement