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

#1 2012-03-10 15:54:24

CoolGamesCY
New Scratcher
Registered: 2012-03-03
Posts: 15

They won't stay still!!

I am making a game with x and y scrolling and you playing it as you where looking at it from above (For example Pokemon games and classic zelda games)

Everything works perfectly! The problem is the enemy's won't go in the place I want them to be.  if that makes sense.

The game works so the main character stays still but the background scrolls.

Please help!

Offline

 

#2 2012-03-10 15:57:04

Splodgey
Scratcher
Registered: 2011-04-26
Posts: 500+

Re: They won't stay still!!

No, it doesn't make sense....

Offline

 

#3 2012-03-10 16:41:11

CoolGamesCY
New Scratcher
Registered: 2012-03-03
Posts: 15

Re: They won't stay still!!

Um...

The background have this:

when gf clicked
forever
go to x: xscroll+480*0 Y: yscroll+360*0 
The player has

when gf clicked
forever if <key right pressed>
change scrollx by -5
key left change xscroll by 5

key up pressed change yscroll by -5
key down pressed chang yscroll by 5

so now i want enemys but i dont know how to make them stay in 1 place within the area

Offline

 

#4 2012-03-11 05:49:26

CoolGamesCY
New Scratcher
Registered: 2012-03-03
Posts: 15

Re: They won't stay still!!

please help??

Offline

 

#5 2012-03-11 06:11:33

Splodgey
Scratcher
Registered: 2011-04-26
Posts: 500+

Re: They won't stay still!!

How big is "the area"?
The enemies would probably need this;

when gf clicked
forever
set x to ((scroll x) - (x)) //the "x" variable being a "for this sprite only" variable
set x to ((scroll y) - (y)) //and the "y" variable
The "x" and "y" variables would be the position of the enemies. You could make them move within a certain area by adding something like this;
if <(x) < [10]>
set [x v] to [10] //changing the 10 to the minimum x, if that makes sense...
set [x velocity v] to ([0] - (x velocity)) //So it turns around
end

if <(x) > [80]>
set [x v] to [80]
set [x velocity v] to ([0] - (x velocity))
end
Do the same for the y. Then it should work, I'm sure you can make them move...
Because it's velocity it would need for the enemy:
change [x v] by (x velocity)
So x velocity is just x speed. I would try to explain better but I've go to go somewhere...

Offline

 

#6 2012-03-11 06:18:30

cheddargirl
Scratch Team
Registered: 2008-09-15
Posts: 1000+

Re: They won't stay still!!

Your enemies have to scroll along with the background in order for them to stay within their designated area. If your background is scrolling to the right, the enemies have to also scroll to the right, etc..

The easiest way to do that is to add a script to the enemies that's similar to the script that you have in the background. For example, if you want an enemy to appear 50 pixels off from the center in the x direction:

when gf clicked
forever
set x to ((((50)+(scrollx))+(480))*(0))
set y to (((yscroll)+(360))*(0))
end


http://i.imgur.com/8QRYx.png
Everything is better when you add a little cheddar, because when you have cheese your life is at ease  smile

Offline

 

Board footer