|
-
Oct 1st, 2000, 02:21 PM
#1
hi all.....
similar to my previous thread.....can someone help me with the code that will give the impression of moving down a tunnel (either square or round)
thanks
john
-
Oct 2nd, 2000, 02:20 PM
#2
Frenzied Member
Sorry that I don't have code for you...this may be a little complicated to do (is for me) but, it sounds like you just need a starfield just altered...
-
Oct 2nd, 2000, 06:25 PM
#3
Frenzied Member
Hi
You mean a cool tunnel effect like the 3D tunnel shipped with the DX sdk?
Or just one like in those old games?
Just making circls getting smaller and smaller?
and make them bigger so it appears to move?
(the second one is very easy!)
Sanity is a full time job
Puh das war harter Stoff!
-
Oct 3rd, 2000, 03:17 PM
#4
reply
hi...well i saw a graphics prog sometime back and it had a big square drawn full screen size.it then drew another one slightly smaller spaced about 5mm and then another...and so on.once the animation was run...its gave an impressive tunnel like effect.
can you help me by starting the code and i,ll finish it off
thanks
john
-
Oct 3rd, 2000, 05:41 PM
#5
Frenzied Member
I never tried this but it seems very easy to me, I just write some strange code in here, jsut as idea, you can put i to real code
I don't think there is a funciton drawrect, but you know what I mean
x1 =0
x2 =600
y1 =0
y2 =600
do
drawrect x1,y1,x2,y2
x1=x1+2
x2=x2-2
y1=y1+2
y2=y2-2
loop
Sanity is a full time job
Puh das war harter Stoff!
-
Oct 3rd, 2000, 10:08 PM
#6
Hyperactive Member
Ugly but will start you off I think
Here you go. It's slow, ugly and altogether useless I would think...
Code:
' on a form with a picturebox, command button, text box and timer controls
Option Explicit
Dim border As Integer
Dim Closing As Boolean
Dim r As Single
Dim colors(15) As Long
Private Sub Command2_Click()
border = Text1
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
border = 10
Timer1.Enabled = False
With Picture1
.AutoRedraw = True
.DrawWidth = border
.ScaleMode = 3
r = .ScaleHeight / .ScaleWidth
End With
' initialise shades of grey
Dim c As Integer
colors(0) = RGB(255, 255, 255)
For c = 1 To 15
colors(c) = RGB(255 - c * 10, 255 - c * 10, 255 - c * 10)
Next
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Closing = True
End Sub
Private Sub Timer1_Timer()
If Closing Then Timer1.Enabled = False
Dim x As Integer
Dim y As Integer
Static c As Long
Dim myWidth As Integer
Dim myHeight As Integer
With Picture1
For x = 0 To .ScaleWidth / 2 Step border
myWidth = .ScaleWidth - 2 * x
myHeight = .ScaleHeight - 2 * x * r
y = r * x
Picture1.Line (x, y)-(x + myWidth, y + myHeight), colors(c), B
c = (c + 1) Mod 15
Next
End With
End Sub
Regards
-
Oct 3rd, 2000, 10:13 PM
#7
Hyperactive Member
Yikes
It's quite funny maximising the picturebox to fit the screen and trying different widths. At with 4, it looks like you are going out, but 5 it looks like you are going in.
And it makes your eyes go funny if you watch for too long.
I guarantee someone will post you an API or DirectX way of doing it which will be really impressive 
Cheers
-
Oct 4th, 2000, 01:12 AM
#8
reply...
hi paul.....thanks for the code....there seems to be a problem with the following line " type mismatch error ".
border = text1
john
-
Oct 4th, 2000, 03:09 AM
#9
Hyperactive Member
Just cast it then
I was being lazy and relying on the user to enter a valid number there.
You could replace it with
Code:
border = cint(text1.text)
It will now give a conversion error if the value is not an integer. For a demo, you can live with it. If you were going to do something serious with it, you would probably check the user input...
Cheers
Paul
-
Oct 4th, 2000, 03:17 PM
#10
reply
hi paul......i seem to be missing something somewhere....on a form i have a textbox,a picturebox,a timer and a command button.i pasted the code into the appropiate areas and still get a " type mismatch " even on that new ode you mailed me.
what am i doing wrong ????
john
-
Oct 4th, 2000, 04:08 PM
#11
Hyperactive Member
An Error
I just started a new project, and followed my own instructions but it did not work. Extra steps I needed to do were:
Call the Command Button Command2 (I guess I originally had 2 buttons for testing)
Put an interval of 250 or so in the Timer Control.
After doing this, and running it, I get a type mismatch if I do not change the value of the Text1 text box. If I put 10 in there and press the button, I get the effect.
You may like to try again, and if no go , post here the whole sub or function that is failing.
Regards
-
Oct 4th, 2000, 04:11 PM
#12
Hyperactive Member
Another idea
Just delete the line that has border=text1. The default border width is 10 anyhow.
Cheers
-
Oct 4th, 2000, 04:58 PM
#13
hiya paul.....got it working 100% now...the timer had no value :-((
now to tear the code apart and disect it....Mmmmmmm
thanks for the help
john
ps...its quite good....needs some smoothe scrolling though.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|