ZoriaRPG

Minecar Template

Jan 16th, 2018
131
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //needed vars (array indices)
  2. //int carframe -- a 60 frame timer.
  3.  
  4. //These are based on LINK's X, Y, and DIR; so we do not store them separately.
  5. //cardir, x, y,
  6.  
  7. //needed constants
  8.  
  9. //Link Misc[]
  10. const int LINK_MISC_ENGINEFLAGS
  11. const int LM_MINECAR = 0x10;
  12.  
  13. void SetMinecarMode(bool enable)
  14. {
  15.     if ( enable ) Link->Misc[LINK_MISC_ENGINEFLAGS] |= LM_MINECAR;
  16.     else Link->Misc[LINK_MISC_ENGINEFLAGS] &= ~LM_MINECAR;
  17. }
  18.  
  19. bool LinkInMinecar(){ return (Link->Misc[LINK_MISC_ENGINEFLAGS]&LM_MINECAR);}
  20.  
  21. //flags for track, branch, dock --can use raft types for these,
  22.     //and they should be on layer 1 so that they can
  23.     //be permanantly changed
  24. const int FLAG_MINECAR_DOCK
  25. const int FLAG_MINECAR_PATH
  26. const int FLAG_MINECAR_BRANCH
  27.  
  28. //tiles
  29. const int TILE_MINECAR_EMPTY_UP
  30. const int TILE_MINECAR_EMPTY_DOWN
  31. const int TILE_MINECAR_EMPTY_LEFT
  32. const int TILE_MINECAR_EMPTY_RIGHT
  33. const int TILE_MINECAR_LINK_UP
  34. const int TILE_MINECAR_LINK_DOWN
  35. const int TILE_MINECAR_LINK_LEFT
  36. const int TILE_MINECAR_LINK_RIGHT
  37.  
  38. //sounds
  39. const int SFX_MINECAR_TRACK
  40. const int SFX_MINECAR_STOP
  41.  
  42. //layers
  43. const int LAYER_MINECAR_FLAGS
  44. const int LAYER_MINECAR_DRAWS
  45.  
  46. //combos for diretional changes
  47. const int CMB_MINECAR_CHANGEDIR_UP
  48. const int CMB_MINECAR_CHANGEDIR_DOWN
  49. const int CMB_MINECAR_CHANGEDIR_LEFT
  50. const int CMB_MINECAR_CHANGEDIR_RIGHT
  51.  
  52. //function to read branching paths -- read the current combo position, and if it is a branch type
  53.     //!  check AdjacentCombo UDLR to see which branches are legal.
  54.  
  55. int IsMineCarBranch(){}
  56. int IsMinecarUpBranch(){}
  57. int IsMinecarDownBranch(){}
  58. int IsMinecarLeftBranch(){}
  59. int IsMinecarRightBranch(){}
  60.  
  61. //Sources
  62. //  Add invisibility and invincibility sources from the minecar
  63. //  to the global function that fetermines of Link is invinciblwe, or not drawn.
  64.  
  65. //GLOBAL CONDITIONS
  66. //if there is a minecar flag on the screen
  67.     //draw empty minecar tile to screen over its flag
  68.     //if Link is over the minecar
  69.         //if link presses a
  70.             //put Link in minecar mode, setting a flag in Link->Misc[]
  71.                 //whenever that flag is true, we make Link invisible, and draw a minecar at
  72.                 //his position, based on his direction and coordinates, om the DRAW layer
  73.            
  74.             //change the car flag on layer 1 to car_inuse so that it doesn't respawn
  75.             //decrement carframe counter unless it is 0
  76.             //if it is 0, reset it
  77.             //make link invisible --set the global source, **NOT** direct writes to Link->Invisible
  78.             //make link invincible --set the global source, **NOT** direct writes to Link->CollDetection
  79.             //draw tile of minecar holding Link to Link's x/y
  80.             //draw other minecars on the screen based on screen flags that show a landed car at a dock
  81.                 //! We know which these are, because they are not at Link's position.
  82.                 //! Link riding a minecar clears the screen flag on layer 1 that causes an empty
  83.                 //! car to be drawn; so these are only drawn to docked cars and we draw Link inside
  84.                 //! a monecar when LinkInMinecar() evaluates true.
  85.            
  86.            
  87.             //move minecar along track
  88.                 //! We do this by moving Link, rather than the car. The car is always drawn to Links position
  89.                 // based on his direction.
  90.             //if there is an intersection
  91.                 //if Link is holding a directional button
  92.                     //change the track
  93.        
  94.         //if we are in minecar mode, and moving
  95.             //determine car direction
  96.                 //! Read for combos that change the direction here
  97.             //update tile based on dir
  98.    
  99.             //follow track based on flags
  100.             //if we are changing tracks, do that now
  101.             //otherwise, follow the track until we reach an end pad flag
  102.                 //based on dir and carframe timer for movement
  103.        
  104.             //play the track noise every n frames based on carframe
  105.        
  106.            
  107.             //minecar stops moving
  108.             //minecar mode ends
  109.            
  110.             //if the car is over a landing pad, hop Link out of the car
  111.             //UNSET link invisible --unset the global source, **NOT** direct writes to Link->Invisible
  112.             //UNSET link invincible --unset the global source, **NOT** direct writes to Link->CollDetection
  113.            
  114.             //make a minecar flag on layer 1 of the screen where it stops
  115.                 //so that it remains there until we reset it.
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×