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

#1 2012-01-30 15:03:00

Zparx
Scratcher
Registered: 2011-03-23
Posts: 500+

How to add moving objects to a scrolling game?

Hi, I'm working on a scrolling game in which will have moving platforms. I know how to make the platforms work with the scroller, but one key piece of information that I need is missing. I would like to know how I can get the platforms to move while the player is roaming and not on any of them. I know how to make a platform function vertically (y position). It's horizontally (x-position) that I'm concerned with. For example, when a player walks up to a platform, have said platform following it's path to and from point A and point B, horizontally. I cannot fathom how this can be done while the game is a scroller, being as how you have to set object's and terrain's x position to:

forever
set x to [scrollx + 480 * 0] //and add 1 for every terrain, etc.
^ with that, things only move according to it, which is why I'm confused.

Thank you for your time and I hope someone has taken the time to read this and help me! I promise to whomever helps out, you will not go un-noticed. I will look into your projects, and add a credits section to the end of the game, with your names in it!


http://images3.wikia.nocookie.net/__cb20101119183412/halo/images/4/43/Hero2.png
^ My rank on Halo: Reach :3

Offline

 

#2 2012-01-30 15:20:53

360-International
Scratcher
Registered: 2011-07-17
Posts: 100+

Re: How to add moving objects to a scrolling game?

The script

forever
set x to ((scrollx) + ((480) * (amount)))
only works with
when [right arrow v] key pressed
change [scrollx v] by (0.8)

when [left arrow v] key pressed
change [scrollx v] by (-0.8)
or similar scripts in the sprite that is "moving". This gives an illusion of movement.

Last edited by 360-International (2012-01-30 15:24:15)


https://lh4.googleusercontent.com/Oib6kyze-OrCFIRlqL6HYnWuHBQp1GfFoh5CkBlZGe3_9WCk-_DDwgfFrnD_mxJ_x2b18hMUyV2KVtIDiLdebyWaQQ6fbpKpZs-8auVep1zoSgOv-iA

Offline

 

#3 2012-01-30 15:23:22

Zparx
Scratcher
Registered: 2011-03-23
Posts: 500+

Re: How to add moving objects to a scrolling game?

I understand that. Like I know how scrollers work, but I mean I don't know how I would make a platform move on it's own in game, while also moving with the scroller. ):

***(on its x posistion, that is)


http://images3.wikia.nocookie.net/__cb20101119183412/halo/images/4/43/Hero2.png
^ My rank on Halo: Reach :3

Offline

 

#4 2012-01-30 15:25:43

360-International
Scratcher
Registered: 2011-07-17
Posts: 100+

Re: How to add moving objects to a scrolling game?

Zparx wrote:

I understand that. Like I know how scrollers work, but I mean I don't know how I would make a platform move on it's own in game, while also moving with the scroller. ):

Just give the platform a

change [scrollx v] by (0.2)
or something.

If you want objects to move independently, I would guess that a
forever
set x to (((scrollx) + [offset amount]) + (independent movement))
change [independent movement v] by (2)
if <(independent movement) > [too much]> // These are for programming baddies.
point in direction (90 v) // These only work if the sprite only faces left-right.
end
if <(independent movement) < [too little]>
point in direction (-90 v)
end
would work.

Last edited by 360-International (2012-01-30 15:38:28)


https://lh4.googleusercontent.com/Oib6kyze-OrCFIRlqL6HYnWuHBQp1GfFoh5CkBlZGe3_9WCk-_DDwgfFrnD_mxJ_x2b18hMUyV2KVtIDiLdebyWaQQ6fbpKpZs-8auVep1zoSgOv-iA

Offline

 

#5 2012-01-30 15:48:56

Zparx
Scratcher
Registered: 2011-03-23
Posts: 500+

Re: How to add moving objects to a scrolling game?

360-International wrote:

Zparx wrote:

I understand that. Like I know how scrollers work, but I mean I don't know how I would make a platform move on it's own in game, while also moving with the scroller. ):

Just give the platform a

change [scrollx v] by (0.2)
or something.

If you want objects to move independently, I would guess that a
forever
set x to (((scrollx) + [offset amount]) + (independent movement))
change [independent movement v] by (2)
if <(independent movement) > [too much]> // These are for programming baddies.
point in direction (90 v) // These only work if the sprite only faces left-right.
end
if <(independent movement) < [too little]>
point in direction (-90 v)
end
would work.

Omg! Thank you so much! That's exactly what I was looking for! I will be sure to include you in the credits section of the final game! Going to go check out your projects now (: Again, thank you!


http://images3.wikia.nocookie.net/__cb20101119183412/halo/images/4/43/Hero2.png
^ My rank on Halo: Reach :3

Offline

 

#6 2012-01-30 15:58:39

360-International
Scratcher
Registered: 2011-07-17
Posts: 100+

Re: How to add moving objects to a scrolling game?

Zparx wrote:

Omg! Thank you so much! That's exactly what I was looking for! I will be sure to include you in the credits section of the final game! Going to go check out your projects now  smile  Again, thank you!

You're welcome  big_smile

EDIT: To get the smileys to work, face them to the right. If you don't want them to work,  check "Never show smilies as icons for this post" near the "Submit" button.

Last edited by 360-International (2012-01-30 16:14:30)


https://lh4.googleusercontent.com/Oib6kyze-OrCFIRlqL6HYnWuHBQp1GfFoh5CkBlZGe3_9WCk-_DDwgfFrnD_mxJ_x2b18hMUyV2KVtIDiLdebyWaQQ6fbpKpZs-8auVep1zoSgOv-iA

Offline

 

Board footer