Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Game Programming > how should i MOVE THE IMAGE BOXES IN A VERY SMOOTH MANNER?


Reply
 
Thread Tools Display Modes
  #1  
Old 12-05-2003, 05:11 PM
jordan_air jordan_air is offline
Freshman
 
Join Date: Nov 2003
Posts: 39
Default how should i MOVE THE IMAGE BOXES IN A VERY SMOOTH MANNER?


i have figured out hwo to move the images with easy and normal vbkeycodes...BUT CAN NEONE TELL ME HOW SHOULD I MOVE IT SMOOTHER!! coz u know to move i i always have to press the ke again n again!!....I WOULD RATHER REFER JUS PRESSING ONCE AND HOLDING ON TO THT...Rather than pressing the arrow keys again n again!!

it looks somewha like this

if keycode = vbKeyup then
img1.top = img1.top + 32

and u know so on?!?!??!
Reply With Quote
  #2  
Old 12-05-2003, 05:51 PM
Flip_Master Flip_Master is offline
Junior Contributor
 
Join Date: Oct 2003
Location: Sydney-Australia
Posts: 287
Default

Quote:
Originally Posted by jordan_air
i have figured out hwo to move the images with easy and normal vbkeycodes...BUT CAN NEONE TELL ME HOW SHOULD I MOVE IT SMOOTHER!! coz u know to move i i always have to press the ke again n again!!....I WOULD RATHER REFER JUS PRESSING ONCE AND HOLDING ON TO THT...Rather than pressing the arrow keys again n again!!

it looks somewha like this

if keycode = vbKeyup then
img1.top = img1.top + 32

and u know so on?!?!??!



Well there are certain events KeyUP KeyPress and the one you are looking for is KeyDown event for when the user is holding down the key.

I would also suggest using PictureBox's maybe as Image Control's tend to flicker when being moved around a form.
Reply With Quote
  #3  
Old 12-05-2003, 05:56 PM
Optikal's Avatar
Optikal Optikal is offline
Codeaholic

Retired Leader
* Guru *
 
Join Date: Oct 2002
Location: Winnipeg, MB, Canada
Posts: 4,543
Default

Most games typically use a game loop, and poll the keyboard state each frame, then update accordingly. I wrote a Game Loop tutorial in the Tutors Corner forum (or on my website http://members.shaw.ca/optikal ) if you don't know what a game loop is.
__________________
There are 10 types of people in this world, those that understand binary, and those that don't.
Reply With Quote
  #4  
Old 12-07-2003, 09:33 PM
rpgnewbie's Avatar
rpgnewbie rpgnewbie is offline
Contributor
 
Join Date: Aug 2003
Location: Portland OR
Posts: 581
Default Constant movement...

Quote:
Originally Posted by jordan_air
i have figured out hwo to move the images with easy and normal vbkeycodes...BUT CAN NEONE TELL ME HOW SHOULD I MOVE IT SMOOTHER!! coz u know to move i i always have to press the ke again n again!!....I WOULD RATHER REFER JUS PRESSING ONCE AND HOLDING ON TO THT...Rather than pressing the arrow keys again n again!!

it looks somewha like this

if keycode = vbKeyup then
img1.top = img1.top + 32

and u know so on?!?!??!


You could also have use a Boolean like:

Private blnMove as Boolean

then in the Keydown event (with a test for the key you want pressed) make blnMove=True. Then in a Do While blnMove = True loop (either in Form_Activate or a timer), put the img1.top = img1.top + 32 code. This is one (simple) type of game loop that Optikal was mentioning...

You can either stop by moving putting an "If X = somevalue" inside the Do Whole loop or have a KeyDown event for another key make blnMove=False.
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
make image move across form cmeares General 8 09-13-2004 11:32 PM
Creating a gride with image boxes loGin General 5 08-27-2003 03:41 PM
I want an image to move with the mouse omripanizel General 1 02-28-2003 08:35 AM
PUblic array With images NeverMore5 Game Programming 3 02-07-2003 01:59 PM
Image Boxes Aecliptica General 2 11-06-2002 03:03 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
 
 
-->