Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 29th, 2007, 08:55 PM
Registered User
 
Join Date: Mar 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default need help

ok im still what you would call new to VB ive been taking a class on it and now im trying to make a little pacman game to see what i know and get more into making bigger and better things. ok but what im needing to know is what kind of code would i use to make the pacman move automatically with the press of an arrow key

 
Old March 30th, 2007, 09:50 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there..

using the keypress event (or keydown) of the form... also set keypreview (of the form) to true...

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
 
Old March 30th, 2007, 09:54 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Hakumioje,

You should choose a subject line that relates to what you need help with. Virtually everyone knows you need help, by virtue of the fact that you posted a question.

Second, though [u]you</u> know what you are trying to say; other do not. It is a kindness to make understanding your question easier by using punctuation and appropriate capitalization. (For example, you should have started with "Ok[u].</u> [u]I’</u>m still what you would call . . . ") You want help, so make giving that help as easy as you can.

Nothing is automatic, but probably the best thing is to preview keypresses. If the key is not one that you are interested in, discard it.

But if it is one of the cursor keys, ad or subtract the appropriate value from the pacman’s position.

For instance, if the smallest move is 5, when the right cursor key is detected set: objPacMan.Left = objPacMan.Left + 5.

Brian









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.