Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! ruby -Ku
- #IME&衝突判定プログラム
- #作者 mireiyu
- require "kconv"
- require_relative "dxruby"
- $xpoint = 0
- $ypoint = 0
- $font = Font.new( 20,'HGP行書体')
- class Main_page
- def init
- Input::IME.enable=true
- @step = 0
- @step2 = 0
- @step3 = 0
- @step4 = 0
- @step5 = 0
- @imput_sprite = nil
- @player_image1 = Image.new( 20, 20, [255,255,255,255] )
- @player_image2 = Image.new( 20, 20, [255,66,66,255] )
- @player_sprite = Sprite.new( 320,240,@player_image1)
- @str = "あ"
- @image_font = Image.new( $font.getWidth(@str), 20, [66,66,66,66] )
- @image_font.draw_font(0, 0, @str, $font)
- @imput_sprite = Sprite.new( 100,100,@image_font)
- @player_sprite.center_x= 10
- @player_sprite.center_y= 10
- end
- def run
- t = Input::IME.get_comp_info
- x = 0
- sx = nil
- t.comp_str.each_char.with_index do |s, i|
- case t.comp_attr[i]
- when Input::IME::ATTR_INPUT # 入力中
- Window.draw_font(x, 24, s, $font)
- sx ||= x
- when Input::IME::ATTR_TARGET_CONVERTED # 選択されてて変換されてる
- Window.draw_font(x, 24, s, $font, color:C_YELLOW)
- sx ||= x
- when Input::IME::ATTR_CONVERTED # 選択されてなくて変換されてる
- Window.draw_font(x, 24, s, $font, color:C_RED)
- when Input::IME::ATTR_TARGET_NOTCONVERTED # 選択されてて変換されてない
- Window.draw_font(x, 24, s, $font, color:C_GREEN)
- sx ||= x
- end
- x += $font.get_width(s)
- end
- @str += Input::IME.get_string
- @image_font = Image.new( $font.getWidth(@str), 20, [66,66,66,66] )
- @image_font.draw_font(0, 0, @str, $font)
- @imput_sprite.image = @image_font
- end
- def render
- if @player_sprite.===(@imput_sprite) == true
- @player_sprite.image = @player_image2
- else
- @player_sprite.image = @player_image1
- end
- @imput_sprite.x = $xpoint
- @imput_sprite.y = $ypoint
- @imput_sprite.draw
- @player_sprite.draw
- @imput_sprite.update
- @player_sprite.update
- end
- def update
- @str = "あ" if Input.keyPush?(K_F1) and @str.length > 2
- if Input.keyPush?(K_F5)
- Window.windowed = false
- end
- if Input.keyPush?(K_F4)
- Window.windowed = true
- end
- end
- def exit
- if Input.keyPush?(K_ESCAPE) #ESCキー
- $end = true
- end
- end
- end
- module Main
- main_page = Main_page.new
- main_page.init
- Window.loop do
- $xpoint = Input.mousePosX
- $ypoint = Input.mousePosY
- main_page.run
- main_page.render
- main_page.update
- main_page.exit
- Window.draw_font(0, 460, "F1 To Reflesh Word", $font, color:C_RED)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement