Finalizing the Code
I will close this up and add some more functionality.
And, as I said, we’ll continue to add these at the start of layouts just because it categorizes all of the IDs here.
So, we will add another For Each Room parameter for the System condition.
For Each Room, we will add the Border.
Then set the Border size to 2×2.
We want the Border to be big. So then we will go to Room and spawn another object: the Border.
We will go to the Border and set the size to Room.Width + 150 and Room.Height + 150.
And then we’re going to do the same thing but replace the Room with the Hallway.
And instead of Room.Width, Room.Height, it’s going to be Hallway.Width, Hallway.Height.
So that will set the Borders there. Then we’ll add more Systems at the start of the layout.
So here we’re going to add some conditions. If a Room is overlapping another object: the Wall.
So if the Room overlaps the Wall, we will destroy the Wall.
So all that does will remove the Walls. Pretty simple stuff right now. Another sub-condition we can copy and paste here.
So we replace the Room with the Hallway.
So get the Hallway, and we’ll get just through the Wall. We will create a whole bunch of these Walls, and then we’ll only destroy the Walls. That’s overlapping the Room. And we’ve got that in the sub-condition. If the Wall overlaps the Border.
We’ll need to add an instance variable and name it the borderWall; type: Boolean.
If it’s overlapping, we’ll go to the Wall and toggle boolean; we’ll toggle the borderWall.
And lastly, we add another sub-condition.
Then we’ll go to the Wall and destroy.
But lastly, we have to invert that.
So if the Wall is not a borderWall, we’ll destroy it. We’re slowly getting there, even though things are working out if you run this here.
Not entirely, though. There are a lot of other things that we need to do first. So let’s go ahead and go to System and at the start of the layout.
We’ll add another condition at the start of the layout.
We’ll go to the Border and destroy the RoomCenter.
And again, so with Construct 3, everything is very visually dependent. And that’s why we have to create these Sprites in another programming language; you could almost do this abstractly. So for now, we’ll keep that here, and there’s more than we need to do. So we’ll add another sub-condition: the System and For Each the RoomCenter.
We’ll go to the RoomCenter and spawn another object, and that object, of course, will be the Coin.
Pretty simple stuff. And we’ll add another sub-condition: the Room.
Compare the instance variable if the ID is equal to one.
So whatever the first Room will get spawned, we’re going to go to the Player and set position to Room.X and Room.Y.
And the reason why we’ll do that is that we want to offset it. So you can do that as you want there. And then, lastly, there’s one other item here.
We’ll have a System, and then we’ll repeat eight times.
And then, we’ll go to the System and pick a random instance of the Hallway.
We don’t use the System here, but the Hallway will spawn another object: the Enemy.
It will spawn the other Enemy and see you in the following story.