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

#1 2012-03-12 12:32:04

DimensionOS
New Scratcher
Registered: 2012-03-12
Posts: 3

Help with NPC's in x and y scrolling games

I'm making an X/ Y scrolling game. It is Pokemon style meaning you play it from a birds eye view.

Anyway, I want to place a person into my game but I don't know how to position him so he will stay there.

The X and Y scrolling script is the traditional method meaning it's like this for the backgrounds:

when gf clicked
forever
go to x: <<(xscroll)> + <(480)*(0)>> y: <<(yscroll)> + <(360)*(0)>>
end
and I change the 0's with numbers for the positioning. I tried doing that with the NPC but he kept moving with the background when my character moved/ background moved

Please help

Offline

 

#2 2012-03-12 13:52:48

muppetds
Scratcher
Registered: 2011-02-11
Posts: 1000+

Re: Help with NPC's in x and y scrolling games

just don't put any movement scripts in the person then place him in the location you want him in

so just take out the scrolling scripts in the person and then he will stay still while the background moves  smile


SCRATCH'S PARTLY INSANE RESIDENT 
http://internetometer.com/imagesmall/31691.pnghttp://bluetetrarpg.x10.mx/usercard/?name=muppetds

Offline

 

#3 2012-03-12 15:38:21

turkey3
Scratcher
Registered: 2011-12-04
Posts: 500+

Re: Help with NPC's in x and y scrolling games

Hmm.. You'll have to have the sprite forever glint to a location in relation to the sctolling sprite

Offline

 

#4 2012-03-12 20:52:53

MaxFlyboy
Scratcher
Registered: 2011-11-07
Posts: 100+

Re: Help with NPC's in x and y scrolling games

DimensionOS wrote:

I'm making an X/ Y scrolling game. It is Pokemon style meaning you play it from a birds eye view.

Anyway, I want to place a person into my game but I don't know how to position him so he will stay there.

The X and Y scrolling script is the traditional method meaning it's like this for the backgrounds:

when gf clicked
forever
go to x: <<(xscroll)> + <(480)*(0)>> y: <<(yscroll)> + <(360)*(0)>>
end
and I change the 0's with numbers for the positioning. I tried doing that with the NPC but he kept moving with the background when my character moved/ background moved

Please help

just don't do it with the NPC and it'll be fine


http://cdn.voodoofilm.org/images/upload/thumb/viral-video-2011.jpg click the picture for an AMV

Offline

 

#5 2012-03-15 19:29:54

sccar3
Scratcher
Registered: 2008-09-04
Posts: 100+

Re: Help with NPC's in x and y scrolling games

you would do

when gf clicked
forever
go to x:<xscroll> + 480 * 0 + <x> y: <yscroll> + 360 * 0 + <y>
end
x and y would be personal variables.
You could have them move around like you would normally but use the x and y variables instad of xposition and yposition.


PS: I don't quite get how to use scratchblocks in forums yet

Last edited by sccar3 (2012-03-15 19:31:24)


http://1.bp.blogspot.com/-WInb2DZ2LBM/UQaLETx3VII/AAAAAAAAAmQ/ZOpSwEPggiE/s1600/The%2BElder%2BScrolls%2BOnline%2BSignup%2BBeta.jpg

Offline

 

#6 2012-03-15 19:42:17

itsmomito
Scratcher
Registered: 2008-03-28
Posts: 100+

Re: Help with NPC's in x and y scrolling games

Exactly, I did it with my mario scroller: http://scratch.mit.edu/projects/itsmomito/1120339

I made that a long time ago, but you can download it and take a look at the npc scripts. I'll take a look later and give you the script I used.

Offline

 

#7 2012-03-15 19:50:06

itsmomito
Scratcher
Registered: 2008-03-28
Posts: 100+

Re: Help with NPC's in x and y scrolling games

Ahh Now I remember what I did:

First, I created a variable for the movement of the npc, in my case in was a goomba from Mario  smile  So I named it Goomba Move.

Then I created this script in the goomba (sorry I just got back on scratch. Im not sure how to use Scratch Blocks yet):

When Flag Clicked
      Forever
           Set X to Goomba Move + ScrollX + 160
      End

The 160 is just the relative location on the screen with Scroll x. For example: if it was 300, the goomba would just be farther to the right. Goomba Move is for the Goomba to move. I Made a script so that it only moves when he is in the screen area. I also made a script to hide the goomba if his x is too far from the player to be on the screen. There you go! That's all there is to it.

Last edited by itsmomito (2012-03-15 19:51:24)

Offline

 

Board footer