Key coding

Questions regarding syntax

Key coding

Postby JaketheDude » Thu Sep 29, 2011 9:04 pm

I am not new to BASIC, but I am new to this type of BASIC. I used to use BlitzMax, but stuff happened, so I got KBasic. :?

Things I need to know:
How to do Types
Key coding and mouse coding
I may need to know other things, but the above is just for right now.
JaketheDude
 
Posts: 3
Joined: Thu Sep 29, 2011 8:57 pm

Re: Key coding

Postby Slowdown » Sun Oct 02, 2011 9:44 am

Hi,
Did you already installed KBasic ?
If so look at the examples and/or documentation.
I think you will find all you need to know.
Regards
Slowdown for now i'm back
Slowdown
 
Posts: 347
Joined: Sat May 02, 2009 6:48 pm
Location: Netherlands

Re: Key coding

Postby JaketheDude » Tue Oct 04, 2011 5:49 pm

I did install KBasic.
The thing is, on Blitz, to give a function to a certain key I did something like this:
If KeyDown (KEY_RIGHT) Then
player.x = player.x + 5
EndIf
But I looked at the key codes and it didn't say how to establish a key IS being pressed, like KeyDown on Blitz.

For Types, I did this
Type TPlayer
Field x,y
End Type
but that doesn't do anything on KBasic. I couldn't find what I was looking for either.
JaketheDude
 
Posts: 3
Joined: Thu Sep 29, 2011 8:57 pm

Re: Key coding

Postby berndnoetscher » Wed Oct 05, 2011 7:32 am

Code: Select all
'http://www.kbasic.com/doku.php?id=control#key_codes

Private Sub Form_OnKeyPress(KeyCode As Integer, Shift As Boolean, Control As Boolean, Alt As Boolean)
  MsgBox(KeyCode)
  if KeyCode = Key.F5 Then
    Msgbox("F5")
  end if
End Sub
berndnoetscher
Site Admin
 
Posts: 1059
Joined: Tue Sep 25, 2007 9:37 am

Re: Key coding

Postby Henning » Wed Oct 05, 2011 10:06 am

Try this

Type TPlayer
x As Integer
y As Integer
End Type

Dim player As TPlayer

If you need to access it outside the module where declared.
Public player As TPlayer

/Henning
Henning
 
Posts: 262
Joined: Mon Feb 09, 2009 12:03 am
Location: Sweden

Re: Key coding

Postby JaketheDude » Wed Oct 05, 2011 8:13 pm

1) When I typed in the F5 thing, a KBasic icon appeared on my dock for not two seconds and disappeared.
2) How do I make the program's window 640x480 pixels?
JaketheDude
 
Posts: 3
Joined: Thu Sep 29, 2011 8:57 pm

Re: Key coding

Postby Henning » Wed Oct 05, 2011 10:25 pm

Just a guess, do as in VB.
Code: Select all
    Private Sub Form_OnKeyPress(KeyCode As Integer, Shift As Boolean, Control As Boolean, Alt As Boolean)
      MsgBox(KeyCode)
      if KeyCode = Key.F5 Then
        Msgbox("F5")
        KeyCode = 0
      end if
    End Sub



The value in KeyCode will stay till removed. So other parts of the app, and maybe in the end the IDE, will also receive it, as if pressing F5.

/Henning
Henning
 
Posts: 262
Joined: Mon Feb 09, 2009 12:03 am
Location: Sweden

Re: Key coding

Postby Henning » Wed Oct 12, 2011 11:57 am

@JaketheDude

2) From an old post:
Sub Form_OnOpen()
Me.Width =640
Me.Height = 480
End Sub

/Henning
Henning
 
Posts: 262
Joined: Mon Feb 09, 2009 12:03 am
Location: Sweden


Return to Coding Questions

cron