Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // initialize random number generator, C++ specific stuff
- random_device rd;
- mt19937 gen(rd());
- uniform_int_distribution<> genTree(-3, 3); // for displacing trees
- uniform_int_distribution<> genTile(1, 8); // for random tiles in the center
- // load the Rocky Roadz template
- ifstream in("QuestzTemplate1.wwd", ios::binary);
- Document document(in);
- // clean up the plane
- Plane& plane = document.getPlane(0);
- plane.getObjects().clear();
- plane.setDimensions(40, 40);
- // fill in tiles and trees
- for(int x=0; x<40; ++x)
- for(int y=0; y<40; ++y)
- if(x > 10 && x < 30 && y > 10 && y < 30)
- plane.setTile(x, y, genTile(gen)); // random tile 1-8
- else
- {
- plane.setTile(x, y, 199);
- // add a tree
- int treeX = plane.getTilesWidth()*x + 19 + genTree(gen);
- int treeY = plane.getTilesHeight()*y - 5 + genTree(gen);
- Object tree;
- tree.setImageSet("LEVEL_TREE1");
- tree.setLogic("EyeCandy");
- tree.setLocation(treeX, treeY, 0, -1);
- // random mirror effect
- if(genTile(gen) > 4)
- tree.setFlag(Object::FlagDraw::MIRROR, true);
- plane.addObject(move(tree));
- }
- // add a gauntletz Grunt in the middle
- Object grunt;
- grunt.setImageSet("GAME_WAPWORLDONLY_TRIGGER");
- grunt.setLogic("GruntStartingPoint");
- grunt.setLocation(700, 700, 0, -1);
- grunt.setPowerup(5);
- plane.addObject(move(grunt));
- // save the level
- ofstream out("Sandbox.wwd", ios::binary);
- document.save(out);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement