• Log in or sign up for an account here: https://www.sythe.org/login

2 questions

kharg0

Active Member
Joined
Feb 25, 2007
Sythe Gold
0
Messages
131
2 questions
i've decided to make a little video game so i've made my visual look and i need some help with this...

#1 i would like to know how to make it so when you press the up arrow on the keyboard an image goes up one pixel

#2 how to make it so when you press the a button on the keyboard it shows the image change from standing there to attacking?

thx :)
 
2 questions
In this code, make a button called button1 and make a picture box called picturebox1.

Dim Hi As Integer
Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
If e.KeyChar = Chr(Asc("w")) Then
Button1.Location = New Point(Button1.Location.X, Button1.Location.Y - 4)
ElseIf e.KeyChar = Chr(Asc("d")) Then
Button1.Location = New Point(Button1.Location.X + 4, Button1.Location.Y)
ElseIf e.KeyChar = Chr(Asc("a")) Then
Button1.Location = New Point(Button1.Location.X - 4, Button1.Location.Y)
ElseIf e.KeyChar = Chr(Asc("s")) Then
Button1.Location = New Point(Button1.Location.X, Button1.Location.Y + 4)
ElseIf e.KeyChar = Chr(Asc("q")) Then
Hi = Hi + 1
PictureBox1.Image = Image.FromFile("C:\Documents and Settings\Jaco\My Documents\My Pictures\Move 2.bmp")
If Hi = 2 Then
PictureBox1.Image = Image.FromFile("C:\Documents and Settings\Jaco\My Documents\My Pictures\Move 1.bmp")
Hi = 0
End If
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PictureBox1.Image = Image.FromFile("C:\Documents and Settings\Jaco\My Documents\My Pictures\Move 1.bmp")
End Sub

w - pushes the button up by 4
a - pushes the button left by 4
d - pushes the button right by 4
s - pushes the button back by 4
q - press it once and it will change to the image to a lite image, press it again and it will change it to a darker, repeating.
 
2 questions
alright do you know where i can get a list of key names like "A" would probably be called "A" but what would the arrow keys be called??

thx
 
2 questions
Chr(Asc("a"))

This lines converts it's letter (A) to a Chr using the Asc function.

Try googleing something like "arrow keys ascii" or something like that.
 
2 questions
ok thx skeletron
:)

ok i looked it up and the second one i belive has a ascii text thingy but visual basic seems to take the first letter and use it so if i say shtkgmfvkigkfkfkvk its gona use s and if it's UP i have to hold shift and press u or press caps lock and press u so ya...
 
Runescape Gamblingrunescape gambling
Back
Top