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

#1 2009-07-25 17:08:50

1st_look-shot-kill
Scratcher
Registered: 2009-01-29
Posts: 3

Making NPCs move realistically in a scrolling game: I'm stumped

I'm making a scrolling game that has a first-person perspective (the background moves left or right depending on where you look).
In this game, there are other characters who walk from left to right across the screen.
I know how to make them walk across the screen, and I know how to make them scroll along with the background as you look around (if they are standing still, of course). What I DON'T know how to do is to make it so that they walk from point A to point B at the same "speed" even while you look around.

For example, let the other character's walking speed be 5. If you aren't looking around, their walking speed will be 5, and their x position on the screen will also be changing by 5.
If you are following them with your eyes, their walking speed will still be five, but their x position on-screen will not change since you are following them.
If you are scanning to the left (behind the other character), their walking speed will still remain at 5, but their x position on-screen will be changing by more than 5.
If you are scanning to the right (in front of the other character), their walking speed will, again, remain at 5, but their position on-screen will be shifting to the left since you are scanning ahead of them.

It's a problem of perspective, and it has me stumped. Please help.

Offline

 

#2 2009-07-26 05:41:35

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Making NPCs move realistically in a scrolling game: I'm stumped

I don't know if you will find it helpful (since it's not from first person perspective) but if you look at the meteors and the coins in this scroller, they are moving realisticly with respect to the landscape.

http://scratch.mit.edu/projects/Paddle2See/171502


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#3 2009-07-26 07:12:47

deatheater
Scratcher
Registered: 2008-04-11
Posts: 1000+

Re: Making NPCs move realistically in a scrolling game: I'm stumped

One of the ways I use is I use archmages method of scrolling, u see the (( 480 <*> 0 ))

part, I put a variable called Xpos (though u can call it whatever u want),

(( 480 <*> <{ Xpos }> ))

Then on the character ur looking at I put

<when green flag clicked>
<set{ Xpos }to( 0
<forever>
<change{ Xpos }by( (( 5 </> 480 ))
<end>

Offline

 

Board footer