Jump to content


Photo

Evil Clutches: How Do I Keep The Dragon On Screen


  • Please log in to reply
27 replies to this topic

#21 johnnyLikesGames

johnnyLikesGames

    GMC Member

  • New Member
  • 18 posts

Posted 15 April 2008 - 11:49 AM

Try adding the step event -> begin step

Add the check for variable for y < 0

then set move fixed to the middle and a speed of 0

Kirb


I guess I'll have to wait until I'm further in the book because I can't make it work with:

up event, if y > 0 then move up
down event, if y< room_height then move down

That should be if the dragon is greater than the top left, which is zero, then I should be able to move him up. When I hit zero I should no longer be able to move him up. When I hit the room_height, or the bottom left, I should not be able to hit down any more. I can continue to do both, so I don' t know. Since the origin is the top left of the sprite I should at least get the up event to work. Oh well.
  • 0

#22 RoboBOT

RoboBOT

    GMC Member

  • Validating
  • 592 posts

Posted 15 April 2008 - 09:57 PM

Here's an idea: Are you setting the speed of the dragon object when you move (rather than just changing its position manually)? If so, you'll need to set the speed to 0:
:( IF variable: y value: 0 greater than
:D set the speed and the direction (up)
:P ELSE
:D set the speed to 0 (direction doesn't matter)

#23 johnnyLikesGames

johnnyLikesGames

    GMC Member

  • New Member
  • 18 posts

Posted 15 April 2008 - 09:57 PM

Try adding the step event -> begin step

Add the check for variable for y < 0

then set move fixed to the middle and a speed of 0

Kirb


I guess I'll have to wait until I'm further in the book because I can't make it work with:

up event, if y > 0 then move up
down event, if y< room_height then move down

That should be if the dragon is greater than the top left, which is zero, then I should be able to move him up. When I hit zero I should no longer be able to move him up. When I hit the room_height, or the bottom left, I should not be able to hit down any more. I can continue to do both, so I don' t know. Since the origin is the top left of the sprite I should at least get the up event to work. Oh well.


What I found is that if the object_dragon.y is on the intersection of the room at 0, then I cannot move up. However, it is set to greater than instead of equal to. In other words, push the up arrow. The object_dragon goes up. If I stop the object_dragon on the y of zero, release the up key, press it down again, I cannot move.

If I press up and hold it down I will continue to move off the screen into negative numbers.

I have <up> event. var action, variable y, value 0, operation larger than. Is this not right? If I am larger then zero, that is on the screen, below the top, which is zero, then I can continue up the screen. Is it a bug? Anyone have the evil clutches game that could look at it? Thanks.
  • 0

#24 RoboBOT

RoboBOT

    GMC Member

  • Validating
  • 592 posts

Posted 15 April 2008 - 10:07 PM

Hmm, I don't really see what's going on. Perhaps when setting your speed to 0 (as I said in my previous post) also set x to xprevious and y to yprevious (that will move it back to the previous step, where it was still on-screen). You'll need blocks:

...(like before)...
:D
:D
:GM073: set speed to 0
:( set x to "xprevious" and y to "yprevious"
:P

#25 johnnyLikesGames

johnnyLikesGames

    GMC Member

  • New Member
  • 18 posts

Posted 15 April 2008 - 10:53 PM

Hmm, I don't really see what's going on. Perhaps when setting your speed to 0 (as I said in my previous post) also set x to xprevious and y to yprevious (that will move it back to the previous step, where it was still on-screen). You'll need blocks:

...(like before)...
:D
:D
:GM073: set speed to 0
:( set x to "xprevious" and y to "yprevious"
:P


I'm not sure it's that complex. I think I know why, but not sure how to fix it. It is the type of event that is the problem. If I move the object_dragon to the top and then let off the key (arrow up), then press up again, it will not go up. But, if I hold the key press, the arrow up, and do not let off of it, no depress, it will continue past the top, or zero, 0. The reason I believe is because the iteration of movement only tests for the first keypress. So, if I start at the bottom and press the up key it only asks once, Are you at 0 yet? No, okay, move up. And that's the last time it asks until I release the up arrow key. If I stop press the up arrow at 0, and then press it again, I will not move up and stay on the screen because the event was triggered again and the if statement was executed. In other words, each movement up does not really cause the entire event to fire. I'm not sure if that is counterintuitive or not, so I'll wait until I learn the program some more. But, the assumption was that every single movement up the screen would also cause both actions within the event to occur. That is not true.
  • 0

#26 johnnyLikesGames

johnnyLikesGames

    GMC Member

  • New Member
  • 18 posts

Posted 15 April 2008 - 11:08 PM

What I ended up doing was adding an Intersect Boundary event to my object_dragon to Reverse Vertical. I will have to adjust my origin for the bottom, but it keeps me on the screen. The other I'm still not sure is a bug or by design. Just not what I expected. Thanks.
  • 0

#27 RoboBOT

RoboBOT

    GMC Member

  • Validating
  • 592 posts

Posted 15 April 2008 - 11:16 PM

Oh, yeah that makes sense. I should have thought of that. Sorry, I wasn't terribly helpful! :(
You're right, the key press event only happens during the step in which the key was pressed (so it would happen once). If you changed it to the regular keyboard event, it should work.

#28 tkirby2003

tkirby2003

    GMC Member

  • New Member
  • 2 posts

Posted 15 April 2008 - 11:42 PM

What happens is the check for the y position only happens at the time you press up. This is why if you press up at precisely y= 0 it stops. The book will address this in later chapters.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users