SHARE
TWEET

WWD level creation

Tomalla Jan 28th, 2019 97 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // initialize random number generator, C++ specific stuff
  2. random_device rd;
  3. mt19937 gen(rd());
  4. uniform_int_distribution<> genTree(-3, 3); // for displacing trees
  5. uniform_int_distribution<> genTile(1, 8); // for random tiles in the center
  6.  
  7. // load the Rocky Roadz template
  8. ifstream in("QuestzTemplate1.wwd", ios::binary);
  9. Document document(in);
  10.  
  11. // clean up the plane
  12. Plane& plane = document.getPlane(0);
  13. plane.getObjects().clear();
  14. plane.setDimensions(40, 40);
  15.    
  16. // fill in tiles and trees
  17. for(int x=0; x<40; ++x)
  18.     for(int y=0; y<40; ++y)
  19.         if(x > 10 && x < 30 && y > 10 && y < 30)
  20.             plane.setTile(x, y, genTile(gen)); // random tile 1-8
  21.         else
  22.         {
  23.             plane.setTile(x, y, 199);
  24.  
  25.             // add a tree
  26.             int treeX = plane.getTilesWidth()*x + 19 + genTree(gen);
  27.             int treeY = plane.getTilesHeight()*y - 5 + genTree(gen);
  28.  
  29.             Object tree;
  30.             tree.setImageSet("LEVEL_TREE1");
  31.             tree.setLogic("EyeCandy");
  32.             tree.setLocation(treeX, treeY, 0, -1);
  33.  
  34.             // random mirror effect
  35.             if(genTile(gen) > 4)
  36.                 tree.setFlag(Object::FlagDraw::MIRROR, true);
  37.  
  38.             plane.addObject(move(tree));
  39.         }
  40.  
  41. // add a gauntletz Grunt in the middle
  42. Object grunt;
  43. grunt.setImageSet("GAME_WAPWORLDONLY_TRIGGER");
  44. grunt.setLogic("GruntStartingPoint");
  45. grunt.setLocation(700, 700, 0, -1);
  46. grunt.setPowerup(5);
  47.  
  48. plane.addObject(move(grunt));
  49.  
  50. // save the level
  51. ofstream out("Sandbox.wwd", ios::binary);
  52. document.save(out);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top