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

#1 2012-10-21 12:45:42

Wernich
New Scratcher
Registered: 2012-01-28
Posts: 7

how to throw something in an scrolling game

hello

i am working on an project and i am stuck. how do you throw or shoot an object relative to the scrolling? i want the object to go towards where i click on the screen relative to the scrolling sprite?? so if the player sprite moves in the game the projectile will not move slower or faster it will move like in real life. currently i just moves 4 steps in the direction of the mouse and if i move back it goes slower because of the scrolling and forward it goes faster.

Please I am a rookie still in school and it is my passion please help me.

Offline

 

#2 2012-10-21 14:52:02

bullelk12
Scratcher
Registered: 2012-05-26
Posts: 100+

Re: how to throw something in an scrolling game

I'll work on it.


http://mag.racked.eu/cimage/i6000/Achievement++get%21/Scratcher+love+minecraft%21/mca.png

Offline

 

#3 2012-10-21 15:04:31

bullelk12
Scratcher
Registered: 2012-05-26
Posts: 100+

Re: how to throw something in an scrolling game

This assumes you have already made the scrolling scripts aspect.
Take the variable 'scrolling speed' and place it in the last part of the scrolling script where it multiplies 480 x (number). Put that variable into the (number) slot.

If you're trying to scroll a different way then you should probably look at this site it shows you the scrolling script that this works with. Go to http://wiki.scratch.mit.edu/wiki/Scrolling_(sprites)


when i receive [throw v]
show 
go to [character v] 
repeat until <touching [ground v]?>
change [scrolling speed v] by (.01)
This script changes the scrollx position of the object by a certain amount so it changes its relative position even if you move. If you lower the number even more you could beat it in a race. Kinda cool I think.

If you want to include gravity on the object use this script.

when gf clicked
set [gravity v] to (-.4)
set [velocity v] to (0)
forever 
if <touching [ground v]?>
set [velocity v] to (0)
else
change [velocity v] by (gravity)
change y by (velocity)
I believe this should work. See my project that includes characters moving with scrolling if you want more detailed stuff on that.http://scratch.mit.edu/projects/bullelk12/2843982

Last edited by bullelk12 (2012-10-21 15:09:48)


http://mag.racked.eu/cimage/i6000/Achievement++get%21/Scratcher+love+minecraft%21/mca.png

Offline

 

#4 2012-10-22 10:35:30

Wernich
New Scratcher
Registered: 2012-01-28
Posts: 7

Re: how to throw something in an scrolling game

thanks man this was helpful I however eventually late last night figured the x speed out. Now what I am struggling with Ii want the object to move towards where I click on the screen until it touches the edge or scrolling sprite?

and really thanks for the help I appreciate it!

Offline

 

Board footer