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

#1 2008-05-19 18:39:09

viper650
Scratcher
Registered: 2008-04-04
Posts: 36

how to make your sprite move

Has anyone played the internet game fishy? Im making a game like that but i dont know how to make my sprites glide the way fishy does. when i press one of the arrow keys i want the main sprite to move in that direction like the main sprite in fishy does. Does anyone have a script that i can use?

Offline

 

#2 2008-05-19 18:42:04

Bluestribute
Scratcher
Registered: 2008-01-24
Posts: 1000+

Re: how to make your sprite move

[blocks]<when green flag clicked>[/blocks]
[blocks]<forever if><key[--> ]pressed?>[/blocks]
[blocks]<point in direction(90[/blocks]
[blocks]<move(10)steps>[/blocks]

You can modify that, but that's the basic moving thing. Or:
[blocks]<when green flag clicked>[/blocks]
[blocks]<forever if><key[--> ]pressed?>[/blocks]
[blocks]<change x by(10[/blocks]

I sometimes use the second one, IT's good sometiems

Last edited by Bluestribute (2008-05-19 18:42:30)


http://img247.imageshack.us/img247/1204/bluestributett4.jpg
That's my PSN ID. I know tons of COD4 glitches. Add me as your friend. Oh, and get a headset

Offline

 

#3 2008-05-19 19:02:27

Cyclone103
Scratcher
Registered: 2008-03-20
Posts: 500+

Re: how to make your sprite move

I have never heard of fishy, but Archmage has a very good shooting motion script: When green flag clicked forever repeat until touching edge change x by sine of direction times 15. For y, it is the same thing but cosine of direction instead of sine. You can have it activate however you want, and it will make smooth movement.

Last edited by Cyclone103 (2008-05-19 19:04:17)


All your base are belong to us

Offline

 

#4 2008-05-19 19:06:22

viper650
Scratcher
Registered: 2008-04-04
Posts: 36

Re: how to make your sprite move

Thanks, but im already using that script. just look up fishy in google search and u can find a "fish eat fish" game somewhere. The script i want will still leave your fish gliding to a stop when the key isnt pressed.

Offline

 

#5 2008-05-19 19:14:17

Cyclone103
Scratcher
Registered: 2008-03-20
Posts: 500+

Re: how to make your sprite move

hmmm. Is the length it moves gliding to a stop always the same or is it dependent on how far it has moved? if it is the same, just add a set number to the end of it. If it is dependent, just make a variable that changes by 1 every_____secs, and then just have it move that variable steps.


All your base are belong to us

Offline

 

#6 2008-05-19 19:14:19

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: how to make your sprite move

Try looking at the premade sprite called friction marble in the things section of the example sprites folder. Or you could just download other fishy projects.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#7 2008-05-19 19:33:47

viper650
Scratcher
Registered: 2008-04-04
Posts: 36

Re: how to make your sprite move

the marble racer helped with the gliding but it doesnt teach me how to stop when the key is released. but thanks anyway

Offline

 

#8 2008-05-19 21:29:55

Cyclone103
Scratcher
Registered: 2008-03-20
Posts: 500+

Re: how to make your sprite move

Just have it repeat until not (key_____pressed), which will tell it to move until you let go.


All your base are belong to us

Offline

 

#9 2008-05-20 07:35:39

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: how to make your sprite move

I have a 'moving a sprite' tutorial on my website...
http://www.scratchedu.webs.com/txt_guides/movingasprite.txt

Last edited by coolstuff (2008-05-20 07:36:34)

Offline

 

Board footer