gsquare のコピーする四角形座標を動かせるようにしてみる

src_x_list = 50, 590, 590, 50
src_y_list = 50, 50, 430, 430

dest_x_list = 50, 590, 540, 100
dest_y_list = 50, 50, 430, 430

buffer 3
buffer 2
picload dir_exe+"/sample/hspcv/bgsamp.jpg"
screen 1
screen 0

dragging = -1, -1
prev_key = 0, 0

repeat
    gsel 3
        color 255, 255, 255 : boxf
        gsquare 2, dest_x_list, dest_y_list, src_x_list, src_y_list
    gsel 0
        copy_from = 2
        dup x_list, src_x_list
        dup y_list, src_y_list
        gosub *draw
    gsel 1
        copy_from = 3
        dup x_list, dest_x_list
        dup y_list, dest_y_list
        gosub *draw
    await 16
loop
stop

*draw
    redraw 0
    color 255, 255, 255 : boxf
    pos 0, 0
    gcopy copy_from, 0, 0, 640, 480
    getkey key
    key &= ginfo_sel == ginfo_act
    if key & prev_key.ginfo_sel == 0 {
        repeat 4
            dx = mousex - x_list.cnt
            dy = mousey - y_list.cnt
            if 10 * 10 >= dx * dx + dy * dy {
                dragging.ginfo_sel = cnt
                break
            }
        loop
    }
    if dragging.ginfo_sel >= 0 {
        if key {
            x_list(dragging.ginfo_sel) = mousex
            y_list(dragging.ginfo_sel) = mousey
        } else {
            dragging.ginfo_sel = -1
        }
    }
    color 255
    pos x_list.3, y_list.3
    repeat 4
        line x_list.cnt, y_list.cnt
    loop
    prev_key.ginfo_sel = key
    redraw
    return

インフォメーション

公開日時
2008年8月11日 午後10時54分20秒
最終更新日時
2008年8月11日 午後10時54分20秒
カテゴリ
HSP