Advertisement
Guest User

Stalk Godalming

a guest
Oct 24th, 2014
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.43 KB | None | 0 0
  1. /*This assumes the following
  2.  
  3. the following insert files are included
  4.  
  5. #include <dracView.h>
  6. #include <gameView.h>
  7. #include <map.h>
  8. */
  9.  
  10. //The objective of this function is to find a space for godalming to move into.
  11. //I'm going to assume here that the map has already been created in the main function
  12. //And that I can call it here.
  13.  
  14. //This function returns the next possible location. If the next location doesn't work, -1
  15. // will be returned
  16.  
  17. // int shortestPath(Map g, Location start, Location end, Location path[], Transport trans[], int rail) will be used
  18.  
  19. Location stalkGodalming(DracView currentView, Map g){
  20.     //Finds where Dracula and lord godalming is going to be
  21.     Location dracula = whereIs(currentView, PLAYER_DRACULA);
  22.     Location hunter1 = whereIs(currentView, PLAYER_LORD_GODALMING);
  23.    
  24.     //Sets variables so you can use shortest Path
  25.     Location path[50];
  26.     Transport trans[50];
  27.     int pathLength;
  28.    
  29.     //Finds the shortestPath between Dracula and Godalming
  30.     pathLength = shortestPath(g, dracula, hunter1, path, trans, 0);
  31.    
  32.     //Checks if pathLength is greater than 1, that is if Lord_Godalming isn't sitting
  33.     //on Dracula
  34.     if(pathLength >= 1){
  35.         location nextMove = path[1];
  36.     } else {
  37.         return -1;
  38.     }
  39.    
  40.     //Checks nextMove to see if its in the trail
  41.     for(i = 0; i <= 5; i++){
  42.         if (nextMove == currentView -> trailLocs[i]) return -1;
  43.     }
  44.    
  45.     //Next move is an accurate move, so we can use that now
  46.     return nextMove;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement