Moving Screen help, like an overhead scrolling shooter |
|
|
|
 |
Replies
|
|
Jan 16 2013, 01:22 AM
|

Dark Jentleman

Group: Local Mod
Posts: 916
Type: Scripter
RM Skill: Skilled
Rev Points: 120

|
You need some scripts to do that... Events and Common Events can't handle this efficiently. Are you planning to scroll it like an Aero Fighter game (from south to north) or more like Gradius (from left to right)? For a Gradius-like effect, you could try this one... CODE #=============================================================================== # ** Jens of Zanicuud horizontal scroll engine v 0.8 # - free use, just credit # - free customization, just PM me the modified version # - you can find me at www.rpgrevolution.com #=============================================================================== # This script will confine the player between the screen's limits by setting # a certain switch to ON (see next lines for a more precise description). # This script could have some compatibility problem, since when the switch # is active, it overruns the update method of the Game_Player class. # Use it carefully and ask for troubleshooting anytime! # NOTE: for now, it works ONLY with horizontal scrolling from LEFT to RIGHT! #===============================================================================
#-------------------------------------------------------------------------- # ** Game_Player #-------------------------------------------------------------------------- class Game_Player < Game_Character #-------------------------------------------------------------------------- # * Constants #-------------------------------------------------------------------------- #id of the switch which triggers the scroll game (e.g. 1 means you have to #set the Switch[0001] to ON. Scroll_game_switch = 1 #-------------------------------------------------------------------------- # * Aliases #-------------------------------------------------------------------------- alias scroll_system_center center alias scroll_update update alias scroll_moving moving? #-------------------------------------------------------------------------- # * Center camera on the player #-------------------------------------------------------------------------- def center(x, y) if !$game_switches[Scroll_game_switch] scroll_system_center(x,y) end end #-------------------------------------------------------------------------- # * Scroll_Moving? #-------------------------------------------------------------------------- def scroll_moving? if @real_x <= $game_map.display_x if @real_y != @y * 128 return true else return false end elsif @real_x >= $game_map.display_x + 640*4 - 128 if @real_y != @y * 128 return true else return false end else return moving? end end #-------------------------------------------------------------------------- # * Update #-------------------------------------------------------------------------- def update if $game_switches[Scroll_game_switch] last_moving = moving? unless scroll_moving? or $game_system.map_interpreter.running? or @move_route_forcing or $game_temp.message_window_showing case Input.dir4 when 2 move_down when 4 move_left when 6 move_right when 8 move_up end update_move end last_real_x = @real_x last_real_y = @real_y super unless moving? if last_moving result = check_event_trigger_here([1,2]) if result == false unless $DEBUG and Input.press?(Input::CTRL) if @encounter_count > 0 @encounter_count -= 1 end end end end if Input.trigger?(Input::C) check_event_trigger_here([0]) check_event_trigger_there([0,1,2]) end end else scroll_update end end #-------------------------------------------------------------------------- # * Update Move #-------------------------------------------------------------------------- def update_move if $game_switches[Scroll_game_switch] screen = [$game_map.display_x, $game_map.display_y, $game_map.display_x + 640*4 - 128, $game_map.display_y + 480*4 - 128] distance = 2 ** @move_speed if @y * 128 > @real_y @real_y = [[@real_y + distance, @y * 128].min, screen[3]].min @real_x = [[screen[0], @real_x].max,screen[2]].min if @real_y == screen[3] @y = @real_y / 128 end end if @x * 128 < @real_x @real_x = [[@real_x - distance, @x * 128].max, screen[0]].max @real_y = [[screen[1], @real_y].max,screen[3]].min if @real_x == screen[0] @x = @real_x / 128 end end if @x * 128 > @real_x @real_x = [[@real_x + distance, @x * 128].min, screen[2]].min @real_y = [[screen[1], @real_y].max,screen[3]].min if @real_x == screen[2] @x = @real_x / 128 end end if @y * 128 < @real_y @real_y = [[@real_y - distance, @y * 128].max, screen[1]].max @real_x = [[screen[0], @real_x].max,screen[2]].min if @real_y == screen[1] @y = @real_y / 128 end end if @walk_anime @anime_count += 1.5 elsif @step_anime @anime_count += 1 end else super end end #-------------------------------------------------------------------------- # * Update Stop #-------------------------------------------------------------------------- def update_stop super if $game_switches[Scroll_game_switch] screen = [$game_map.display_x, $game_map.display_y, $game_map.display_x + 640*4 - 128, $game_map.display_y + 480*4 - 128] @real_x = [[screen[0], @real_x].max,screen[2]].min @real_y = [[screen[1], @real_y].max,screen[3]].min end end end Jens
__________________________
|
|
|
|
|
|
|
|
|
Jan 29 2013, 11:17 AM
|

Level 2

Group: Member
Posts: 25
Type: Event Designer
RM Skill: Intermediate

|
QUOTE (Jens of Zanicuud @ Jan 16 2013, 01:22 AM)  You need some scripts to do that... Events and Common Events can't handle this efficiently. Are you planning to scroll it like an Aero Fighter game (from south to north) or more like Gradius (from left to right)? For a Gradius-like effect, you could try this one... CODE #=============================================================================== # ** Jens of Zanicuud horizontal scroll engine v 0.8 # - free use, just credit # - free customization, just PM me the modified version # - you can find me at www.rpgrevolution.com #=============================================================================== # This script will confine the player between the screen's limits by setting # a certain switch to ON (see next lines for a more precise description). # This script could have some compatibility problem, since when the switch # is active, it overruns the update method of the Game_Player class. # Use it carefully and ask for troubleshooting anytime! # NOTE: for now, it works ONLY with horizontal scrolling from LEFT to RIGHT! #===============================================================================
#-------------------------------------------------------------------------- # ** Game_Player #-------------------------------------------------------------------------- class Game_Player < Game_Character #-------------------------------------------------------------------------- # * Constants #-------------------------------------------------------------------------- #id of the switch which triggers the scroll game (e.g. 1 means you have to #set the Switch[0001] to ON. Scroll_game_switch = 1 #-------------------------------------------------------------------------- # * Aliases #-------------------------------------------------------------------------- alias scroll_system_center center alias scroll_update update alias scroll_moving moving? #-------------------------------------------------------------------------- # * Center camera on the player #-------------------------------------------------------------------------- def center(x, y) if !$game_switches[Scroll_game_switch] scroll_system_center(x,y) end end #-------------------------------------------------------------------------- # * Scroll_Moving? #-------------------------------------------------------------------------- def scroll_moving? if @real_x <= $game_map.display_x if @real_y != @y * 128 return true else return false end elsif @real_x >= $game_map.display_x + 640*4 - 128 if @real_y != @y * 128 return true else return false end else return moving? end end #-------------------------------------------------------------------------- # * Update #-------------------------------------------------------------------------- def update if $game_switches[Scroll_game_switch] last_moving = moving? unless scroll_moving? or $game_system.map_interpreter.running? or @move_route_forcing or $game_temp.message_window_showing case Input.dir4 when 2 move_down when 4 move_left when 6 move_right when 8 move_up end update_move end last_real_x = @real_x last_real_y = @real_y super unless moving? if last_moving result = check_event_trigger_here([1,2]) if result == false unless $DEBUG and Input.press?(Input::CTRL) if @encounter_count > 0 @encounter_count -= 1 end end end end if Input.trigger?(Input::C) check_event_trigger_here([0]) check_event_trigger_there([0,1,2]) end end else scroll_update end end #-------------------------------------------------------------------------- # * Update Move #-------------------------------------------------------------------------- def update_move if $game_switches[Scroll_game_switch] screen = [$game_map.display_x, $game_map.display_y, $game_map.display_x + 640*4 - 128, $game_map.display_y + 480*4 - 128] distance = 2 ** @move_speed if @y * 128 > @real_y @real_y = [[@real_y + distance, @y * 128].min, screen[3]].min @real_x = [[screen[0], @real_x].max,screen[2]].min if @real_y == screen[3] @y = @real_y / 128 end end if @x * 128 < @real_x @real_x = [[@real_x - distance, @x * 128].max, screen[0]].max @real_y = [[screen[1], @real_y].max,screen[3]].min if @real_x == screen[0] @x = @real_x / 128 end end if @x * 128 > @real_x @real_x = [[@real_x + distance, @x * 128].min, screen[2]].min @real_y = [[screen[1], @real_y].max,screen[3]].min if @real_x == screen[2] @x = @real_x / 128 end end if @y * 128 < @real_y @real_y = [[@real_y - distance, @y * 128].max, screen[1]].max @real_x = [[screen[0], @real_x].max,screen[2]].min if @real_y == screen[1] @y = @real_y / 128 end end if @walk_anime @anime_count += 1.5 elsif @step_anime @anime_count += 1 end else super end end #-------------------------------------------------------------------------- # * Update Stop #-------------------------------------------------------------------------- def update_stop super if $game_switches[Scroll_game_switch] screen = [$game_map.display_x, $game_map.display_y, $game_map.display_x + 640*4 - 128, $game_map.display_y + 480*4 - 128] @real_x = [[screen[0], @real_x].max,screen[2]].min @real_y = [[screen[1], @real_y].max,screen[3]].min end end end Jens I tried loking through the code, again I'm not nuch of a scripter, and I couldn't identify the exact spot where the code controls the screen movement, but...would it be possible to change the moving switch to a variable and then change the code to be just like how it is but with up, down, left and right sections for what the variable is set to? How much different is the up-scrolling code versus the right-scrolling code?
|
|
|
|
|
|
|
Posts in this topic
Claytonic Moving Screen help Jan 11 2013, 12:26 PM  Jens of Zanicuud QUOTE (Claytonic @ Jan 29 2013, 08:17 PM)... Jan 31 2013, 07:27 AM Claytonic Well my plan is to use it in an adventure game, so... Jan 18 2013, 12:28 PM Jens of Zanicuud Uhm... okay. I've got it. Of course, this woul... Jan 19 2013, 01:24 AM Claytonic sure thing, that's cool. no rush
Oh yeah, and... Feb 1 2013, 01:15 PM Redd I saw a script a while ago that would center the c... Feb 23 2013, 02:30 PM Claytonic QUOTE (Redd @ Feb 23 2013, 02:30 PM) I sa... Mar 3 2013, 10:12 PM Redd Like the scrolling levels in Super Mario Bros., ju... Mar 5 2013, 02:15 PM Claytonic QUOTE (Redd @ Mar 5 2013, 02:15 PM) Like ... Mar 8 2013, 10:07 AM  Jens of Zanicuud QUOTE (Claytonic @ Mar 8 2013, 07:07 PM) ... Mar 13 2013, 01:11 PM Claytonic Okay, upon reviewing my game library, I could not ... Mar 27 2013, 10:04 AM Jens of Zanicuud QUOTE (Claytonic @ Mar 27 2013, 07:04 PM)... Mar 28 2013, 03:34 AM  Claytonic QUOTE (Jens of Zanicuud @ Mar 28 2013, 04... Mar 28 2013, 07:44 AM   Jens of Zanicuud QUOTE (Claytonic @ Mar 28 2013, 04:44 PM)... Mar 29 2013, 04:32 AM    Claytonic QUOTE (Jens of Zanicuud @ Mar 29 2013, 05... Mar 29 2013, 10:08 AM     Jens of Zanicuud 1) Okay, this is good;
2) Crap, this is bad Passa... Mar 29 2013, 10:28 AM Claytonic Um, if you can make it so the player is dragged to... Mar 30 2013, 02:23 PM Jens of Zanicuud QUOTE (Claytonic @ Mar 31 2013, 12:23 AM)... Apr 2 2013, 07:33 AM Claytonic Where generally do passability issues come up? / W... Apr 2 2013, 10:02 AM
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
RPG RPG Revolution is an Privacy
Policy and Legal
|
|