Really easy Questions 
Author Message
 Really easy Questions

    Could you please answer a couple of (or four) questions for me, to
preserve my sanity?

1.
    I have written a Space Invaders type game using the keyboard to move and
shoot.  The problem is, when you hold down the key to keep moving the ship,
and then fire, the ship stops moving, and you have to repress the key to
start moving again.  How can I rewrite this so that the ship keeps moving
when you fire?

Private Sub Form_KeyPress(KeyAscii As Integer)

      If KeyAscii = vbKeyEscape Then frmMenu.Show vbModal
     If KeyAscii = 52 Then MoveShipLeft
      If KeyAscii = 54 Then MoveShipRight
      If KeyAscii = vbKeySpace And Shooting = False Then Shoot

End Sub

2.
Also, I wanted to use the arrow keys to move the ship, so I used vbKeyLeft
and vbKeyRight, but this didn't work.  So I put the code
    Debug.Print KeyAscii
in the above procedure to see what numbers I should use, but the arrow keys
didn't show a number when I pressed them.
The function keys didn't either.
Of the keys that did show an ascii code, most of them were different than
the ones in the Help.
Is there some property on the form I should change ?  Or a keyboard setting
somewhere?

3.
At the start of the game, the high score table is loaded from a file into an
array.
If this file doesn't exist (eg.  The first time the game is played)  there's
an error.
How do I check if the file exists so I can skip the procedure if it doesn't?
I assume this uses the FileExists method, but can you please give me an
example ?

4.
If I load a picture into an image control at design time, and then make an
exe to send to someone, do I need to send them the picture as well, or is
that included in the executable ?

Please help, as I need to finish this game or I'll never get around to doing
the things I should be (assignments, eating, sleeping etc.)



Tue, 05 Mar 2002 03:00:00 GMT  
 Really easy Questions
Being only an advanced novice myself... I can only help a little (but I
try).

Quote:

>     Could you please answer a couple of (or four) questions for me, to
> preserve my sanity?
<snip>

> 3.
> At the start of the game, the high score table is loaded from a file into an
> array.
> If this file doesn't exist (eg.  The first time the game is played)  there's
> an error.
> How do I check if the file exists so I can skip the procedure if it doesn't?
> I assume this uses the FileExists method, but can you please give me an
> example ?

My suggestion is
Make a error trap

IE: on error goto Error_Trap

Place the Error_Trap past the rest of the code.

I know that gotos are bad form but its the best I could think of.

Quote:

> 4.
> If I load a picture into an image control at design time, and then make an
> exe to send to someone, do I need to send them the picture as well, or is
> that included in the executable ?

No It should be part of the exe.

--
Dwayne Miller

ICQ: 49362615
http://members.xoom.com/fallenhunter



Tue, 05 Mar 2002 03:00:00 GMT  
 Really easy Questions
I monitor  KeyDown() and KeyUp() instead of KeyPress() in similar situation.
It allows me to keep track of all pressed key
 (even if several keys are pressed simultaneously)
Also implement variables to store last movement and firing keys.
Your timer can refer to your "movement" and "firing" variables.
Yury
Quote:

>  The problem is, when you hold down the key to keep moving the ship,
>and then fire, the ship stops moving, and you have to repress the key to
>start moving again.  How can I rewrite this so that the ship keeps moving
>when you fire?

>Private Sub Form_KeyPress(KeyAscii As Integer)

>      If KeyAscii = vbKeyEscape Then frmMenu.Show vbModal
>     If KeyAscii = 52 Then MoveShipLeft
>      If KeyAscii = 54 Then MoveShipRight
>      If KeyAscii = vbKeySpace And Shooting = False Then Shoot



Tue, 05 Mar 2002 03:00:00 GMT  
 Really easy Questions

<How can I rewrite this so that the ship keeps moving
<when you fire?

Set module level flags in the KeyDown event.  Check them in your Timer event.
Clear them in the KeyUp event.

<2.
<Also, I wanted to use the arrow keys to move the ship, so I used vbKeyLeft
<and vbKeyRight, but this didn't work.

Up/Down instead of Press should fix that.

<3.

<How do I check if the file exists so I can skip the procedure if it doesn't?
<I assume this uses the FileExists method, but can you please give me an
<example ?

If Dir("YourHighScoreFile.xyz") <> "" Then
        'you have a file
End If

<
<4.
<If I load a picture into an image control at design time, and then make an
<exe to send to someone, do I need to send them the picture as well, or is
<that included in the executable ?

It's in the .exe.

--
Paul Marshall



Tue, 05 Mar 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Really Easy Question

2. Really easy question

3. Using mailslot .... Really easy question.

4. really easy VBA question!

5. Really easy Select Question

6. EASY EASY EASY question

7. Really really stuck on this one. (QBasic Question)

8. This is a really really dumb question.

9. HELP - Really, really simple printer questions

10. Really, really stupid question.

11. Really, Really Horrible question about sprites

12. Really easy I think

 

 
Powered by phpBB® Forum Software