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

#1 2012-07-27 20:30:28

Subsidel
New Scratcher
Registered: 2012-07-22
Posts: 35

Help with ship controls...

Hard for me to explain... here we go:

Does anyone have the blocks to move a spaceship forward (constantly at the speed) in the direction the ship is facing BUT the speed of the ship gets slightly faster the longer you hold the direction key (up to a certain max speed). 

So when i tap the forward key- the ships moves slightly (keeps moving at that speed)
but if i tap the key again- it will go slightly faster (and remain at the same speed) until a certain speed. Likewise if you hold the forward key down it will get faster until a certain speed or if you let go of the forward key...

If you can understand this then is it possible?

Offline

 

#2 2012-07-27 20:50:24

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Help with ship controls...

when gf clicked
set [speed v] to (0)
forever
if <key [right arrow v] pressed?>
turn cw (5) degrees
end
if <key [left arrow v] pressed?>
turn ccw (5) degrees
end
if <key [up arrow v] pressed?>
change [speed v] by (0.1) // bigger = faster
end
if <(speed) > (max speed)>
set [speed v] to (max speed)
end
move (speed) steps

Last edited by MoreGamesNow (2012-07-27 20:51:13)


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#3 2012-07-28 05:31:57

Subsidel
New Scratcher
Registered: 2012-07-22
Posts: 35

Re: Help with ship controls...

Hello

Keep gettin stuck on the movement of my ship heh. Is there any blocks that move the ship so when u hit the forward key/ backwards- you move in that direction constantly but you can still rotate left and right while the ship is still moving forward.

For instance while the ship is moving constantly in this direction: -->                                         I can turn left and right while moving the same direction: -->

Thanx  smile

Offline

 

#4 2012-07-28 06:04:31

daniel_j
Scratcher
Registered: 2012-05-22
Posts: 100+

Re: Help with ship controls...

Here is a script that may help you  wink
Just lock the sprite to avoid the ship going upside down!  smile


when gf clicked

forever  

if <key [right arrow v] pressed?> 

point in direction (90 v)

move (10) steps

end

if <key [left arrow v] pressed?> 

point in direction (-90 v)

move (10) steps

end

if <key [up arrow v] pressed?> 

point in direction (0 v)

move (10) steps

end

if <key [down arrow v] pressed?> 

point in direction (180 v)

move (10) steps

end

end


http://i50.tinypic.com/2dhgnsx.jpg

Offline

 

#5 2012-07-28 06:07:23

jontmy00
Scratcher
Registered: 2011-11-28
Posts: 1000+

Re: Help with ship controls...

daniel_j wrote:

Here is a script that may help you  wink
Just lock the sprite to avoid the ship going upside down!  smile


when gf clicked

forever  

if <key [right arrow v] pressed?> 

point in direction (90 v)

move (10) steps

end

if <key [left arrow v] pressed?> 

point in direction (-90 v)

move (10) steps

end

if <key [up arrow v] pressed?> 

point in direction (0 v)

move (10) steps

end

if <key [down arrow v] pressed?> 

point in direction (180 v)

move (10) steps

end

Fixed your forever loop.


FOR ALL THE NEWS ON UPDATES FOR SIMPLISTICRAFT, CLICK HERE.

Offline

 

#6 2012-07-28 06:08:57

daniel_j
Scratcher
Registered: 2012-05-22
Posts: 100+

Re: Help with ship controls...

Lol deerrr I forgot the end xD thanks  big_smile


http://i50.tinypic.com/2dhgnsx.jpg

Offline

 

#7 2012-07-28 06:33:21

Subsidel
New Scratcher
Registered: 2012-07-22
Posts: 35

Re: Help with ship controls...

Hmm i really appreciate the help  smile  and thanx but every time i press the foward key- i would like to move foward in the direction that the ship is pointing + it moves in that direction constantly but at the same time i can move my ship left and right.

Hard to explain so.... if my ship was pointing   <----   i hit the forward key and it will move slowly in that direction constantly (and at the same time i can still rotate without it affecting the direction that the ship is moving until i hit forward again- when it moves forward in that direction)

So hard to explain- but when i use (move [steps]) and repeat- it moves in the direction but when i turn right   or left- the movement of the ship is also changed to that direction.

Thanx for ur efforts- i know this ones complicated because ive tried in different ways...

If you still don't understand what i'm tryin to achieve- its ship movement exactly like this: http://scratch.mit.edu/projects/maayax/2692420but mayb its the background  thats moving and not the ship  yikes

Offline

 

#8 2012-07-28 06:35:35

daniel_j
Scratcher
Registered: 2012-05-22
Posts: 100+

Re: Help with ship controls...

Ok, give me a few minutes to figure out a script.


http://i50.tinypic.com/2dhgnsx.jpg

Offline

 

#9 2012-07-28 06:37:19

Subsidel
New Scratcher
Registered: 2012-07-22
Posts: 35

Re: Help with ship controls...

Sorry i meant like this video: http://www.scratch.mit.edu/ext/youtube/?v=_ucp8AoyM74&feature=relmfu    (the ships and the controls/ bombs is what im intending to make in a 1 vs 1 duel game on scratch)

Thanks for your efforts lol

Offline

 

#10 2012-07-28 06:39:50

daniel_j
Scratcher
Registered: 2012-05-22
Posts: 100+

Re: Help with ship controls...

Is this what you mean?
make a variable direction


when gf clicked

forever  

if <key [up arrow v] pressed?> 

point in direction (direction)

move (10) steps

end

if <key [left arrow v] pressed?> 

turn cw (15) degrees

set [direction v] to (direction)

end

if <key [right arrow v] pressed?> 

turn ccw (15) degrees

set [direction v] to (direction)

end

end


http://i50.tinypic.com/2dhgnsx.jpg

Offline

 

#11 2012-07-28 06:41:41

daniel_j
Scratcher
Registered: 2012-05-22
Posts: 100+

Re: Help with ship controls...

Ohhhhh.. I get what you mean.
What you need is a script that uses velocity and a heap of variables  smile
I'll take a look now.


http://i50.tinypic.com/2dhgnsx.jpg

Offline

 

#12 2012-07-28 06:41:50

Subsidel
New Scratcher
Registered: 2012-07-22
Posts: 35

Re: Help with ship controls...

I'll test it and see what happens lol

Offline

 

#13 2012-07-28 06:43:02

daniel_j
Scratcher
Registered: 2012-05-22
Posts: 100+

Re: Help with ship controls...

Ok, i'll do it now  smile


http://i50.tinypic.com/2dhgnsx.jpg

Offline

 

#14 2012-07-28 06:45:20

daniel_j
Scratcher
Registered: 2012-05-22
Posts: 100+

Re: Help with ship controls...

Aghhh.. what you need is very complicated because if your turn (15) degress it will move towards were you are pointing...
Ill keep trying.


http://i50.tinypic.com/2dhgnsx.jpg

Offline

 

#15 2012-07-28 06:45:26

Subsidel
New Scratcher
Registered: 2012-07-22
Posts: 35

Re: Help with ship controls...

ok hehe i'll wait... really appreciate it lol... i'm just staring at my screen with a headache about figuring it out. Thought i could recreate that ship based on that video i showed u but turns out its taking forever... i've made the bomb bounce once and explode but its the ship control is one of the major problems lol

Gonna try and make it player 1 vs player 2... then have different arenas to pick from... want me to publish what ive done so far so u can see where im coming from?

Offline

 

#16 2012-07-28 06:49:04

Subsidel
New Scratcher
Registered: 2012-07-22
Posts: 35

Re: Help with ship controls...

The turning of the ship is fine at the setting of: When clicked- forever if key Left is pressed - turn <- 5 degrees and right -> degrees...

Its just the forward and backwards bit... just getting it to glide when i hit the forwards or backwards key but can still rotate left and right at the same time

Offline

 

#17 2012-07-28 06:49:21

daniel_j
Scratcher
Registered: 2012-05-22
Posts: 100+

Re: Help with ship controls...

Yeah, if you can publish it, I can edit your script directly so I can put it in for you, it would make it easier for me  smile
I'm happy to help till it is done  big_smile


http://i50.tinypic.com/2dhgnsx.jpg

Offline

 

#18 2012-07-28 06:50:28

daniel_j
Scratcher
Registered: 2012-05-22
Posts: 100+

Re: Help with ship controls...

Subsidel wrote:

The turning of the ship is fine at the setting of: When clicked- forever if key Left is pressed - turn <- 5 degrees and right -> degrees...

Its just the forward and backwards bit... just getting it to glide when i hit the forwards or backwards key but can still rotate left and right at the same time

Do you want the ship to move the direction you are pointing?


http://i50.tinypic.com/2dhgnsx.jpg

Offline

 

#19 2012-07-28 06:57:20

Subsidel
New Scratcher
Registered: 2012-07-22
Posts: 35

Re: Help with ship controls...

I'm just tidying it up slightly... i had far too many random bits everywhere
5 mins i think

Offline

 

#20 2012-07-28 06:59:05

daniel_j
Scratcher
Registered: 2012-05-22
Posts: 100+

Re: Help with ship controls...

ok mate  big_smile  I'll see what I can do when you put it on  smile


http://i50.tinypic.com/2dhgnsx.jpg

Offline

 

#21 2012-07-28 07:10:49

Subsidel
New Scratcher
Registered: 2012-07-22
Posts: 35

Re: Help with ship controls...

Ok here it is  tongue   http://scratch.mit.edu/projects/Subsidel/2700928

1) Yeh i want the ship to glide only forwards or backwards (so u can still rotate while the ship is moving in 1 direction- until u hit the forward or backwards key again where u will glide in the new direction)..... the rotate keys is ok as it is

2) Once its done...If this is possible- i'll try and figure out how to add speed gradually to the ship so the longer you press the forward or backwards key the faster the ship moves in that direction until a set speed lol. (so complicated lol)

Offline

 

#22 2012-07-28 07:13:22

daniel_j
Scratcher
Registered: 2012-05-22
Posts: 100+

Re: Help with ship controls...

Ok. i'm looking at the script now.
as for gradually gaining speed, when it comes to it I can help with that too  big_smile
I cleaned up the script abittoo.
I'll figure it out now  smile


http://i50.tinypic.com/2dhgnsx.jpg

Offline

 

#23 2012-07-28 07:25:01

Subsidel
New Scratcher
Registered: 2012-07-22
Posts: 35

Re: Help with ship controls...

Well i actually thought i was gettin close to sorting the controls out- with a massive script i made the ship constantly move forward + gets slightly faster the longer i held the forward key up until a set max speed but every turn would make the ship move in that direction  sad .

Basically you point in a direction- hit forward/ backwards key: u move in that direction but if u let go of the forward key- u keep moving at the same speed and u can rotate + the ship will still remain moving in same direction until u point in a new direction and hit the forwards key..

so complicated to explain but simple in my head.

Offline

 

#24 2012-07-28 07:28:31

daniel_j
Scratcher
Registered: 2012-05-22
Posts: 100+

Re: Help with ship controls...

Yeah, I fully understand what you need. It is just getting the sprite not to move in the direction it is pointing, as scratch is made that way.
it may take a while xD


http://i50.tinypic.com/2dhgnsx.jpg

Offline

 

#25 2012-07-28 07:53:12

daniel_j
Scratcher
Registered: 2012-05-22
Posts: 100+

Re: Help with ship controls...

while you wait, check out my projects, some may help you with scripts  big_smile 
(still trying scripts )


http://i50.tinypic.com/2dhgnsx.jpg

Offline

 

Board footer