Hello!

Here’s the solution to making your maze walls solid – sorry I couldn’t solve it while you were here!

First find your “obj_wall” in the objects section of the asset browser (on the right of the screen and double click it to open it’s properties

You should hopefully now see something like this:

Click on the “Solid” box so it has a tick.

Next find “obj_player” in the asset browser and open it, you should see this:

Click on “Add Event” and select Collision\Objects\obj_wall

This should add a new event to the list. Oddly you don’t need to put any code in it, but the “Solid” tick box in the obj_wall only works if the other object has a collision event for it. That’s the bit I couldn’t remember earlier as we normally do a different system for collisions and I’ve not used it for ages! Anyway it should look roughly like this:

Since I can’t remember how I left the movement code on your version we may as make sure the game runs okay and that walls are solid, so click the run button. If it runs and you can’t run through walls hooray, now you can place walls to make up the maze bits if you want.

If it doesn’t run or the controls don’t work correctly you can replace the code in the “Create” and “Step events with the code below, which should work fine.

First delete anything in the “create” event (in obj_player) and paste this in:

h_speed = 8
v_speed = 8
bang = false
death_timer = 120

It should hopefully now look like the picture above, except that it won’t have “bang = false” at the bottom as well as in on the third line as I’ve just noticed I put it in twice for no good reason at all. Thinking about it the obj_landmine might not be on yours either as I think we added those after last week.

Next delete anything in the “step” event (in obj_player) and copy and paste this in:

if keyboard_check(vk_right)
{
x = (x + h_speed);
}

if keyboard_check(vk_left)
{
x = (x – h_speed);
}

if keyboard_check(vk_up)
{
y = (y – v_speed);
}

if keyboard_check(vk_down)
{
y = (y + v_speed);
}

x = clamp(x,0, room_width);

y= clamp(y,0,room_height);

It should look like this.

So that should be all you need to do to make it work properly. Bear in mind the Nepal flag won’t be stopped by the walls unless you give it a collision event like we did for obj_player, so that will be fun! If you do make it so Nepal can’t go through walls (by adding a collision event with obj_wall) it’ll probably get stuck quite a lot as it just moves directly towards you and has no instructions for how to avoid walls. I do have some code for that already which we can look at next week if you’d like to.