Hello,
EDIT: This is not a timer problem. Skip this post and read the bottom of my next post.
I suddenly remembered that I encountered a problem regarding the Timer component when trying to write an Achtung die kurve clone (not porting an application from VB6).
What seems to be happening is that after a short while timers stop working (maybe jabaco is counting the cycles).
Herewith is the complete code I have just written; place a timer with Interval=12 on a black applet. The keycodes are for the left and down arrows.
Why is this happening? Can someone try and tell me whether this occurs also? I tried Jabaco on a different computer so I think that either I do something wrong or there is a bug somewhere. If I do need to replace the timer with a loop and DoEvents, how can I do something equivalent to Sleep but without API Calls (Which cannot be called within a web applet)?
Regards,
Amit Markel
|
Jabaco Source
|
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
39
40
41
42
43
44
45
46
|
Option Explicit
Private Type Acht
X As Single
Y As Single
ANG As Integer
iKey As Byte
End Type
Dim Achts() As Acht
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
achts(1).ikey=0
End Sub
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 + 3*cos(achts(i).ANG/180*3.141),achts(i).Y + 3*sin(achts(i).ANG/180*3.141),False,rgb(255,255,255)
achts(i).X=round(achts(i).X + 3*cos(achts(i).ANG/180*3.141),1)
achts(i).Y=round(achts(i).Y + 3*sin(achts(i).ANG/180*3.141),1)
If achts(i).iKey=1 Then
achts(1).ANG=achts(1).ANG-3
achts(1).ANG = achts(1).ANG Mod 360
Elseif achts(i).iKey=2 Then
achts(1).ANG=achts(1).ANG+3
achts(1).ANG = achts(1).ANG Mod 360
End If
Next
End Sub
Public Sub Applet_KeyDown(KeyCode As Integer, Shift As Integer)
If keycode=37 Then
achts(1).iKey=1
Elseif keycode=40 Then
achts(1).iKey=2
End If
End Sub
Public Sub Applet_KeyUp(KeyCode As Integer, Shift As Integer)
If keycode=37 Or keycode=40 Then
achts(1).iKey=0
End If
End Sub
|
If lines aren't drawn set the form's ForeColor property to white.
Amit Markel