You are not logged in.

amitmarkel

Beginner

  • "amitmarkel" is male
  • "amitmarkel" started this thread

Posts: 17

Date of registration: Jul 17th 2009

  • Send private message

1

Sunday, August 2nd 2009, 2:52pm

Achtung die kurve (a game), timers problem?

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

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


amitmarkel

Beginner

  • "amitmarkel" is male
  • "amitmarkel" started this thread

Posts: 17

Date of registration: Jul 17th 2009

  • Send private message

2

Tuesday, August 4th 2009, 9:57pm

Line() memory leak?

Hello,

Problem solved... goto Edit.

I've now tried to copy&paste the timer code into a sub and set it to be called on Applet_Click().

Then I added to the sub: While True ... DoEvents Sleep and Wend (leaving the Dim out before :)), but I've got the same effect: after a while the execution stoped, and all lines drawn disappeared although AutoRedraw=True. Perhaps there is a memory leak in Line().

Edit: I have just noticed the framework snapshots section! This problem has already been fixed - hence my specific problem as well. :D

Regards,
Amit.

This post has been edited 2 times, last edit by "amitmarkel" (Aug 4th 2009, 10:09pm)


Rate this thread
WoltLab Burning Board