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

#1 2012-09-20 13:37:07

Matticus
New Scratcher
Registered: 2012-09-20
Posts: 4

A little help with my project please?

I'm currently making a version of the classic game Asteroids! For anyone who hasn't heard of it, its a game where you are a space ship shooting asteroids that come at you. I want to have the player able to navigate by means of using the mouse to select a direction and have you able to move smoothly (if possible) in the direction using the arrow keys. However, I cant seem to write a script to do this. Any help?

Offline

 

#2 2012-09-20 13:49:25

Averydan
New Scratcher
Registered: 2012-09-03
Posts: 8

Re: A little help with my project please?

So, like, the ship points at the mouse, but only moves if you press the arrow key?  Or do you mean the user can chose to control it with mouse or arrow keys?

Offline

 

#3 2012-09-20 14:04:51

mmww
Scratcher
Registered: 2010-01-14
Posts: 500+

Re: A little help with my project please?

if you use arrow keys there are multiple ways of programming this. One way: Use the when key ___ pressed block then under it a change X by ___ it could work. But to make it smooth use a forever loop. Inside it have an [if key right arrow pressed] and then an if with [if key left arrow pressed]. Then use change X axis by ___


http://i.imgur.com/AWFFO.pnghttp://www.weebly.com/uploads/1/0/1/4/10146167/4363061_orig.png Save the cheese!
I am http://blocks.scratchr.org/API.php?action=onlineStatus&user=mmww

Offline

 

#4 2012-09-20 14:22:38

Matticus
New Scratcher
Registered: 2012-09-20
Posts: 4

Re: A little help with my project please?

Averydan, Yeah thats it. So by moving the mouse, the ship remains stationary and by using the arrow keys to move the ship's position on the stage.

Offline

 

#5 2012-09-20 14:42:11

Matticus
New Scratcher
Registered: 2012-09-20
Posts: 4

Re: A little help with my project please?

mmww, thank you for the suggestion. I have tried it and find the ship unable to stop moving in that direction. The get somewhat stuck and after all of the directions are pressed, it doesn't move at all.

Offline

 

#6 2012-09-20 15:26:02

Averydan
New Scratcher
Registered: 2012-09-03
Posts: 8

Re: A little help with my project please?

Offline

 

#7 2012-09-20 16:10:13

Matticus
New Scratcher
Registered: 2012-09-20
Posts: 4

Re: A little help with my project please?

Averydan, yeah thats more or less what I mean. How did you do that?

Offline

 

#8 2012-09-20 20:13:39

Averydan
New Scratcher
Registered: 2012-09-03
Posts: 8

Re: A little help with my project please?

Just click this.  And you will get the scripts.

Glad I could help! Let me know if you need anything else!  smile

Offline

 

Board footer