Drawing things
-
-
I need to draw a Equilateral triangle, and also rotate it and bounce it off the screen, i have seem this done before, but i dont know ehere to start, any help in pointing me in the right direction, and any code samples would be nice Thanx Matt
I don't have time to do the details... but, to give you a clue: What you need to do is host the directx7 library by making a 'reference (via the object browser) first, even though the machines use DX8 'cause thats where direct draw is, OK? In your code you'll have to: option explicit Private MyDX7 as NEW vbDXlib.DirectX7 Private MyDirectDraw as vbDXlib.DirectDraw7 sub Form1_OnLoad() set MyDirectDraw = MyDX7.DreateDirectDraw7 yadda...yadda..yadda... the trick is that DX7 HAS to be created 'as new' THEN you get DirectDraw (in-directly) :) which you then use some UserDefinedTypes (UDT's) to initialize a 'primary_surface' and the 1st 'offscreen_surface'. All this just to get a page flippin scheme so your stuff draws REAL_FAST... before you call your bitmap (of any shape you desire) into a 2nd 'offscreen_surface' using: MyDirectDraw.CreateSurfaceFromFile(bla,bla,bla) -which is a holder in memory for your 'sprite' as some call would say. You then use DirectDraw's super cool graphics methods to paint rotated versions of the sprite (to the current degree) on a 4th 'offscreen_surface' before dumping that 4th surface to the 1st 'offscreen' surface, so that the picture will be there when the 'Form1_repaint' is called by the Operating_Sys or your animating timer control's ticker event.... Get the DirectX8 sdk and look at the vb-Billboard sample. Really, it shows you exactly what you are trying to do 'cept they made their whirly-gig go in a circle. You'll have to do the bouncing yourself, but the hard parts will be taken care of. You'll be pleasently supprised with the performance, even on a 200mmx or so you could get >45 fps especially if you have a flat color (black?) background so you don't have to clip. PS: Try using this basic structure for gradient backgrounds, use a 128x128 bitmap created in say... ulead photoImpact's magic gradient (they have a 30 day demo for free) or other graphics package. That size is great 'cause you won't see ANY pixel lines even when the form streches it full screen, unlike the windows desktop... and it re-paints faster than you can do a loop! »geeky ain't I... :) CodeCrafty® nauhaus@swbell.net
-
I don't have time to do the details... but, to give you a clue: What you need to do is host the directx7 library by making a 'reference (via the object browser) first, even though the machines use DX8 'cause thats where direct draw is, OK? In your code you'll have to: option explicit Private MyDX7 as NEW vbDXlib.DirectX7 Private MyDirectDraw as vbDXlib.DirectDraw7 sub Form1_OnLoad() set MyDirectDraw = MyDX7.DreateDirectDraw7 yadda...yadda..yadda... the trick is that DX7 HAS to be created 'as new' THEN you get DirectDraw (in-directly) :) which you then use some UserDefinedTypes (UDT's) to initialize a 'primary_surface' and the 1st 'offscreen_surface'. All this just to get a page flippin scheme so your stuff draws REAL_FAST... before you call your bitmap (of any shape you desire) into a 2nd 'offscreen_surface' using: MyDirectDraw.CreateSurfaceFromFile(bla,bla,bla) -which is a holder in memory for your 'sprite' as some call would say. You then use DirectDraw's super cool graphics methods to paint rotated versions of the sprite (to the current degree) on a 4th 'offscreen_surface' before dumping that 4th surface to the 1st 'offscreen' surface, so that the picture will be there when the 'Form1_repaint' is called by the Operating_Sys or your animating timer control's ticker event.... Get the DirectX8 sdk and look at the vb-Billboard sample. Really, it shows you exactly what you are trying to do 'cept they made their whirly-gig go in a circle. You'll have to do the bouncing yourself, but the hard parts will be taken care of. You'll be pleasently supprised with the performance, even on a 200mmx or so you could get >45 fps especially if you have a flat color (black?) background so you don't have to clip. PS: Try using this basic structure for gradient backgrounds, use a 128x128 bitmap created in say... ulead photoImpact's magic gradient (they have a 30 day demo for free) or other graphics package. That size is great 'cause you won't see ANY pixel lines even when the form streches it full screen, unlike the windows desktop... and it re-paints faster than you can do a loop! »geeky ain't I... :) CodeCrafty® nauhaus@swbell.net
Want something fast mail me(cemkalyoncu@yahoo.com). DirectX has too many depencies but if you use GDI effectively you will increase speed(setdibits API:)).
-
I don't have time to do the details... but, to give you a clue: What you need to do is host the directx7 library by making a 'reference (via the object browser) first, even though the machines use DX8 'cause thats where direct draw is, OK? In your code you'll have to: option explicit Private MyDX7 as NEW vbDXlib.DirectX7 Private MyDirectDraw as vbDXlib.DirectDraw7 sub Form1_OnLoad() set MyDirectDraw = MyDX7.DreateDirectDraw7 yadda...yadda..yadda... the trick is that DX7 HAS to be created 'as new' THEN you get DirectDraw (in-directly) :) which you then use some UserDefinedTypes (UDT's) to initialize a 'primary_surface' and the 1st 'offscreen_surface'. All this just to get a page flippin scheme so your stuff draws REAL_FAST... before you call your bitmap (of any shape you desire) into a 2nd 'offscreen_surface' using: MyDirectDraw.CreateSurfaceFromFile(bla,bla,bla) -which is a holder in memory for your 'sprite' as some call would say. You then use DirectDraw's super cool graphics methods to paint rotated versions of the sprite (to the current degree) on a 4th 'offscreen_surface' before dumping that 4th surface to the 1st 'offscreen' surface, so that the picture will be there when the 'Form1_repaint' is called by the Operating_Sys or your animating timer control's ticker event.... Get the DirectX8 sdk and look at the vb-Billboard sample. Really, it shows you exactly what you are trying to do 'cept they made their whirly-gig go in a circle. You'll have to do the bouncing yourself, but the hard parts will be taken care of. You'll be pleasently supprised with the performance, even on a 200mmx or so you could get >45 fps especially if you have a flat color (black?) background so you don't have to clip. PS: Try using this basic structure for gradient backgrounds, use a 128x128 bitmap created in say... ulead photoImpact's magic gradient (they have a 30 day demo for free) or other graphics package. That size is great 'cause you won't see ANY pixel lines even when the form streches it full screen, unlike the windows desktop... and it re-paints faster than you can do a loop! »geeky ain't I... :) CodeCrafty® nauhaus@swbell.net
"As New" has no speed benefit and it can actually be dangerous in some cases. Declaring the variable and then using "Set x = New Y" is exactly the same thing and is a better coding practice. What you're trying to explain here (I think) is that late binding (Dim x As Object) is far slower than early binding or semi-late binding. ___________ Klaus [www.vbbox.com]