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