This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-10-17 22:58:48

ACDash
New Scratcher
Registered: 2012-10-17
Posts: 4

I'm new to this. Making a Zelda esque game. Could use some help.

So yeah, I'm making this Zelda-like game and I'm currently trying to implement movement controls. I've gotten the basics down fairly well, but there's a couple of nuances that are really bugging me and I just can't figure them out.

Okay, first of all, I can move the main character in the four cardinal directions using a basic script.

when gf clicked
forever 
  if <Key Down Arrow Pressed>
    point in direction (180)
    move (3) steps
Simple enough and it works, the smooth movement is clearly better than just using the When Key Pressed control function.

However, I cannot for the life of me figure out how to keep button presses from overlapping. If say my character is moving down and I press the left button to move left he will move down and left. I just want him to move left and stop moving down. I've tried everything from implementing operators wherein if left button is pressed and not the up, down, or right buttons then he will move left but if you press those buttons he just stops.

Another thing that has been bugging me is I'm trying to figure out how to change the costume so that it imitates actual movement. I've got two movement sprites for each direction, and I'm trying to make it so it changes like every .5 seconds, but I'm not sure exactly how I would implement that either.

So yeah, any help would be very much appreciated. I hope I provided a detailed enough explanation of what exactly I'm trying to accomplish here.

Offline

 

#2 2012-10-18 01:08:32

CopperHawk
Scratcher
Registered: 2011-09-23
Posts: 100+

Re: I'm new to this. Making a Zelda esque game. Could use some help.

Put a "Repeat until NOT key down arrow pressed" around "Point in direction 180, move 3 steps. That way, it will only repeat down arrow, until a new key is pressed. Do the same for all keys.

   Hope that helps! smile


Copper Games is...  "ridiculously amazing!" -Nomolos    "Way too fun!"-Liamadams "awesome!" -Wes64       "Amazing!  big_smile " -JJROCKER

Offline

 

#3 2012-10-18 17:19:45

ACDash
New Scratcher
Registered: 2012-10-17
Posts: 4

Re: I'm new to this. Making a Zelda esque game. Could use some help.

CopperHawk wrote:

Put a "Repeat until NOT key down arrow pressed" around "Point in direction 180, move 3 steps. That way, it will only repeat down arrow, until a new key is pressed. Do the same for all keys.

   Hope that helps! smile

Thanks for the tip. It definitely makes the movement smoother, and although it stopped the overlapping it still doesn't allow you to push a different button while still holding the original direction button to change direction. The sprite would just stop...

But, that's a minor complaint. I would still like to be able to figure out how to change my characters costume change animations for movement. I think I'm going to try making a repeat forever loop inside of my other repeat forever loop.

Offline

 

#4 2012-10-18 18:38:21

ACDash
New Scratcher
Registered: 2012-10-17
Posts: 4

Re: I'm new to this. Making a Zelda esque game. Could use some help.

Alright, I figured it out! Here's what I did.

when gf clicked
forever
  if (key [down arrow] pressed)
    repeat until <not(key [down arrow] pressed)>
      point in direction [180]
      move (3) steps

when gf clicked
forever
  if (key [down arrow] pressed)
    repeat until <not(key [down arrow] pressed)>
      switch to costume [front1]
      wait (0.1) seconds
      switch to costume [front2]
      wait (0.1) seconds
I don't think my scratchblocks code is too great, but these separate threads should work wonders in scratch. Implementing this code with each arrow key allowed me to fully flesh out my movement animation for a top down action adventure game.

Needless to say I'm stoked. I should've figured out that the costume change interfered with the actual control function. It makes perfect sense now that I should've just used a separate script.

Anyway, I'll keep working on this and I'll update my progress as I go. Wish me luck.  smile

Offline

 

#5 2012-10-18 19:20:52

ACDash
New Scratcher
Registered: 2012-10-17
Posts: 4

Re: I'm new to this. Making a Zelda esque game. Could use some help.

Okay, my current predicament seems to be that my sprite's costume doesn't change fast enough. I think it might have to do with the wait .1 second loop, but I have no idea how to work around that.

Here, I'm going to post a link to my current project to show what I mean. When you press a button in any of the directions too quickly the sprite's costume just doesn't react quickly enough to the movement.

http://scratch.mit.edu/projects/ACDash/2844066

It doesn't look terrible, but it's definitely noticeable.

Offline

 

Board footer