You are not logged in.

Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

amma

Beginner

  • "amma" is male
  • "amma" started this thread

Posts: 17

Date of registration: Jul 17th 2009

  • Send private message

1

Saturday, July 18th 2009, 4:42pm

Some problems I ran into

Project1.zip
Hello Jabaco community,

Edit: This post is obsolete (because the problem was in Line() and not with the timers because I didn't install the latest framework version and using the Key_Down and Up with a variable I got the same effect as with AsyncKeyState), except the question whether WinAPI calls are possible on a web applet with IE and Firefox.

When I saw this Jabaco application I was very glad because-of the option to export VB programming to JAVA! I am really impressed, after playing around with Jabaco.

But as soon as I've begun programming a clone of a very old and simple game called Achtung die curve, I encountered some problems. I am using the newest 1.4.2 Version. Maybe Jabaco just works differently and I am the one not being compatible. :)

1. Timers seem to stop functioning after a short while. However from my short experience I can tell that the lower the interval the less time the timer will work.
2. Is calling WinAPI calls possible from within an embedded object in a web page? Both Firefox as well as IE do not allow doing so. In this case I didn't want the OS to delay further input after the first press of a button, while still being pressed (ie: a long press produces: 1|LONG DELAY|1|SHORT DELAY|1|..|1|..|1|..|1|..|1). I have tried implementing the KeyListener events but got the same, well, Normal effect of typing, which delays all characters after the first one according to the default OS setting.

BTW: The timer problem persisted, even when I did not use a Timer (Timer2) for input, but the Form_KeyDown instead. I assumed the problem might had arose because of the two timers' conjunction. Well, to draw, at least a single timer is required (I do not wish to make a loop with DoEvents and Sleep).

I have placed two timers on a black form (applet) -- the first one set to interval=12 and the other=13. Herewith the simple code (which I've also attached):

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Option Explicit
Private Winapi Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer

Private Type Acht 'Snake_type
   X As Single
   Y As Single
   ANG As Integer 'Angle
End Type
Dim Achts() As Acht 

'ARRAY AND SETUP - NOT IMPORTANT
Public Sub Applet_Initialize()
   Redim Achts(1 To 1)
  Achts(1).ANG=0
  Achts(1).X=Me.Width/2
  Achts(1).Y=Me.Height/2
End Sub

'This timer draws the snakes
Public Sub Timer1_Timer()
Dim i As Integer
For i=1 To Ubound(achts)
   Me.Line achts(i).X,achts(i).Y,achts(i).X + 2*cos(achts(i).ANG/180*3.1415),achts(i).Y + 2*sin(achts(i).ANG/180*3.1415),False,rgb(255,255,255)
   achts(i).X=round(achts(i).X + 2*cos(achts(i).ANG/180*3.1415),1)
   achts(i).Y=round(achts(i).Y + 2*sin(achts(i).ANG/180*3.1415),1)
Next
End Sub

'This timer handles the controls
Public Sub Timer2_Timer()
      If GetAsyncKeyState(49) Then
  achts(1).ANG=achts(1).ANG-2
  achts(1).ANG = achts(1).ANG Mod 360
   Elseif GetAsyncKeyState(81) Then
  achts(1).ANG=achts(1).ANG+2
  achts(1).ANG = achts(1).ANG Mod 360
   End If
End Sub


Thanks!

Amit Markel

This post has been edited 1 times, last edit by "amitmarkel" (Aug 5th 2009, 10:03pm)


Rate this thread
WoltLab Burning Board