PDA

View Full Version : Mouise Movement



peter
22-11-2013, 01:27
Hi,


Mouse movement in alpha stage.


Uses "ui"
#INCLUDE "abc.inc"
#INCLUDE "bass.inc"


DWord hdc, hwnd
hwnd = Canvas_Window("DRAW MOUSE",0,0,Width,Height)
Canvas_Attach(hwnd,0,%TRUE)


hdc = Canvas_GetDC()
SetHandleDC hdc, hwnd
SetFont 16,16,%FW_BOLD,""
InitBass


Long p1,p2
Single dx,dy,tx,ty,x,y,e
x=300:y=200:e=0.05


p1 = LoadBmp "bmp/back.bmp",1
p2 = LoadMusic "music/a.mod"


PlayMusic p2


While IsWindow(hwnd) And KeyDown(27)=0
AlphaBlend p1,0,0,width,height,25
tx=xMouse() -15
dx=tx-x
If Abs(dx) >1 Then
x += dx*e
End If
ty=yMouse -15
dy=ty-y
If Abs(dy) >1 Then
y += dy*e
End If
DrawCircle x, y, 40, 0, Rgb 253,237,229
DrawCircle x+10,y+10,20,0, Rgb 249,200,190
DrawCircle x+15,y+15,10,0, Rgb 246,170,128
Canvas_Redraw
Sleep 10
Wend
FreeGraphic
FreeBass
Canvas_Window End





Uses "ui"
#INCLUDE "abc.inc"
#DEFAULT BOUNDCHECK Off


DWord hdc, hwnd
hwnd = Canvas_Window("DRAW MOUSE", 0,0, 640,480)
Canvas_Attach(hwnd,0,%TRUE)


hdc = Canvas_GetDC()
SetHandleDC hdc, hwnd
SetFont 16,16,%FW_BOLD,""


Dim num(60) As Long
Dim mx (60) As Long
Dim my (60) As Long
Long frames, blue, index, n, i
frames=1 : n=60


blue = LoadBmp "bmp/back.bmp",1


While IsWindow(hwnd) And KeyDown(27)=0
AlphaBlend blue,0,0,640, 480,60
mx(frames) = xMouse()-30
my(frames) = yMouse()-30
For i=1 To n
index = Mod(frames+i,60)
DrawEllipse mx(index),my(index), i,i, 0, Rgb(255,255,255)
Next
frames +=1
If frames=60 Then frames=1
Canvas_Redraw
SetFps (160)
Wend
FreeGraphic
Canvas_Window End




Uses "ui"
#INCLUDE "abc.inc"


DWord hdc, hwnd
hwnd = Canvas_Window("ThinBasic",xMiddle(640),yMiddle(480),640,480)
Canvas_Attach(hwnd,0,%TRUE)


hdc = Canvas_GetDC()
SetHandleDC hdc, hwnd
SetFont 10,20,%FW_BOLD,""


Long mx,my,bm,bz
Single bv


bm = LoadBmp "bmp/batman.bmp",6


While IsWindow(hwnd)
Canvas_Clear 0


mx = xMouse
my = yMouse


DrawText 10,20, "xMouse " & mx, Rgb 255,255,255
DrawText 10,40, "yMouse " & my, Rgb 255,255,255
DrawText 20,100, "when you leave the screen,the mouse pointer ordinates get zero.", Rgb 200,200,248
DrawText 20,120, "and that in all direction", Rgb 200,200,248


DrawBmp bm,300,140,64,64,bz
DrawBmp bm,284,210,96,96,bz


bv +=.3
If bv >=1 Then
bv =0
bz +=1
If bz=6 Then bz=0
End If


Canvas_Redraw
Sleep 10
Wend


FreeGraphic
Canvas_Window End