; このブログのコードはコピペだと正常に動作しません。
; mod_smart-37.zip の sample-smart_analog_4.hsp を読み込んで実行してください。
#cmpopt varinit 1
#include "hsp3dish.as"
#include "mod_smart.as"
//--------------------------------------------------------------------------------------------
#const SCREEN_WIDTH_SIZE 320
#const SCREEN_HEIGHT_SIZE 480
#const SCREEN_WIDTH_CENTER SCREEN_WIDTH_SIZE / 2
#const SCREEN_HEIGHT_CENTER SCREEN_HEIGHT_SIZE / 2
;---------------------------
#const BUTTON_FIRST_TAP 0
#const BUTTON_ANALOG_STICK 1
;--------------------------- タップ関係
#const TAP_DETOUCH 0 ; タップされてない
#const TAP_TOUCH 1 ; タップされている
#const TAP_TOUCH_FINISH 2 ; タップ終了
#const TAP_DOUBLE 3 ; ダブルタップ
//--------------------------------------------------------------------------------------------
*mod_smart_initialize
smart_init
smart_add : act_num(BUTTON_FIRST_TAP) = stat
smart_add : act_num(BUTTON_ANALOG_STICK) = stat
//--------------------------------------------------------------------------------------------
*hensu_initialize
act_first_tap_stat = TAP_DETOUCH
touch_x = 0
touch_y = 0
scroll_x = 0.0
scroll_y = 0.0
me_move_spd = 50
//--------------------------------------------------------------------------------------------
*setcls_initialize
setcls CLSMODE_SOLID, $000000
//--------------------------------------------------------------------------------------------
*main
repeat
redraw 0
gosub *get_tap
gosub *put_me
redraw 1
await 16
loop
//--------------------------------------------------------------------------------------------
*get_tap
color 0, 0, 255
boxf SCREEN_WIDTH_CENTER - 5 + scroll_x, SCREEN_HEIGHT_CENTER - 5 + scroll_y, SCREEN_WIDTH_CENTER + 5 + scroll_x, SCREEN_HEIGHT_CENTER + 5 + scroll_y
act_first_tap_stat = smart_one(act_num(BUTTON_FIRST_TAP), 0, 0, SCREEN_WIDTH_SIZE, SCREEN_HEIGHT_SIZE)
if act_first_tap_stat == TAP_TOUCH {
touch_x = smart_getx()
touch_y = smart_gety()
}
dim analog, 10
smart_analog act_num(BUTTON_ANALOG_STICK), analog, touch_x, touch_y, SCREEN_HEIGHT_SIZE
if analog(0) {
if analog(3) != 0 {
rad_waru_100man = double(analog(8)) / 1000000 ; 角度(ラジアン)/100万
add_x = (cos(rad_waru_100man) * me_move_spd) ; X移動量取得
add_y = (sin(rad_waru_100man) * me_move_spd) ; Y移動量取得
scroll_x += add_x
scroll_y += add_y
}
}
return
//--------------------------------------------------------------------------------------------
*put_me
color 255, 0, 0
circle touch_x - 10, touch_y - 10, touch_x + 10, touch_y + 10
return