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

#1 2012-08-06 07:20:52

JamieBruce
Scratcher
Registered: 2012-08-05
Posts: 52

how to move

I have been looking for ways to move,jump,fall,walk on stuff and fly any suggestions?  hmm


help my project "the adventures of oreo,sandstone and flopsy"
[url=file:///C:/Users/Jamie/Desktop/JBcaptain/JBcaptain.htmL[/url]

Offline

 

#2 2012-08-06 07:37:52

BirdByte
Scratcher
Registered: 2012-07-07
Posts: 1000+

Re: how to move

Moving around and jumping are completely different for each project. If you are making a scrolling platformer, scrolling, collision detection and an xpos variable will need to be implemented. If it's a non-scrolling platformer, you'll need collision detection. However, if it's just a character moving around a screen, then it'll be easy: The simplest way of doing this is direct movement, which uses this script:

when gf clicked
forever
 if <key [up arrow v] pressed?>
  change y by (1)
 end
 if <key [down arrow v] pressed?>
  change y by (-1)
 end
 if <key [left arrow v] pressed?>
  change x by (-1)
 end
 if <key [right arrow v] pressed?>
  change x by (1)
 end
end


http://i50.tinypic.com/312u714.jpg

Offline

 

#3 2012-08-06 07:54:53

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

Re: how to move

This should do it.

when gf clicked
set [x v] to (0)
set [y v] to (0)
forever
if<key [right arrow v] pressed?>
change [x v] by (0.2)
end
if<key [left arrow v] pressed?>
change [x v] by (-0.2)
end
change x by (x)
if <touching [wall or floor sprite v]?>
set [x v] to ((-0.5)*(x))
change x by (x)
if <touching [wall or floor sprite v]?>
change x by (x)
end
end
if<key [space v] pressed?>// fly up when space is pressed
change [y v] by (0.2)
end
change [y v] by (-0.1)
change y by (y)
if<touching [wall or floor sprite v]?>
set [x v] to ((x)*(.98)) // friction on the ground
set [y v] to ((-0.5)*(y))
change y by (y)
if<touching [wall or floor sprite v]?>
change y by (y)
end
if<<key [up arrow v] pressed?> and <(y) > (0)>>
set [y v] to (5)
end
else
set [x v] to ((x)*(.99)) // less friction if you're in the air
end


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

Offline

 

#4 2012-08-06 10:51:23

JamieBruce
Scratcher
Registered: 2012-08-05
Posts: 52

Re: how to move

this dosen't work=(


help my project "the adventures of oreo,sandstone and flopsy"
[url=file:///C:/Users/Jamie/Desktop/JBcaptain/JBcaptain.htmL[/url]

Offline

 

#5 2012-08-06 16:46:00

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: how to move

I helped whiteflame115 with something similar to this. Anyway, at the end of one of Whiteflame115's topics, I made a guide on making sensors for platformers as well as how to make your character move and not run through walls. Just to warn you, it might be a bit complicated, and also remember that the my tutorial is at the end of it. Anyway, here's a link to the topic:
how to make a sprite move up a diagonal line?

Just to let you know, my tutorial doesn't have everything in it. For example, if you were only using my scripts, then you could jump through ceilings, but that can be avoided with the right scripts.

Anyhow, I hope that this helps!

Last edited by ErnieParke (2012-08-06 17:06:14)


http://i46.tinypic.com/35ismmc.png

Offline

 

#6 2012-08-07 19:52:00

maxamillion321
Scratcher
Registered: 2011-06-17
Posts: 500+

Re: how to move

You use the go to script.

go to x:(0):y(0)

Last edited by maxamillion321 (2012-08-07 19:52:22)

Offline

 

#7 2012-08-07 20:02:50

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: how to move

maxamillion321 wrote:

You use the go to script.

go to x:(0):y(0)

Fixed:

go to x: (0) y: (0)


http://i46.tinypic.com/35ismmc.png

Offline

 

#8 2012-08-08 05:04:56

JamieBruce
Scratcher
Registered: 2012-08-05
Posts: 52

Re: how to move

nonsense   mad


help my project "the adventures of oreo,sandstone and flopsy"
[url=file:///C:/Users/Jamie/Desktop/JBcaptain/JBcaptain.htmL[/url]

Offline

 

#9 2012-08-08 07:53:26

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: how to move

JamieBruce wrote:

nonsense   mad

What do you mean by "nonsense"?


http://i46.tinypic.com/35ismmc.png

Offline

 

#10 2012-08-08 08:55:36

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

Re: how to move

JamieBruce wrote:

this dosen't work=(

Unless I'm misunderstanding what you're asking, it does work; I uploaded an example here


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

Offline

 

#11 2012-08-12 12:58:51

CoolScrawl
Scratcher
Registered: 2012-02-04
Posts: 100+

Re: how to move

Here:

when gf clicked
move somehow XD


http://i.imgur.com/sFkNT3c.gif

Offline

 

#12 2012-08-26 13:41:03

JamieBruce
Scratcher
Registered: 2012-08-05
Posts: 52

Re: how to move

ErnieParke wrote:

JamieBruce wrote:

nonsense   mad

What do you mean by "nonsense"?

just player controlled not auto game!


help my project "the adventures of oreo,sandstone and flopsy"
[url=file:///C:/Users/Jamie/Desktop/JBcaptain/JBcaptain.htmL[/url]

Offline

 

Board footer