Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > moving dots


Reply
 
Thread Tools Display Modes
  #1  
Old 06-06-2003, 08:37 AM
necro necro is offline
Freshman
 
Join Date: Nov 2002
Posts: 45
Default 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:)
Reply With Quote
  #2  
Old 06-06-2003, 08:43 AM
vb-dred vb-dred is offline
Centurion
 
Join Date: Nov 2002
Location: UK
Posts: 174
Default

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
Reply With Quote
  #3  
Old 06-06-2003, 09:04 AM
necro necro is offline
Freshman
 
Join Date: Nov 2002
Posts: 45
Default

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:)
Reply With Quote
  #4  
Old 06-06-2003, 09:09 AM
vb-dred vb-dred is offline
Centurion
 
Join Date: Nov 2002
Location: UK
Posts: 174
Default

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
Reply With Quote
  #5  
Old 06-06-2003, 09:15 AM
necro necro is offline
Freshman
 
Join Date: Nov 2002
Posts: 45
Default

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:)
Reply With Quote
  #6  
Old 06-06-2003, 09:43 AM
necro necro is offline
Freshman
 
Join Date: Nov 2002
Posts: 45
Default

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:)
Reply With Quote
  #7  
Old 06-06-2003, 11:27 AM
DrPunk's Avatar
DrPunk DrPunk is offline
Senior Contributor

* Expert *
 
Join Date: Apr 2003
Location: Never where I want to be
Posts: 1,293
Default

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.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving emails in outlook using visual basic neilmaclean Word, PowerPoint, Outlook, and Other Office Products 2 01-27-2003 07:28 AM
Dots Game / Pacman Games brassmonkeyrh Game Programming 6 11-11-2002 02:57 AM
how to detect if moving objects touch each other leytonhouse General 11 04-21-2002 03:34 AM
Animation creating Green moving Dots visualbasic700e General 5 05-28-2001 01:40 AM
Shapes moving over picture box causing flikering seven General 4 01-28-2001 08:17 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->