473,385 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Side scrolling problem with Key events

I am using a code which goes like this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  2.  
  3. If Imgme.Top <= 400 Then
  4.   Imgme.Top = 400
  5. End If
  6.  
  7. If KeyCode = vbKeyRight Then
  8.   c = c + 1
  9.   If c = 12 Then c = 1
  10.   Imgme.Picture = meright(c).Picture
  11.   Imgme.Left = Imgme.Left + 45
  12. End If
  13.  
  14. If KeyCode = vbKeyLeft Then
  15.   d = d + 1
  16.   If d = 8 Then d = 1
  17.   Imgme.Picture = meleft(d).Picture
  18.   Imgme.Left = Imgme.Left - 45
  19. End If
  20.  
  21. End Sub
to code a side scrolling game. I want to create a jump button, in which when I press on it, it jumps up for a while and then drop down. I also want to include a crouch button where when I press down, I bend down(keydown) but if I let go, it stands up again.

I tried doing something like this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  2. If KeyCode = vbKeyDown Then
  3.   Imgme.Picture = mecrouch.Picture
  4. End If
  5. -----
  6. Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
  7. If KeyCode = vbKeyDown Then
  8.   Imgme.Picture = Imgme.Picture
  9. End If
  10.  
But it doesn't seem to work. Can anyone tell me how to make the crouch work, and how to implement a jump function.

Thanks in advance, I will appreciate it!
Oct 13 '07 #1
1 1168
Killer42
8,435 Expert 8TB
Can you show us the actual code you ended up with, so we don't just duplicate what you're already tried? You haven't shown us how you integrated the two different KeyDown routines.

To judge from the Sub declaration, this is in VB6 - correct?
Oct 17 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Paul | last post by:
I use ASP and I need to know how to attaches an Iframe Id with its page so I can load menu options ( eg. 1.htm, 2.htm, 3.htm, ect...) into the Iframe from any given page on my website. The problem...
3
by: japi | last post by:
Hi, In my webpage I have an embedded Windows Media Player and an unordered list with a table of contents. When playing a video, the Windows Media Player is triggering events for new...
2
by: Rik Brooks | last post by:
My boss has put a couple of restraints on me that has me tearing out my hair. Here is my problem. On a particular asp page I need to use server side controls so that I do some fairly complex...
0
by: 6tc1 | last post by:
Hi all, I've got a UserControl that contains a few PictureBox objects. If I click on outside of the Picture in the UserControl, the scrolling with the mouse button works - however, no amount of...
5
by: Mong | last post by:
Hi, I have a webform with various asp controls on it such as textboxes and dropdownlists. I'm fairly new to asp.net coming from VB6 and am wondering when it's best to use client side events and...
10
by: Ben | last post by:
Hi, I made an application in classic asp (reservation of books and video stuffs for students) and want to migrate to asp.net. The user has to chose a date, then pushung on a submit button. The...
3
by: Chamnap | last post by:
Hello everybody, I have one problem. I want to do something after the user finished scrolling. The scroll event fires whenever the user is scrolling. I don't want this actually. Does anyone has...
3
by: Mike | last post by:
Hi, I'm wondering if I can do this with ASP.NET?
1
by: jonceramic | last post by:
Hi All, I've noticed that in a lot of my forms and tables, when I'm on continuous view, I can't scroll when the focus is in a field or on a control. Meaning, if I have a list, and start...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.