Post by hartnell on Nov 4, 2006 12:36:37 GMT -5
Here's my mouse library so far. It does mouse hit, mouse down, mouse released, lock, unlock, and wait. It's all based off the left mouse button for now.
If theres anything you want me to include in this, let me know.
Also, this is straight out of the ide, so it's a mess.
-hartnell
If theres anything you want me to include in this, let me know.
Also, this is straight out of the ide, so it's a mess.
graphics.Initialize
key.Initialize
mouse.Initialize
' virtual keycodes
' short versions included on purpose
const vk_window_x = 0
const vk_wx = 0
const vk_escape = 1
const vk_esc = 1
const vk_1 = 2
const vk_2 = 3
const vk_3 = 4
const vk_4 = 5
const vk_5 = 6
const vk_6 = 7
const vk_7 = 8
const vk_8 = 9
'? 9 = 10
'? 0 = 11
const vk_minus = 12
const vk_min = 12
const vk_equals = 13
const vk_equ = 13
const vk_backspace = 14
const vk_bsp = 14
const vk_tab = 15
const vk_q = 16
const vk_w = 17
const vk_e = 18
const vk_r = 19
const vk_t = 20
const vk_y = 21
const vk_u = 22
const vk_i = 23
const vk_o = 24
const vk_p = 25
const vk_left_bracket = 26
const vk_lbr = 26
const vk_right_bracket = 27
const vk_rbr = 27
const vk_return = 28
const vk_enter = 28
const vk_ret = 28
const vk_ent = 28
const vk_left_control = 29
const vk_lcn = 29
const vk_a = 30
const vk_s = 31
const vk_d = 32
const vk_f = 33
const vk_g = 34
const vk_h = 35
const vk_j = 36
const vk_k = 37
const vk_l = 38
const vk_semicolon = 39
const vk_scl = 39
const vk_apostrophe = 40
const vk_aps = 40
const vk_grave = 41
const vk_grv = 41
const vk_tilde = 41
const vk_tld = 41
const vk_left_shift = 42
const vk_lsh = 42
const vk_backslash = 43
const vk_bsl = 43
const vk_z = 44
const vk_x = 45
const vk_c = 46
const vk_v = 47
const vk_b = 48
const vk_n = 49
const vk_m = 50
const vk_comma = 51
const vk_com = 51
const vk_period = 52
const vk_prd = 52
const vk_slash = 53
const vk_slh = 53
const vk_right_shift = 54
const vk_rsh = 52
const vk_multiply = 55
const vk_mul = 55
const vk_left_alt =56
const vk_lalt = 56
const vk_space = 57
const vk_spc = 57
class mouse_tp
public lb_hit
public lb_last
public lb_down
public lb_released
public lb_locked
public waiting
public sub init()
lb_last = 0
lb_hit = 0
lb_down = 0
lb_released = 0
lb_locked = 0
waiting = 0
end sub
public sub update()
if lb_locked = 0 then
lb_last = lb_down
lb_hit = 0
lb_down = 0
lb_pressed = 0
lb_released = 0
lb_down = mouse.LeftButton
if lb_down and not lb_last then lb_hit = 1
if not lb_down and lb_last then lb_released = 1
end if
end sub
sub lb_lock()
lb_locked = 1
end sub
sub lb_unlock()
lb_locked = 0
end sub
sub wait()
waiting = 1
do while waiting
if mouse.LeftButton then waiting = 0
system.Pause 1
loop
end sub
end class
dim supermouse
Set supermouse = New mouse_tp
supermouse.init()
Dim font
font = graphics.CreateFont("system",10)
dim blarg
blarg = ""
supermouse.wait
graphics.SetText "done" ,100,120,font
do while not key.Pressed(vk_esc) and not key.Pressed(vk_wx)
graphics.Clear
supermouse.update()
if supermouse.lb_down then blarg = blarg + "o"
graphics.SetText blarg ,100,100,font
graphics.Display
loop
graphics.Terminate
key.Terminate
mouse.Terminate
-hartnell