Moving Screen help, like an overhead scrolling shooter |
|
|
|
|
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?
|
|
|
|
|
|
|
|
|
Jan 31 2013, 07:27 AM
|

Dark Jentleman

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

|
QUOTE (Claytonic @ Jan 29 2013, 08:17 PM)  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? The Up-Scrolling isn't too much difficult to implement, but I'm in a bad period and I can't script it right now. If you can wait till March, I'll give it a look. Jens
__________________________
|
|
|
|
|
|
|
|
|
Mar 3 2013, 10:12 PM
|

Level 2

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

|
QUOTE (Redd @ Feb 23 2013, 02:30 PM)  I saw a script a while ago that would center the camera on the player at all times... like a Pokemon game. I can't seem to find it right now, but is that what you are asking for? Actually, I want sort of the opposite of that. I want the screen to slowly move on its own while the player is restricted to moving around inside the "on-screen" area, so the camera would have to not follow the player at all. Instead, the player is forced to follow the camera.
|
|
|
|
|
|
|
|
|
Mar 8 2013, 10:07 AM
|

Level 2

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

|
QUOTE (Redd @ Mar 5 2013, 02:15 PM)  Like the scrolling levels in Super Mario Bros., just upwards instead? Yes, rather, over-head instead. Changing the direction at a point in the dungeon would be cool too. I swear I've played a game that does this but I can't think of it....
|
|
|
|
|
|
|
|
|
Mar 13 2013, 01:11 PM
|

Dark Jentleman

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

|
QUOTE (Claytonic @ Mar 8 2013, 07:07 PM)  QUOTE (Redd @ Mar 5 2013, 02:15 PM)  Like the scrolling levels in Super Mario Bros., just upwards instead? Yes, rather, over-head instead. Changing the direction at a point in the dungeon would be cool too. I swear I've played a game that does this but I can't think of it.... Okay, I've got the problem. You need a script which could bind the player (i.e. the player is moved by the screen bounds, if it remains still - right?) but there are a couple problems. First off, RMXP implements a tile system which actually greatly reduces free movement. In practice, if you tell the program "hey, I want you to force my lil' player to move by three pixels" this won't work unless you modify the whole system. Second, I need some more detail. What kind of game is this supposed to be? A platform or a sort of Gradius-side-scroller? I'll see what I can do. Jens
__________________________
|
|
|
|
|
|
|
|
|
Mar 28 2013, 03:34 AM
|

Dark Jentleman

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

|
QUOTE (Claytonic @ Mar 27 2013, 07:04 PM)  Okay, upon reviewing my game library, I could not find an example of what I visualized.... What this game is going to be is a sort of overhead action game. I'm starting to think binding the player to the screen will not be necessary(close walls and other things can do that). What I want is to be able to control a moving camera and not have it center on the player while he is moving around the level (this is to keep the player moving through the level at a specified pace, not going back for anything he misses). Do you need a "every-direction-screen-movement" or is there a precise direction the game is developed to? Jens
__________________________
|
|
|
|
|
|
|
|
|
Mar 29 2013, 04:32 AM
|

Dark Jentleman

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

|
QUOTE (Claytonic @ Mar 28 2013, 04:44 PM)  QUOTE (Jens of Zanicuud @ Mar 28 2013, 04:34 AM)  Do you need a "every-direction-screen-movement" or is there a precise direction the game is developed to?
Jens Yes, I want it in every direction.  Okay, let's put it fair and square: the script isn't the most easy, since RMXP tilesets structure. I need a couple more pieces of information: >first of all, I need to know how the game camera is placed: is it a classic RPG (seen from above, as RMXP standard) or a platform game like any SuperMario? In the latter case, I could get rid of the tileset structure and design another system; >second, in case the game is seen from above, should I proceed anyway and get rid of the tileset structure (free movement , instead of that 32 pixels move - some passability issues)? >third, has the player to be "dragged" from the screen? (i.e. if the charcter is placed on the left side and the screen is moving right, should the screen drag the player with it?) Sorry for the huge number of questions, but I can't properly design it without these pieces of information  Jens
__________________________
|
|
|
|
|
|
|
|
|
Mar 29 2013, 10:08 AM
|

Level 2

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

|
QUOTE (Jens of Zanicuud @ Mar 29 2013, 05:32 AM)  Okay, let's put it fair and square: the script isn't the most easy, since RMXP tilesets structure. I need a couple more pieces of information: >first of all, I need to know how the game camera is placed: is it a classic RPG (seen from above, as RMXP standard) or a platform game like any SuperMario? In the latter case, I could get rid of the tileset structure and design another system; >second, in case the game is seen from above, should I proceed anyway and get rid of the tileset structure (free movement , instead of that 32 pixels move - some passability issues)? >third, has the player to be "dragged" from the screen? (i.e. if the charcter is placed on the left side and the screen is moving right, should the screen drag the player with it?) Sorry for the huge number of questions, but I can't properly design it without these pieces of information  Jens Not at all, I'm asking for help so it is best that you know what I want help with. 1) It will be overhead, seen from above, classic rpg style. 2) Free movement would be best so feel free to get rid of the tileset structure. 3) Dragging the character along is not necessary, but not bad if possible. Also, I want to be able to disable/enable it per dungeon (the screen moving part, keep the free movement at all times).
|
|
|
|
|
|
|
|
|
Mar 29 2013, 10:28 AM
|

Dark Jentleman

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

|
1) Okay, this is good; 2) Crap, this is bad  Passability issues ahead! (I'll see what I can do) 3) What if the screen doesn't drag the player? Is the player supposed to follow the screen, to die when the screen overcomes him, or simply the screen is supposed to stop if the player is on one of their sides? I'll begin working on it once I'll be supplied with this last info  Jens
__________________________
|
|
|
|
|
|
|
|
|
Apr 2 2013, 07:33 AM
|

Dark Jentleman

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

|
QUOTE (Claytonic @ Mar 31 2013, 12:23 AM)  Um, if you can make it so the player is dragged to be kept on screen, that would be amazing. Again, I don't know the technical problems you run into when scripting so I don't know which is easier, but another idea for back-up is if the player goes off screen then they are teleported to the center of the screen (maybe after being gone for three seconds?). I don't want the screen to stop and wait for the player. Alright  I'll see what I can do. Jens
__________________________
|
|
|
|
|
|
|
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
RPG RPG Revolution is an Privacy
Policy and Legal
|
|