playable mini OF

This commit is contained in:
CatWindow 2026-08-15 02:00:21 +03:00
parent 6d2a060f87
commit 7c9473cfee

View file

@ -12,6 +12,12 @@ class Scene_OF
ARROWS_SIDES_MARGIN = 48
ARROWS_SPEED = 10
ARROWS_ALLOW_ZONE_SIZE = 40
HP_WIDTH = 400
HP_HEIGHT = 16
MISS_TIME = 90
SPRITES = {
:cat_base_arrow_left => Rect.new(0, 0, 32, 32), :cat_base_arrow_down => Rect.new(32, 0, 32, 32), :cat_base_arrow_up => Rect.new(64, 0, 32, 32), :cat_base_arrow_right => Rect.new(96, 0, 32, 32),
@ -75,12 +81,16 @@ class Scene_OF
@voice_niko.start_frame = length / 3
@voice_niko.max_frame = length / 3 * 2
@miss_sound = Audio.create_sound("Audio/SE/shatter")
@viewport_ui = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport_arrows = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport_ui.ox = @viewport_arrows.ox = -Graphics.width / 2
@viewport_ui.oy = @viewport_arrows.oy = -Graphics.height / 2
@spritesheet = RPG::Cache.misc(".cats")
@cat_flying_arrows = []
@player_flying_arrows = []
@player_arrows = []
@cat_arrows = []
for i in 0..3
@ -101,11 +111,42 @@ class Scene_OF
@cat_arrows << cat_arrow
end
@simple_bitmap = Bitmap.new(1, 1)
@simple_bitmap.fill_rect(0, 0, 2, 2, Color.new(255, 255, 255))
@hp_bg = Sprite.new(@viewport_ui)
@hp_bg.bitmap = @simple_bitmap
@hp_bg.zoom_x = HP_WIDTH
@hp_bg.zoom_y = HP_HEIGHT
@hp_bg.modulate = Color.new(0, 12, 24)
@hp_bg.x = -HP_WIDTH / 2
@hp_bg.y = -HP_HEIGHT / 2 + Graphics.height / 2 - ARROWS_SIDES_MARGIN
@hp_blue = Sprite.new(@viewport_ui)
@hp_blue.bitmap = @simple_bitmap
@hp_blue.zoom_x = HP_WIDTH - 4
@hp_blue.zoom_y = HP_HEIGHT - 4
@hp_blue.modulate = Color.new(72, 73, 200)
@hp_blue.x = -HP_WIDTH / 2 - 2
@hp_blue.y = -HP_HEIGHT / 2 - 2 + Graphics.height / 2 - ARROWS_SIDES_MARGIN
@hp_blue.z = @hp_bg.z + 1
@hp_white = Sprite.new(@viewport_ui)
@hp_white.bitmap = @simple_bitmap
@hp_white.zoom_x = HP_WIDTH * 0.5 - 2
@hp_white.zoom_y = HP_HEIGHT - 4
@hp_white.x = -HP_WIDTH / 2 - 2
@hp_white.y = -HP_HEIGHT / 2 - 2 + Graphics.height / 2 - ARROWS_SIDES_MARGIN
@hp_white.z = @hp_bg.z + 2
@hp = 50
@bst_debug = Sprite.new(@viewport_ui)
@bst_debug.bitmap = Bitmap.new(300, 40)
@total_time = 0
@bump_timeout = 0
@miss_timeout = 0
make_mapping
@ -136,6 +177,8 @@ class Scene_OF
def update
@total_time += 1
@miss_timeout -= 1
@voice_niko.volume = @miss_timeout <= 0 ? 1.0 : 0.0
# fl studio b:s:t :3
beat = (@total_time / BPM_TIME / 2).to_i + 1
@ -145,7 +188,21 @@ class Scene_OF
@bst_debug.bitmap.clear
@bst_debug.bitmap.draw_text(Rect.new(0, 0, 300, 40), "#{beat} : #{step} : #{tick}")
@viewport_arrows.oy += ARROWS_SPEED
@cat_flying_arrows.each do |arrow|
arrow[0].y -= ARROWS_SPEED
if arrow[0].y < ARROWS_TOP_MARGIN - Graphics.height / 2
arrow[0].dispose
@cat_flying_arrows.delete(arrow)
end
end
@player_flying_arrows.each do |arrow|
arrow[0].y -= ARROWS_SPEED
if arrow[0].y < - Graphics.height / 2 - ARROW_SIZE * ARROW_SCALE
miss
arrow[0].dispose
@player_flying_arrows.delete(arrow)
end
end
@bump_timeout -= 1
if @bump_timeout <= 0
@ -165,9 +222,46 @@ class Scene_OF
@player_arrows[mapped].bitmap.clear
@player_arrows[mapped].bitmap.stretch_blt(Rect.new(0, 0, ARROW_SIZE, ARROW_SIZE), @spritesheet, SPRITES[PLAYER_ARROWS_SPRITES[@arrows_states[mapped] ? :pressed : :base][mapped]])
end
if Input.trigger?(i * 2)
doing = true
i = 0
while doing && i < @player_flying_arrows.length
arrow = @player_flying_arrows[i]
if arrow[1] == mapped
if arrow[0].y > ARROWS_TOP_MARGIN - Graphics.height / 2 - ARROWS_ALLOW_ZONE_SIZE
if arrow[0].y < ARROWS_TOP_MARGIN - Graphics.height / 2 + ARROWS_ALLOW_ZONE_SIZE
arrow[0].dispose
@player_flying_arrows.delete(arrow)
self.hp += 5
@miss_sound.stop
@miss_timeout = 0
else
miss
end
doing = false
end
end
i += 1
end
end
end
end
def miss
self.hp -= 10
@miss_sound.play(0, 0.6, rand(75..125) / 100.0)
@miss_timeout = MISS_TIME
end
def hp
@hp
end
def hp=(val)
@hp = val.clamp(0, 100)
@hp_white.zoom_x = (HP_WIDTH - 4) * (100 - @hp) / 100.0
end
def map_input(input)
case input
when 2
@ -200,7 +294,18 @@ class Scene_OF
(step - 1) / 15.0 * 2 * BPM_TIME * ARROWS_SPEED +
(tick) / 24.0 / 15.0 * 2 * BPM_TIME * ARROWS_SPEED
@cat_flying_arrows << arrow
@cat_flying_arrows << [arrow, i]
end
if line_data[0][i + 5] == '#'
arrow = make_arrow(i, false)
arrow.x = Graphics.width / 2 - ARROWS_SIDES_MARGIN + (ARROW_SIZE * ARROW_SCALE + ARROWS_PADDING) * i - (ARROW_SIZE * ARROW_SCALE * 4 + ARROWS_PADDING * 3)
arrow.y = ARROWS_TOP_MARGIN - Graphics.height / 2 +
(beat - 1) * 2 * BPM_TIME * ARROWS_SPEED +
(step - 1) / 15.0 * 2 * BPM_TIME * ARROWS_SPEED +
(tick) / 24.0 / 15.0 * 2 * BPM_TIME * ARROWS_SPEED
@player_flying_arrows << [arrow, i]
end
end
end
@ -215,17 +320,59 @@ class Scene_OF
end
SONG_MAPPING = [
#arrows, B, S, T
["# | ", 5, 1, 0],
[" # | ", 5, 3, 0],
[" # | ", 5, 5, 0],
[" #| ", 5, 9, 0],
[" # | ", 5, 13, 0],
["# | ", 6, 1, 0],
[" # | ", 6, 3, 0],
[" # | ", 6, 5, 0],
[" # | ", 6, 9, 0],
["# | ", 6, 13, 0],
# arrows, B, S, T
["# | ", 5, 1, 0],
[" # | ", 5, 3, 0],
[" # | ", 5, 5, 0],
[" #| ", 5, 9, 0],
[" # | ", 5, 13, 0],
["# | ", 6, 1, 0],
[" # | ", 6, 3, 0],
[" # | ", 6, 5, 0],
[" # | ", 6, 9, 0],
["# | ", 6, 13, 0],
[" # | ", 7, 1, 0],
[" #| ", 7, 3, 0],
[" # | ", 7, 5, 0],
["# | ", 7, 9, 0],
["# | ", 7, 13, 0],
["# | ", 8, 1, 0],
[" # | ", 8, 3, 0],
[" # | ", 8, 6, 0],
[" # | ", 8, 8, 0],
[" # | ", 8, 11, 0],
[" #| ", 8, 13, 0],
[" |# ", 9, 1, 0],
[" | # ", 9, 3, 0],
[" | # ", 9, 5, 0],
[" | #", 9, 9, 0],
[" | # ", 9, 13, 0],
[" |# ", 10, 1, 0],
[" | # ", 10, 3, 0],
[" | # ", 10, 5, 0],
[" | # ", 10, 9, 0],
[" |# ", 10, 13, 0],
[" | # ", 11, 1, 0],
[" | #", 11, 3, 0],
[" | # ", 11, 5, 0],
[" |# ", 11, 9, 0],
[" |# ", 11, 13, 0],
[" |# ", 12, 1, 0],
[" | # ", 12, 3, 0],
[" | # ", 12, 5, 0],
[" | # ", 12, 6, 0],
[" | # ", 12, 7, 0],
[" | # ", 12, 8, 0],
[" | # ", 12, 9, 0],
[" | #", 12, 10, 0],
[" | # ", 12, 11, 0],
[" |# ", 12, 13, 0],
[" |# ", 12, 15, 0],
#[" |# ", 12, 15, 12],
[" |# ", 12, 16, 0],
#[" |# ", 12, 16, 12],
[" |# ", 13, 1, 0],
]
end