Question
Convert the following java based code to C code: private function hCorridor(x1:Int, x2:Int, y) { for (x in Std.int(Math.min(x1, x2))...Std.int(Math.max(x1, x2)) + 1) { //
Convert the following java based code to C code:
private function hCorridor(x1:Int, x2:Int, y) {
for (x in Std.int(Math.min(x1, x2))...Std.int(Math.max(x1, x2)) + 1) {
// destory the tiles to "carve" out corridor
map[x][y].parent.removeChild(map[x][y]);
// place a new unblocked tile
map[x][y] = new Tile(Tile.DARK_GROUND, false, false);
// add tile as a new game object
addChild(map[x][y]);
// set the location of the tile appropriately
map[x][y].setLoc(x, y);
}
}
// create vertical corridor to connect rooms
private function vCorridor(y1:Int, y2:Int, x) {
for (y in Std.int(Math.min(y1, y2))...Std.int(Math.max(y1, y2)) + 1) {
// destroy the tiles to "carve" out corridor
map[x][y].parent.removeChild(map[x][y]);
// place a new unblocked tile
map[x][y] = new Tile(Tile.DARK_GROUND, false, false);
// add tile as a new game object
addChild(map[x][y]);
// set the location of the tile appropriately
map[x][y].setLoc(x, y);
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started