PDA

View Full Version : Black Rain



peter
14-10-2012, 19:53
Hi,

A little bit rain.


Uses "ui"


DWord hdc,hwin
hwin=Canvas_Window("Black Rain",1,1,640,480)
Canvas_Attach(hwin,0,%TRUE)
Canvas_Font("georgia",18,%CANVAS_FONTSTYLE_BOLD)
Randomize


Dim x(500),y(500),z(500) As Long
Long i,mx,m


For i=1 To 500
x(i)=Rnd(1,640)
y(i)=Rnd(1,460)
z(i)=Rnd(1,3)
Next


While IsWindow(hwin)
Canvas_BitmapRender("rainbow.bmp",0,0,640,480)


For i=1 To 500
y(i)=y(i)+z(i)
If y(i) >480 Then
x(i)=Rnd(1,649)
y(i)=1
z(i)=Rnd(1,3)
End If
Canvas_Circle(x(i),y(i),2,0)
Next


Canvas_Redraw
If GetAsyncKeyState(27) Then Exit While
Wend
Canvas_Window End

ErosOlmi
15-10-2012, 12:24
Very nice peter.

While you are posting those nice examples, I'm working in the background to add more functionalities to Canvas control and Window.
Very soon (hope by end of this week) a new thinBasic beta version.

omarpta
15-10-2012, 17:32
Really Very Nice!
And very nice to know that thinbasic beta release is close...
Thanks

peter
15-10-2012, 20:05
Great Eros!


Don't forget the Mouse handling!
Might be : xMouse, yMouse, MouseButton(1) (2) (3), where 1 is left, 2 right, 3 middle.


Without Mouse is canvas lifelessly.

peter
15-10-2012, 20:07
Thank you omarpta!

ErosOlmi
15-10-2012, 21:25
Don't forget the Mouse handling!
Might be : xMouse, yMouse, MouseButton(1) (2) (3), where 1 is left, 2 right, 3 middle.
Without Mouse is canvas lifelessly.

petr,

Usually the best way to handle mouse events is creating a canvas control over a standard window and handle Windows events. Than place your main loop inside a timer event without looping but letting the timer do the job.

But in the meantime, can you please check example here: http://www.thinbasic.com/community/showthread.php?11079-clicking-on-Geometry-Figures&p=82814&viewfull=1#post82814
There is a source called DragnDropDemo.tBasic (http://www.thinbasic.com/community/attachment.php?attachmentid=7107&d=1300967520)
Inside there is a function called GWInMouse.

I something like that that you need?

Let me know.

peter
16-10-2012, 13:39
Hi Eros,

No, isn't what I need.
I have some other ideas. I have to experiment!


Thank you for your effort.