#Help with tutorial code not working

1 messages · Page 1 of 1 (latest)

modest python
#

My kid was trying to work through the "Make Your First Platformer Game" tutorial on the GM website and it doesn't seem to be executing the scripts related to either the Create Event or Step Event. I've checked his work up to the point he's at and it's what the tutorial has said to do. I'm not very familiar with GM yet, but I did put some simple debug code in the scripts at one point and got nothing in the log. The scripts are super-short, so I'll just paste them both as plain text below . Any help would be appreciated. Thanks!

https://gamemaker.io/en/tutorials/your-first-platformer

/// @Create Event
// You can write your code in this editor
window_set_size(1280, 720);
xsp=0;
ysp=0;

/// @Step Event
// You can write your code in this editor
ysp += 0.1;
xsp = 0;

if keyboard_check(vk_left)
{
    xsp = -1;
}

if keyboard_check(vk_right)
{
    xsp = +1;
}

if place_meeting(x, y+1, oSolid)
{
ysp = 0;
if keyboard_check(vk_up)
{
ysp = -2;
}
}

move_and_collide(xsp, ysp, oSolid);

tiny flax
#

Did any sort of error message pop up or nothing happens in the game at all?

eternal quiver
#

it doesn't seem to be executing the scripts related to either the Create Event or Step Event
Make sure you've put the object in the room (and you are in the correct room in case you have more)

tiny flax
#

the code seems to be working fine so I think what Kleo said could be the case

modest python
#

The scripts are linked to the Create and Step events of a Player (oPlayer, I think) object. That's how the person doing the tutorial showed how to do it. An yes, or no.... The room itself comes up with all of the sprites showing (in its tiny form), but the events aren't bing triggered. The set_window_resize doesn't happen, and the virtual keys are unrecognized. And no, there were no errors in the output unless I intentionally introduced one by deleting a bracket.

eternal quiver
#

Sprites are not the same as objects (though objects can have sprites assigned to them) - they are just pictures and they have no code inside.

I haven't watched this tutorial, but it looks like this code belongs to players object. That object needs to be put in the room - the object, not players sprite. If it's Create Event doesn't run - it's not there, or you're not in the right room.

modest python
#

Makes perfect sense that that would cause this issue. I think he did that correctly, but I'm not positive, so I'm going to double check things again. Thank you! I'll let you know how that goes.

nova shuttle
#

4 minute mark shows how to put the object in the rooms.

modest python
#

I'll be back.... Thank you!

#

Okay. It looks like he did it correctly, assigning all of the sprites to objects. Is there a way to attach an image to a comment in here?

#

I hope this works....

eternal quiver
#

If you're on Windows - win+shift+s to make a screenshot and paste directly

modest python
#

Yeah. He has the nice Windows laptop. I have my old iMac. I'm just emailing things to myself from his computer.

eternal quiver
#

Ok, this looks fine
But is this object in the room?

modest python
#

Ahhhhh.... Okay BRB.

eternal quiver
#

Press on your room in Asset Browser on the right, and then drag the oPlayer from Asset Browser into the room area

modest python
#

I dragged oPlayer from Objects down to Rooms. I tried to drag it into "Room1", but it will only go into the Rooms folder, so I'm assuming that's normal. I pressed play and got the same result. No errors.

eternal quiver
#

Sorry, what I said could be misleading, I meant to drag it from Asset Browser into the room area - space on the left, not into room asset in the browser

modest python
#

And I just intentionally introduced an error and it bonked and displayed the error.

eternal quiver
modest python
#

Ahhhhhh! Just to clarify. You mean that when he created the room with all the sprites, he shoulf have used the objects, not the sprites? Or that I just need to drag the thing into some random spot in the room?

eternal quiver
#

Yeah!

modest python
#

Yeah to the former or the latter? LOL!

eternal quiver
#

Drag the objects, not the sprites (well, most probably, because they will be used for collisions I assume)

#

and sprites won't work for collisions

modest python
#

Okay! Makes perfect sense. Can't interact with a picture; can interact with an object. Time to recreate the kids room! I'm hoping this is where he went wrong.... I'll let you know how it goes. Thanks again!

modest python
#

Kleo. You are amazing and have the patience of a saint. That was exactly what he did and I didn't catch it because the room looked like the one in the video. Thank you so much! This may have just saved him from hating programming.

eternal quiver
#

haha, nice! 😄
Forgetting to put object in the room happens to everyone at some point 😄