 |
 |

06-06-2003, 08:37 AM
|
|
Freshman
|
|
Join Date: Nov 2002
Posts: 45
|
|
moving dots
|
i need help! does anyone know some code for some really basic moving stimuli eg dots moving constantly in one direction? any help would be really appreciated
thanks
andy
|
__________________
i am a newbie, so you may have to speak slowly:)
|

06-06-2003, 08:43 AM
|
|
Centurion
|
|
Join Date: Nov 2002
Location: UK
Posts: 174
|
|
|
i would use a timer, interval 1000ms, and every 1000ms it sets the image's height + 100 or something, this will move the image (dot) moving upwards.
|
__________________
abracadabra
|

06-06-2003, 09:04 AM
|
|
Freshman
|
|
Join Date: Nov 2002
Posts: 45
|
|
Quote: Originally Posted by vb-dred i would use a timer, interval 1000ms, and every 1000ms it sets the image's height + 100 or something, this will move the image (dot) moving upwards.
cool, but would you be able to give me a quick example
thanks
andy
|
__________________
i am a newbie, so you may have to speak slowly:)
|

06-06-2003, 09:09 AM
|
|
Centurion
|
|
Join Date: Nov 2002
Location: UK
Posts: 174
|
|
say you got a image named img1 and a timer named tmr1, interval set to 1000.
put this in your coding
Code:
Private Sub Tmr1_Timer()
Img1.Top = Img1.Top + 100
End Sub
this would make the image go down every 1 second
|
__________________
abracadabra
|

06-06-2003, 09:15 AM
|
|
Freshman
|
|
Join Date: Nov 2002
Posts: 45
|
|
|
i use a library called winhrt to do my timing so i suppose it would then be
img1.top = img1.top + 100
do_idelay1 'my thing e.g. 500ms
img1.top = img1.top + 100
etc
|
__________________
i am a newbie, so you may have to speak slowly:)
|

06-06-2003, 09:43 AM
|
|
Freshman
|
|
Join Date: Nov 2002
Posts: 45
|
|
|
ok cool this works (with my module timer thing) so i can get it to go left and down (.left and .top) but how do i get it to go right and up?
thanks
andy
|
__________________
i am a newbie, so you may have to speak slowly:)
|

06-06-2003, 11:27 AM
|
 |
Senior Contributor
* Expert *
|
|
Join Date: Apr 2003
Location: Never where I want to be
Posts: 1,293
|
|
Quote: Originally Posted by necro ok cool this works (with my module timer thing) so i can get it to go left and down (.left and .top) but how do i get it to go right and up?
thanks
andy
Hi. I get the feeling that you're trying to get something to bounce around the form. Even if it's not, it got me interested so I decided to put a pretty poor example together. These are my first thoughts on it. No doubt there is some much simpler way of doing it. I'm afraid it doesn't even take into account the title bar of the window so goes off the bottom of the window a bit.
If you want to do stuff like this I advise you look intousing pictureboxes and blitting and the like because using controls gives nasty flickers. Anyway, it was fun while it lasted.
Just change C_MOVE to move the control by more or less. It's all twips. I suppose I should of used ScaleHeight and ScaleWidth so it would work in pixels too. Oh yeah, and it uses a shape control.
Code:
Option Explicit
Private Const C_MOVE = 60
Private m_Up As Boolean
Private m_Left As Boolean
Private Sub Timer1_Timer()
If WillHitBoundaryX Then
m_Left = Not m_Left
End If
If WillHitBoundaryY Then
m_Up = Not m_Up
End If
Shape1.Left = Shape1.Left + MoveByX
Shape1.Top = Shape1.Top + MoveByY
End Sub
Private Function WillHitBoundaryY() As Boolean
If Shape1.Top + MoveByY <= 0 Then
WillHitBoundaryY = True
Else
If Shape1.Top + Shape1.Height + MoveByY >= Me.Height Then
WillHitBoundaryY = True
End If
End If
End Function
Private Function WillHitBoundaryX() As Boolean
If Shape1.Left + MoveByX <= 0 Then
WillHitBoundaryX = True
Else
If Shape1.Left + Shape1.Width + MoveByX >= Me.Width Then
WillHitBoundaryX = True
End If
End If
End Function
Private Function MoveByX() As Long
If m_Left Then
MoveByX = -C_MOVE
Else
MoveByX = C_MOVE
End If
End Function
Private Function MoveByY() As Long
If m_Up Then
MoveByY = -C_MOVE
Else
MoveByY = C_MOVE
End If
End Function
|
Last edited by DrPunk; 06-06-2003 at 11:39 AM.
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|