赞 | 0 |
VIP | 0 |
好人卡 | 1 |
积分 | 1 |
经验 | 2446 |
最后登录 | 2016-9-12 |
在线时间 | 21 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 21 小时
- 注册时间
- 2011-8-22
- 帖子
- 13
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 lotsofone 于 2011-10-6 15:41 编辑
我做了一个在RMVX里玩动作游戏的脚本。可以用来做简单的动作类游戏,拥有显示文章、场所移动的功能。如果你想试试想试试效果,可以直接下载。
RASB V1.0.rar
(309.03 KB, 下载次数: 2268)
注意游戏有两关,第一关算是RMVX最简单的动作类游戏吧,就是在地图上有很多人追你,你要躲开,到达右边的出口。第二关才是真正的动作类游戏。
lotsofone于2011-8-28 10:56补充以下内容:
上游戏截图
第一关
第二关
使用教程:先新建一个事件,里面先输入:
公共事件:初始化- $scene = Scene_Action.new #进入动作游戏场景
复制代码 然后触发这个事件,就会发现你进入了动作游戏,但除了角色什么都没有。
如果在事件里输入
公共事件:初始化- $game_hard_thing[1] = [1,30,60,400,8]
复制代码- $scene = Scene_Action.new
复制代码 触发事件,你就会发现你右边有一块地板,然后你什么都没碰到就掉下去了。
首先我来解释$game_hard_thing[1] = [1,30,60,400,8]是什么意思。
“30”就是距离左边的距离,“60”是距离上面的距离,“400”是地板宽度,“8”是地板高度,下图会更直观。
怎么让角色站在地板上呢?
输入:
公共事件:初始化
变量操作:【0011:角色x】= 60- $game_hard_thing[1] = [1,30,60,400,8]
复制代码- $scene = Scene_Action.new
复制代码 角色x = 60 就是把角色右移了,如下图。
这次再触发事件,就能让角色站在地板上了,知道怎么做了吧,就这样做出复杂的游戏吧。
游戏复杂,可如果掉下去怎么办?那就永远不停地掉了。输入
公共事件:初始化
变量操作:【0011:角色x】= 60- $game_hard_thing[1] = [1,30,60,400,8]
复制代码- $game_soft_thing[1] = [1,-270,100,1000,8]
复制代码- $scene = Scene_Action.new
复制代码 $game_hard_thing是不可穿越的区域,而$game_soft_thing是可穿越的区域,一般做时间用。
$game_soft_thing[1] = [1,-270,100,1000,8]的“1”意思是指事件类型是1,1代表接触该事件立即死亡。
触发事件,就会发现下面加了一条长长的红色事件,这样掉下去就会死。
上面讲到事件类型为1时是立即死亡。为2时就是场所移动或出口。如果为2,后面就要加一些参数。
如果插如这一句- $game_soft_thing[2]=[2,50,-4,77,64,"end"]
复制代码 事件类型为2的时候,代表场所移动或通关,这个事件是一个门,在门的旁边按↓就可以进入。注意,此事件的参数的第3项和第4项必须为“77”和“64”。“end”代表是通关。如果写成“move”就是场所移动,可以移动到什么地方,不过又要多两个参数,如下。- $game_soft_thing[3]=[2,50,-4,77,64,"move",-100,100]
复制代码 至于它是什么意思,你们自己琢磨琢磨吧。全部都有教程,对脚本技术的提高没好处。
当事件类型为3时,什么意思和具体用法你们也自己琢磨琢磨,只要仔细看脚本编辑器里■Scene_Action的344到367行。自己研究脚本才是学习脚本最好的方法。
修正一个bug,在第一百五十几行有一个调试用的- if Kboard.press?($R_Key_A)
- p @touch[1],@touch[2],@touch[3],@touch[4]
- end
复制代码 使得任何时候按下a都会显示,所以在后面加上and $DEBUG
如果脚本出现改动,使下面的脚本与我上传的文件里的脚本不同,以下面的脚本为准。
2011-10-6更新- #==============================================================================
- # ■ Scene_Action
- #------------------------------------------------------------------------------
- # 处理游戏画面的类。
- #==============================================================================
- #$DEBUG = true #这一行可以调整
- class Scene_Action < Scene_Base
- def make_sure_date #数据
- @player_direction = 1
- @player_cartoon = 2
- @speed_x_abs_max = $game_variables[1]
- @player_jumping_skill = $game_variables[2]
- @ground_f = $game_variables[3]
- @thing_max = $game_hard_thing.size-1
- @event_max = $game_soft_thing.size-1
- @player_x = $game_variables[11]
- @player_y = $game_variables[12]
- @player_velocity_x = $game_variables[13]
- @player_velocity_y = $game_variables[14]
- @text1 = $game_variables[21]
- @text2 = $game_variables[22]
- @text3 = $game_variables[23]
- @text4 = $game_variables[24]
- @text1 = nil if $game_variables[21] == 0
- @text2 = nil if $game_variables[22] == 0
- @text3 = nil if $game_variables[23] == 0
- @text4 = nil if $game_variables[24] == 0
- @touch = []
- @cartoon_spend = 7
- @cartoon_comput = @cartoon_spend
- @dead_have_wait = 0
- @player_dead = false
- @player_width = 6
- @player_height = 32
- @passage1 = Window_Base.new(0,0,544,56)
- @passage1.opacity = 0
- @passage1.z = 20
- @passage2 = Window_Base.new(0,24,544,56)
- @passage2.opacity = 0
- @passage2.z = 20
- @passage3 = Window_Base.new(0,48,544,56)
- @passage3.opacity = 0
- @passage3.z = 20
- @passage4 = Window_Base.new(0,72,544,56)
- @passage4.opacity = 0
- @passage4.z = 20
- @passage_wait = 500
- passage
- end
-
- def start #开始包括:数据处理;生成视区;生成白底;生成元件;生成事件;生成角色
- make_sure_date
- create_viewports
- create_white_base
- create_things
- create_events
- create_player
- update_player
- end
- def create_viewports
- @viewport5 = Viewport.new(0, 0, 544, 416)
- @viewport10 = Viewport.new(0, 0, 544, 416)
- @viewport13 = Viewport.new(0, 0, 544, 416)
- @viewport15 = Viewport.new(0, 0, 544, 416)
- #~ @viewport20 = Viewport.new(0, 0, 544, 416)
- @viewport5.z = 5
- @viewport10.z = 10
- @viewport13.z = 13
- @viewport15.z = 15
- #~ @viewport20.z = 20
- end
- def create_white_base
- @white_base = Sprite.new(@viewport5)
- @white_base.bitmap = Bitmap.new("Graphics/System/白底")
- @white_base.src_rect = Rect.new(0,0,544,416)
- @white_base.x = 0
- @white_base.y = 0
- end
- def create_things
- @game_showing_thing = []
- for num in 1..@thing_max
- case $game_hard_thing[num][0]
- when 1
- @game_showing_thing[num] = Sprite.new(@viewport10)
- @game_showing_thing[num].bitmap = Bitmap.new("Graphics/System/事物")
- @game_showing_thing[num].x = $game_hard_thing[num][1]-@player_x+256
- @game_showing_thing[num].y = $game_hard_thing[num][2]-@player_y+192
- #@game_showing_thing[num].src_rect = Rect.new(0,0,$game_hard_thing[num][3],$game_hard_thing[num][4])
- @game_showing_thing[num].src_rect = Rect.new(0,0,1,1)
- @game_showing_thing[num].zoom_x = $game_hard_thing[num][3]
- @game_showing_thing[num].zoom_y = $game_hard_thing[num][4]
- else
-
- end
- end
- end
- def create_events
- @game_showing_event = []
- for num in 1..@event_max
- case $game_soft_thing[num][0]
- when 1
- @game_showing_event[num] = Sprite.new(@viewport13)
- @game_showing_event[num].bitmap = Bitmap.new("Graphics/System/死亡")
- @game_showing_event[num].x = $game_soft_thing[num][1]-@player_x+256
- @game_showing_event[num].y = $game_soft_thing[num][2]-@player_y+192
- @game_showing_event[num].src_rect = Rect.new(0,0,1,1)
- @game_showing_event[num].zoom_x = $game_soft_thing[num][3]
- @game_showing_event[num].zoom_y = $game_soft_thing[num][4]
- when 2
- @game_showing_event[num] = Sprite.new(@viewport13)
- @game_showing_event[num].bitmap = Bitmap.new("Graphics/System/场所移动或出口")
- @game_showing_event[num].x = $game_soft_thing[num][1]-@player_x+256
- @game_showing_event[num].y = $game_soft_thing[num][2]-@player_y+192
- @game_showing_event[num].src_rect = Rect.new(11,192,77,64)
- @game_showing_event[num].zoom_x = 1
- @game_showing_event[num].zoom_y = 1
- else
- @game_showing_event[num] = Sprite.new(@viewport13)
- if $DEBUG
- @game_showing_event[num].bitmap = Bitmap.new("Graphics/System/制作人调试用")
- else
- @game_showing_event[num].bitmap = Bitmap.new("Graphics/System/空白")
- end
- @game_showing_event[num].x = $game_soft_thing[num][1]-@player_x+256
- @game_showing_event[num].y = $game_soft_thing[num][2]-@player_y+192
- @game_showing_event[num].src_rect = Rect.new(0,0,1,1)
- @game_showing_event[num].zoom_x = $game_soft_thing[num][3]
- @game_showing_event[num].zoom_y = $game_soft_thing[num][4]
- end
- end
- end
- def create_player
- @showing_player = Sprite.new(@viewport15)
- @showing_player.bitmap = Bitmap.new("Graphics/Characters/Actor1")
- @showing_player.src_rect = Rect.new(32,0,32,32)
- @showing_player.x = 256
- @showing_player.y = 192
- end
-
- def update #画面更新包括:按下重置;接触重置;接触判断;按钮响应;地心引力;
- #角色移动;移动事物;移动事件;更新角色图像;事件响应;转到死亡场景计算
- #文章显示
- @have_moved = false
- @pressing_down = false
- touch_check_update
- touch_check_using
- key_pressing
- ground_f_comput
- player_truly_move
- move_thing
- move_event
- update_player
- map_event
- scene_dead_comput
- passage_wait
- if Kboard.press?($R_Key_A) and $DEBUG #这里需要■full kboard的支持,文件里有。
- p @touch[1],@touch[2],@touch[3],@touch[4]
- end
-
- end
- def touch_check_update
- @touch[1]=false
- @touch[2]=false
- @touch[3]=false
- @touch[4]=false
- end
- def touch_check_all
-
- end
- def touch_check_using
- touch_check_down if @player_velocity_y >= 0
- touch_check_up if @player_velocity_y <= 0
- touch_check_left if @player_velocity_x <= 0
- touch_check_right if @player_velocity_x >= 0
- end
- def touch_check_down
- for num in 1..@thing_max
- if $game_hard_thing[num][0]==1
- x = $game_hard_thing[num][1]
- y = $game_hard_thing[num][2]
- width = $game_hard_thing[num][3]
- height = $game_hard_thing[num][4]
- if @player_x+16+@player_width/2 >= x and @player_x+16-@player_width/2 <= x+width and @player_y+16+@player_height/2 >= y and @player_y+16+@player_height/2 < y+15
- @touch[1] = true
- @player_y = y-16-@player_height/2
- @player_velocity_y = 0 if @player_velocity_y >0
- return true
- end
- end
- end
- end
- def touch_check_left
- for num in 1..@thing_max
- if $game_hard_thing[num][0]==1
- x = $game_hard_thing[num][1]
- y = $game_hard_thing[num][2]
- width = $game_hard_thing[num][3]
- height = $game_hard_thing[num][4]
- if @player_y < y+height and @player_y+32 > y and @player_x+13 <= x+width and @player_x+13 > x+width-6
- @touch[2] = true
- @player_x = x+width-13
- @player_velocity_x = 0 if @player_velocity_x <0
- return true
- end
- end
- end
- end
- def touch_check_right
- for num in 1..@thing_max
- if $game_hard_thing[num][0]==1
- x = $game_hard_thing[num][1]
- y = $game_hard_thing[num][2]
- width = $game_hard_thing[num][3]
- height = $game_hard_thing[num][4]
- if @player_y < y+height and @player_y+32 > y and @player_x+32-13 >= x and @player_x+32-13 < x+6
- @touch[3] = true
- @player_x = x+13-32
- @player_velocity_x = 0 if @player_velocity_x >0
- return true
- end
- end
- end
- end
- def touch_check_up
- for num in 1..@thing_max
- if $game_hard_thing[num][0]==1
- x = $game_hard_thing[num][1]
- y = $game_hard_thing[num][2]
- width = $game_hard_thing[num][3]
- height = $game_hard_thing[num][4]
- if @player_x+32-13 > x and @player_x+13 < x+width and @player_y <= y+height and @player_y > y+height-15
- @touch[4] == true
- @player_y = y+height
- @player_velocity_y = 0 if @player_velocity_y < 0
- return true
- end
- end
- end
- end
- def key_pressing
- if @player_dead == true
- return true
- end
- case Input.dir8 #注意输出的是1,2,3,4,6,7,8,9
- when 0 #什么也不按
- if @touch[1]==true
- @player_velocity_x = 0
- @player_direction = 1
- end
- when 1 #左下
- if @touch[1]==true
- @player_velocity_x = -@speed_x_abs_max if @touch[2] == false
- @player_direction = 2
- @pressing_down = true
- end
- when 2 #下
- if @touch[1]==true
- @player_velocity_x = 0
- @player_direction = 1
- @pressing_down = true
- end
- when 3 #右下
- if @touch[1]==true
- @player_velocity_x = @speed_x_abs_max if @touch[3] == false
- @player_direction = 3
- @pressing_down = true
- end
- when 4 #左
- if @touch[1]==true
- @player_velocity_x = -@speed_x_abs_max if @touch[2] == false
- @player_direction = 2
- end
- when 6 #右
- if @touch[1]==true
- @player_velocity_x = @speed_x_abs_max if @touch[3] == false
- @player_direction = 3
- end
- when 7 #左上
- if @touch[1]==true
- @player_velocity_x = -@speed_x_abs_max if @touch[2] == false
- @player_velocity_y = -@player_jumping_skill
- @player_direction = 2
- end
- when 8 #上
- if @touch[1]==true
- @player_velocity_y = -@player_jumping_skill
- @player_velocity_x = 0
- @player_direction = 1
- end
- when 9 #右上
- if @touch[1]==true
- @player_velocity_x = @speed_x_abs_max if @touch[3] == false
- @player_velocity_y = -@player_jumping_skill
- @player_direction = 3
- end
- end
- end
- def ground_f_comput
- @player_velocity_y += @ground_f if @touch[1]==false
- end
- def player_truly_move
- @player_x += @player_velocity_x
- @player_y += @player_velocity_y
- end
- def move_thing
- for num in 1..@thing_max
- @game_showing_thing[num].x = $game_hard_thing[num][1]-@player_x+256
- @game_showing_thing[num].y = $game_hard_thing[num][2]-@player_y+192
- end
- end
- def move_event
- for num in 1..@event_max
- @game_showing_event[num].x = $game_soft_thing[num][1]-@player_x+256
- @game_showing_event[num].y = $game_soft_thing[num][2]-@player_y+192
- end
- end
- def update_player
- @cartoon_comput += 1
- @cartoon_comput = @cartoon_spend*2 if @touch[1]==false
- @cartoon_comput = @cartoon_spend if @player_velocity_x == 0
- if @cartoon_comput > 0 and @cartoon_comput <= @cartoon_spend
- @player_cartoon = 2
- elsif @cartoon_comput <= @cartoon_spend*2
- @player_cartoon = 3
- elsif @cartoon_comput <= @cartoon_spend*3
- @player_cartoon = 4
- elsif @cartoon_comput <= @cartoon_spend*4
- @player_cartoon = 1
- else
- @cartoon_comput = 1
- @player_cartoon = 2
- end
-
- x = @player_cartoon*32-32
- x = 32 if @player_cartoon == 4
- case @player_direction
- when 1
- y = 0
- when 2
- y = 32
- when 3
- y = 64
- end
-
- @showing_player.src_rect = Rect.new(x,y,32,32)
- end
- def map_event
- for num in 1..@event_max
- type = $game_soft_thing[num][0]
- x = $game_soft_thing[num][1]
- y = $game_soft_thing[num][2]
- width = $game_soft_thing[num][3]
- height = $game_soft_thing[num][4]
- if @player_x+13 < x+width and @player_x+32-13 > x and @player_y < y+height and @player_y+32 > y
-
- case type
- when 0
- return true #什么也不做,可以算做由于独立开关使事件消失。
- when 1 #立即死亡
- event_type_1
- when 2 #场所移动或出口
- @num = num
- event_type_2 if @player_dead == false and @have_moved == false
- when 3 #显示文章
- @num = num
- event_type_3 if @player_dead == false
- end
- end
- end
- end
- def event_type_1
- unless @player_dead == true
- @showing_player.dispose
- @showing_player = Sprite.new(@viewport15)
- @showing_player.bitmap = Bitmap.new("Graphics/Characters/Actor1-1dead")
- @showing_player.src_rect = Rect.new(32,0,32,32)
- @showing_player.x = 256
- @showing_player.y = 192
-
- @player_width = 32
- @player_height = 14
-
- if @player_direction == 2
- @showing_player.src_rect = Rect.new(32,64,32,32)
- @player_velocity_x = 4
- @player_velocity_y = -5
- @player_direction = 3
- else
- @showing_player.src_rect = Rect.new(32,32,32,32)
- @player_velocity_x = -4
- @player_velocity_y = -5
- @player_direction = 2
- end
- end
- @player_dead = true
- @viewport5.z = -4
- @viewport10.z = -3
- @viewport13.z = -2
- @viewport15.z = -1
- end
- def event_type_2
- if @pressing_down == true
- do_what = $game_soft_thing[@num][5]
- case do_what
- when "map"
- @viewport5.z = -4
- @viewport10.z = -3
- @viewport13.z = -2
- @viewport15.z = -1
- $scene = Scene_Map.new
- when "move"
- @have_moved = true
- Graphics.fadeout(20)
- @player_x = $game_soft_thing[@num][6]
- @player_y = $game_soft_thing[@num][7]
- move_thing
- move_event
- Graphics.update
- Graphics.fadein(20)
- when "end"
- passage_add("恭喜通关,感谢您的游戏。")
- Graphics.wait(100)
- Graphics.fadeout(200)
- Graphics.wait(20)
- $scene = Scene_Title.new
- else
- end
- end
- end
- def event_type_3
- do_what = $game_soft_thing[@num][5]
- $game_soft_thing[@num][0] = 0
- passage_add(do_what)
- end
- def scene_dead_comput
- @dead_have_wait += 1 if @player_dead == true
- if @player_dead == true
- @passage1.dispose unless @passage1.disposed?
- @passage2.dispose unless @passage2.disposed?
- @passage3.dispose unless @passage3.disposed?
- @passage4.dispose unless @passage4.disposed?
- end
- $scene = Scene_Gameover.new if @player_dead == true and (@touch[1] == true or @dead_have_wait >= 300)
- end
-
- def passage_wait
- @passage_wait -= 1
- if @passage_wait <= 0
- @passage_wait = 400
- @text1 = nil
- passage
- end
- end
- def passage_add(add_what)
- if @text4 == nil
- @text4 = add_what
- else
- @text1 = @text2
- @text2 = @text3
- @text3 = @text4
- @text4 = add_what
- end
- @passage_wait = 400
- passage
- end
- def passage
- @passage1.dispose unless @passage1.disposed?
- @passage2.dispose unless @passage2.disposed?
- @passage3.dispose unless @passage3.disposed?
- @passage4.dispose unless @passage4.disposed?
- a = [@text1, @text2, @text3, @text4]
- a.compact!
- @text1 = a[0]
- @text2 = a[1]
- @text3 = a[2]
- @text4 = a[3]
- #~ if @player_dead == true
- #~ return true
- #~ end
- @passage1 = Window_Base.new(0,0,544,56)
- @passage1.opacity = 0
- @passage2 = Window_Base.new(0,24,544,56)
- @passage2.opacity = 0
- @passage3 = Window_Base.new(0,48,544,56)
- @passage3.opacity = 0
- @passage4 = Window_Base.new(0,72,544,56)
- @passage4.opacity = 0
- @passage1.draw_action_text(@text1)
- @passage2.draw_action_text(@text2)
- @passage3.draw_action_text(@text3)
- @passage4.draw_action_text(@text4)
-
- end
-
- def pre_terminate #结束前处理
- #~ Graphics.fadeout(20)
- $game_variables[11] = @player_x
- $game_variables[12] = @player_y
- $game_variables[13] = @player_velocity_x
- $game_variables[14] = @player_velocity_y
- $game_variables[21] = @text1
- $game_variables[22] = @text2
- $game_variables[23] = @text3
- $game_variables[24] = @text4
- @passage1.z = -1 unless @passage1.disposed?
- @passage2.z = -1 unless @passage2.disposed?
- @passage3.z = -1 unless @passage3.disposed?
- @passage4.z = -1 unless @passage4.disposed?
- @viewport5.z = -4
- @viewport10.z = -3
- @viewport13.z = -2
- @viewport15.z = -1
- #~ @viewport5.dispose
- #~ @viewport10.dispose
- #~ @viewport13.dispose
- #~ @viewport15.dispose
- #~ @viewport20.dispose
- #~ @passage1.dispose unless @passage1.disposed?
- #~ @passage2.dispose unless @passage2.disposed?
- #~ @passage3.dispose unless @passage3.disposed?
- #~ @passage4.dispose unless @passage4.disposed?
- end
- end
复制代码 |
评分
-
查看全部评分
|