How do I make the screen scroll like a Zelda game?

From OHRRPGCE-Wiki

Jump to: navigation, search
This article does not meet the standard of quality we would like to have. Feel free to revise it and make it better by using the edit link at the top of the page. This tag should be removed when an editor feels it is of high quality.

The following script is making the screen scrolling like in Zelda's games. It comes from moogle1's website (click above for more details)

script, zelda scroll, begin
	suspend player # don't let the player screw this up!

	variable (scrollnpc) # for changing the NPC used

	scrollnpc := 0    # scroll npc is NPC 0, change to suit needs
	if(herodirection(me) == up, or, herodirection(me) == down)
		then, begin
			pancamera(herodirection(me),12,10) # pan camera 12 tiles up or down!
		end

	if(herodirection(me) == left, or, herodirection(me) == right)
		then, begin
			pancamera(herodirection(me),18,10) # pan camera 19 right or left!
		end


	variable (tempx) # Magical NPC Locator Variables (tm)
	variable (tempy)
	
	tempx := herox(me) # MNL Variables are set to the hero's current position
	tempy := heroy(me)

	
	# these IFs set the "npc locator" variables one ahead of the hero
      # so it doesn't "find" the npc the hero is standing on
	
	if(herodirection(me) == up) then ( tempy := tempy -- 1 )
	if(herodirection(me) == down) then ( tempy := tempy + 1 )
	if(herodirection(me) == left) then ( tempx := tempx -- 1 )
	if(herodirection(me) == right) then ( tempx := tempx + 1 )


	while(npcatspot(tempx,tempy) == false) # time to search for that NPC
		do, begin
			# Yes, I used the same ifs again.
			# Re-usable code: Hey, it worked for Windows! (tm)
			
                if(herodirection(me) == up) then ( tempy := tempy -- 1 )
            	if(herodirection(me) == down) then ( tempy := tempy + 1 )
            	if(herodirection(me) == left) then ( tempx := tempx -- 1 )
            	if(herodirection(me) == right) then ( tempx := tempx + 1 )
		end

	variable (npctodelete)
	npctodelete := npcatspot(tempx,tempy)

	destroynpc(npctodelete) #destroys NPC ahead of Dogero
	

	# I could have even used the above IFs -again- here, but for
	# some reason it looks better this way.
	# The below code walks Dogero (or the hero) in the direction needed,
	# and then walks them one more step in that direction so I
	# can re-create the NPC in it's old spot
	
	if(herodirection(me) == up, or, herodirection(me) == down)
		then, begin
			walkherotoy(me,tempy)
			waitforhero
			if(herodirection(me) == up) then ( walkhero(me,up,1) , waitforhero)
			if(herodirection(me) == down) then ( walkhero(me,down,1) , waitforhero)
	
		end

	if(herodirection(me) == left, or, herodirection(me) == right)
		then, begin
			walkherotox(me,tempx)
			waitforhero
			if(herodirection(me) == left) then ( walkhero(me,left,1) , waitforhero)
			if(herodirection(me) == right) then ( walkhero(me,right,1) , waitforhero)
	
		end

	walknpc


	createnpc(scrollnpc,tempx,tempy)  # re-creates deleted NPC

	resumeplayer #returns control of game to player after all of this scripting! Phew.

end # end of script


Feel to adapt it your needs but using only the pan camera commands and using less tiles than 12.

Eg

 if(herodirection(me) == left, or, herodirection(me) == right,or, 

herodirection(me) == up, or, herodirection(me) == down)
		then, begin
			pancamera(herodirection(me),10,10) # pan camera 10 right left up or down!
		end

[edit] See Also

Moogle1's Plotscripting Tutorials

Personal tools