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

#1 2013-03-14 18:11:27

GTM9
Scratcher
Registered: 2013-02-05
Posts: 10

Jetpack shoes

PLEASE HELP! I need my cyberguy to use his jet shoes to fly up but if he runs out of fuel he falls down. When helping please use scratchblocks, it makes it much easier!  smile

Offline

 

#2 2013-03-14 20:31:57

Liamadams
Scratcher
Registered: 2012-12-08
Posts: 100+

Re: Jetpack shoes

ooh, i don't know how to do that. Ask someone like r2dav2.


http://i39.tinypic.com/3309476.jpg

Offline

 

#3 2013-03-14 21:16:26

Harald
New Scratcher
Registered: 2013-03-05
Posts: 34

Re: Jetpack shoes

forever
if <<[Fly key v] pressed> And <(Fuel) > [0]>>
Change y by [1]
set (Flight v) to 1
else
set (Flight v) to 0
I hope this is what you were looking for. I assume you have some sort of gravity to make him fall down already set. Otherwise, just insert "Change y by -#" at else.
Below is a way for the fuel to be drained only when the guy is flying.


forever
if <(Flight) = [1]>
Change (Fuel) by -1
wait 0.1 secs

Offline

 

#4 2013-03-16 11:23:13

Liamadams
Scratcher
Registered: 2012-12-08
Posts: 100+

Re: Jetpack shoes

Harald wrote:

forever
if <<[Fly key v] pressed> And <(Fuel) > [0]>>
Change y by [1]
set (Flight v) to 1
else
set (Flight v) to 0
I hope this is what you were looking for. I assume you have some sort of gravity to make him fall down already set. Otherwise, just insert "Change y by -#" at else.
Below is a way for the fuel to be drained only when the guy is flying.


forever
if <(Flight) = [1]>
Change (Fuel) by -1
wait 0.1 secs

Lol, there is no

<key [fly key v] pressed?>
block. It would be cool if there was a block with that in it but what about a maze or something different from a flying project?
when gf clicked
forever
if <key [fly key v] pressed?>
change x by [5]
end
if <key [fly key v] pressed?>
change y by [-5]
end
if <key [fly key v] pressed?>
change x by [-5]
end
if <key [fly key v] pressed?>
change y by [5]
end
end
There might be a reply to that saying whatever it is a subsitute for. XD But how is GTM9 gonna know which to do?

Last edited by Liamadams (2013-03-29 16:47:51)


http://i39.tinypic.com/3309476.jpg

Offline

 

#5 2013-03-16 14:36:11

Harald
New Scratcher
Registered: 2013-03-05
Posts: 34

Re: Jetpack shoes

Sorry. The Fly key thing was just a substitute for whichever key they wanted the flying to be activated at.
Also, at that time, my scratchblock skills weren't very good..

Let's say Space is the trigger for flying:

when gf clicked
forever
if <<key [Space v] pressed?> and <(fuel) > [0]>>
change y by [1]
set [flight v] to [1]
else
set [flight v] to [0]

Offline

 

#6 2013-03-18 18:27:08

GTM9
Scratcher
Registered: 2013-02-05
Posts: 10

Re: Jetpack shoes

Thanks! Harald!

Offline

 

#7 2013-03-19 18:53:54

GTM9
Scratcher
Registered: 2013-02-05
Posts: 10

Re: Jetpack shoes

Help my guy starts falling as soon as the green flag is clicked

Offline

 

#8 2013-03-19 18:57:30

SarkyKeshy
New Scratcher
Registered: 2013-02-13
Posts: 9

Re: Jetpack shoes

That is because the brief bit of code here is just to demonstrate how to turn on an off the jetpack assuming there is no ground beneath.

You need to add a collision test to see if the jetpack guy is on the ground and if so NOT do the change Y by 1.

Probably by doing a touching color test.

Offline

 

#9 2013-03-19 19:01:30

SarkyKeshy
New Scratcher
Registered: 2013-02-13
Posts: 9

Re: Jetpack shoes

Sorry i appologise. That is not that case as the change by 1 is upward movement and only occurs when the space is pressed.

It means that somewhere in your code you have a change y by a "minus value" that does not check to see if the JetPack guy is on solid ground before performing it.

Offline

 

#10 2013-04-06 18:21:53

Liamadams
Scratcher
Registered: 2012-12-08
Posts: 100+

Re: Jetpack shoes

GTM9 wrote:

Help my guy starts falling as soon as the green flag is clicked

when gf clicked
forever
 if <key [up arrow v] pressed?>
  change y by [1]
 else
  change y by [-1]
end
if that doesnt work, dont use Haralds scripts (no offense just a suggestion).
also, some more scripts
when gf clicked
forever
 if <key [right arrow v] pressed?>
  change x by [2.5]
 end
 if <key [left arrow v] pressed?>
  change x by [-2.5]
end
hope it works. i havent tried it yet but heres my idea  smile

Last edited by Liamadams (2013-04-06 18:24:07)


http://i39.tinypic.com/3309476.jpg

Offline

 

#11 2013-04-10 17:02:54

Liamadams
Scratcher
Registered: 2012-12-08
Posts: 100+

Re: Jetpack shoes

Liamadams wrote:

GTM9 wrote:

Help my guy starts falling as soon as the green flag is clicked

when gf clicked
forever
 if <key [up arrow v] pressed?>
  change y by [1]
 else
  change y by [-1]
   if <key [up arrow v] pressed?>
    change y by [1]
   else
    change y by [-1]
     if <key [up arrow v] pressed?>
      change y by [1]
     else
      change y by [-1]
       if <key [up arrow v] pressed?>
        change y by [1]
       else
        change y by [-1]
end
if that doesnt work, dont use Haralds scripts (no offense just a suggestion).
also, some more scripts
when gf clicked
forever
 if <key [right arrow v] pressed?>
  change x by [2.5]
 end
 if <key [left arrow v] pressed?>
  change x by [-2.5]
end
hope it works. i havent tried it yet but heres my idea  smile

i think that way gravity works better.  cool


http://i39.tinypic.com/3309476.jpg

Offline

 

Board footer