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

#1 2008-05-27 23:39:55

lestrade3333
Scratcher
Registered: 2008-05-21
Posts: 18

Infinite scrolling but definite distances

I have an idea, but I don't know whether it will work:

first I have vertical strips of cut out background (stars) that will move left or right when arrow keys pressed, with the main sprite pointing in a certain direction when the arrow keys are pressed, and the strips will move to the opposite direction, and when the strips hit the border, it reappears in the side it originally came from, so to create a scrolling background. It should create an optical illusion that the sprite is moving, but the it is always in the centre. And it is supposed to give the sprite infinite range. It works fine with some other projects I have seen, but the problem is this:

How on earth am I suppose to make sprites that is supposed to appear when the sprite goes a certain "distance" ? For example, if the sprite moves right for ten seconds, it is supposed to reach coordinate of sprite B (which appears). but if I move left, the distance to sprite B is all messed up.Considering the main sprite has NOT MOVED ANY REAL DISTANCE AT ALL, there is no way to make sure of the relative distances between sprites. I considered using a ghost minimap to keep track, but I can't figure out how to do it, and I need help.

If it happens that any of you guys find a less redundant way to achieve this, feel free to tell me.
Thanks.

Offline

 

#2 2008-05-27 23:59:04

CFCRubiks
Scratcher
Registered: 2008-05-11
Posts: 100+

Re: Infinite scrolling but definite distances

Maybe a variable like this:

[blocks]<when green flag clicked>[/blocks]
[blocks]<forever if><key[ Right arrow ]pressed?>[/blocks]
[blocks]<repeat until><<  <not><key[ right arrow ]pressed?>  >>[/blocks]
[blocks]<wait( 1 )secsc>[/blocks]
[blocks]<change{ Time }by(1[/blocks]
[blocks]<end>[/blocks]
[blocks]<stop script>[/blocks]


And opposite for other side (left side). I really don't konw if it will work, bubt it most likely will. And when Time gets to a certain number, whatever you want happens.



P.S. Going left should change time by negative

Last edited by CFCRubiks (2008-05-27 23:59:39)

Offline

 

#3 2008-05-28 04:34:36

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: Infinite scrolling but definite distances

Imagine your play area as one very wide screen made up of all your sprites.  You need to use a variable to keep track of your "x" co-ordinate on that "super-screen".  You can position monsters, objects etc on the "super screen" by giving them an "x" location of their own, and then you can then use the "x" variable to check whether or not other things are on the actual screen or not.

My Ninja Dynamic Scroller uses this method, but it has other aspects that make it too complicated to be a good example to learn from, I'm afraid.


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

#4 2009-01-15 19:41:12

sam95
Scratcher
Registered: 2008-11-11
Posts: 1

Re: Infinite scrolling but definite distances

how do you make a minimap? what i am trying to do is be able to keep track of the moving person in a scrolling background position relative to other sprite. like a minimap in a lot of video games that shows you where you are in relation to other things.

Offline

 

#5 2009-01-20 21:09:53

EveningSage
Scratcher
Registered: 2009-01-10
Posts: 65

Re: Infinite scrolling but definite distances

Just make a variable that changes by .1 or something when you have the right arrow key down and subtracts .1 when the left is down. like this:
<if><key[ right ]pressed?>
<forever if><key[ right ]pressed?>
<change{ xPosition }by( .1)
<end>
<end>

And then When XPosition equals whatever have a monster Pop up.

Offline

 

#6 2009-01-20 23:00:25

yambanshee
Scratcher
Registered: 2007-11-06
Posts: 500+

Re: Infinite scrolling but definite distances

i guess the enemy could also receave a scrolling value. More info in my Tanks game

Offline

 

Board footer