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

#1 2012-06-24 14:55:45

Corwen
New Scratcher
Registered: 2012-06-23
Posts: 28

platform game. swimming?

I have made a basic platform game, and i was wondering if there is any way to my my character swim when in water.
  This would mean slowing him down whilst touching a certain shade of blue (water) and not being able to jump as high.

to see the game i wish to add this feature to go here:
http://scratch.mit.edu/projects/Corwen/2630226

please help!

Offline

 

#2 2012-06-24 15:20:05

THEphish
New Scratcher
Registered: 2012-06-23
Posts: 15

Re: platform game. swimming?

I haven't seen your game but try making these two scripts like these:

when gf clicked
forever
  if <touching colour [#00FF00]?>
    move [-5] steps //or however much you want to slow down by. Drawback is if you stop moving you get dragged back again.
end
when gf clicked
point in direction [-90 v]
move 10 steps

This is just a bit of a guess, and I don't know about the jumping, but it might work!

Offline

 

#3 2012-06-24 15:23:50

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: platform game. swimming?

Make your movement scripts work on variables (speed or velocity) and then just have if touching blue set speed to (smaller amount) else set speed to (normal)


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#4 2012-06-24 15:24:02

Corwen
New Scratcher
Registered: 2012-06-23
Posts: 28

Re: platform game. swimming?

i have tried this, with my scripts, this simply makes the player move backwards.  sad
its puzzling.  sad

Offline

 

#5 2012-06-24 16:07:02

Corwen
New Scratcher
Registered: 2012-06-23
Posts: 28

Re: platform game. swimming?

zammer990 wrote:

Make your movement scripts work on variables (speed or velocity) and then just have if touching blue set speed to (smaller amount) else set speed to (normal)

Thanks for the reply, i will test this next time i am working on my game. I am almost certain it will work

Offline

 

#6 2012-06-24 18:30:16

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: platform game. swimming?

Like Zammer said, using velocity is probably your best bet.  smile


Hai.

Offline

 

#7 2012-06-25 02:43:34

JH1010
Scratcher
Registered: 2012-05-31
Posts: 1000+

Re: platform game. swimming?

For moving left and right:

when gf clicked
forever
if <touching colour [ground colour]
if  <key [right arrow] pressed>
change x by 5
end
if  <key [left arrow] pressed
change y by -5
end
end
if <touching colour [water colour]
if  <key [right arrow] pressed>
change x by 3
end
if  <key [left arrow] pressed
change y by -3
end
end
end
For jumping:

when gf clicked
forever
if <<touching colour [ground colour]> or <touching colour [water colour]>>
set [y velocity] to (0)
end
if <<touching colour [ground colour]> and <key [up arrow] is pressed>>
change [y velocity] by (15)
end
if <<touching colour [water colour]> and <key [up arrow] is pressed>>
change [y velocity] by (9)
end
if <<<not <touching colour [ground colour]> or <touching colour [water colour]>>>
change [y velocity] by (0.4)
end
end
[scratchbocks]
when gf clicked
forever
change y by [y velocity]
end

Offline

 

Board footer