This is a forum on how to make your characters move for a game. Let's get started.
Let's say you want the character to move with the arrow keys. That takes four scripts.
1. <when[ up arrow ]key pressed>
<point in direction( 0
<move( 10 )steps>
<stop script>
2. <when[ down arrow ]key pressed>
<point in direction( 180
<move( 10 )steps>
<stop script>
3. <when[ right arrow ]key pressed>
<point in direction( 90
<move( 10 )steps>
<stop script>
4. <when[ left arrow ]key pressed>
<point in direction( -90 or 270
<move( 10 )steps>
<stop script>
Notes: Your character doesn't have to move ten steps, that depends on how fast you want it to move. If you want your character to only move left and right, that will take only two scripts and you will have to take away the up arrow script and the down arrow script.
Let's say you don't want your character to move with the arrow keys, but follow the mouse. That is very simple to do. It takes a single script. Here's the script:
<when green flag clicked>
<forever>
<go to[ mouse-pointer
<end>
Now you know how to make characters move for your game! A game is not a game when you can't move the characters, right? Enjoy programming your game! I hope it will work well! Please read: In the projects you made with the help of this forum, please give me a bit of credit because you learned to do it here and please post a link, if you don't know how to link please go to my other forum called "How to link".
I hope you guys have learned something from this forum!
~ From me, Chatter
Offline
Looking for an alternate method?
Try this!
<when green flag clicked>
<forever>
<if><key[ rightarrow ]pressed?>
<change x by( positive number
<if><key[ leftarrow ]pressed?>
<change x by( negative number
<if><key[ uparrow ]pressed?>
<change y by( positive number
<if><key[ downarrow ]pressed?>
<change y by( negative number
Another method looks like this. It is similar to the second method Chatter posted, but it makes the characters follow the mouse rather than go to it.
<when green flag clicked>
<forever>
<point in direction( mouse pointer
<move( a number! )steps>
Last edited by shadow_7283 (2009-12-26 22:58:11)
Offline
To make it follow mouse when clicked...
<when green flag clicked>
<forever>
<wait until> <mouse down?>
<point towards( Mouse pointer
<move( positive number! )steps>
This is fun!
Offline
Well it is very good programming, but i want to start with something simple for new
Scratchers, like shorter scripts, if you understand. No offence, it's really good.
Offline
I don't know. These all contribute, and at some point or another they are going to want an alternative method of movement (in some areas, your's are kind of limited).
Offline
And Chatter, just pointing out to every newbie who wants to make a shooter game (like me ) :
Chatters moving method won't work for it, you'll want to use a move x/y positive/negative so you don't have to look where your going.
Seriously, try it, if your pointing at mouse, it makes movement jumpy (it keeps changing where its facing) and may shoot in the wrong direction.
Learnt that the hard way...
Offline
This one is for other games, not really shooting games. For help with those games, please go to another universe. I'm not into making those games. And also the thing shows you how it's going to rotate, you're supposed to click the 'Don't rotate' button.
~ Chatter
Offline
mm another way is to 'when right arrow key pressed, change x by 5' and 'when left arrow key pressed, change x by -5' etc. this can be easier and smoother.
Offline
MrMunchkin wrote:
mm another way is to 'when right arrow key pressed, change x by 5' and 'when left arrow key pressed, change x by -5' etc. this can be easier and smoother.
Let's just say there is a million possibilities.
Offline
I definitely think that all movement should be through the
<change x by(
<change y by(
<set x to(
<set y to(
It is good for practice in the future. I don't even know why the Scratch team included
the <move( -- )steps> block. When users become more advanced, they will find this block more and more difficult to work with.
Last edited by shadow_7283 (2009-12-27 22:42:54)
Offline
shadow_7283 wrote:
I definitely think that all movement should be through the
<change x by(
<change y by(
<set x to(
<set y to(
It is good for practice in the future. I don't even know why the Scratch team included
the <move( -- )steps> block. When users become more advanced, they will find this block more and more difficult to work with.
QFT.
Move steps is really annoying, and if you start off with a program thats getting a bit too advanced for a newbie; learning by using move steps will waste loads of time when you realise that a lot of stuff is smoother and easier with change x/y
Offline
one thing with the
<move( )steps>
[/blocks]
is that it can let you move in a non- standard direction(diagonal, for instance)
Last edited by itchyone (2009-12-29 20:47:53)
Offline
Hmmm, i guess so, but if theres a border you must keep your character in then move steps will let it escape.
Offline