On the mud I play they occationally send up messages like:
A huge purple fireball explodes in the sky.
Or something close to that, I don't remember the precise text right now, nor is it relevant to my problem. I am trying to work out the 'core' function needed to generate a set of fireworks in an external window in response to this. I am unfortunately still stuck at the stage where I can't even get the graphics to work. The code I have so far is this:
When I get this much to work, I will change to code so it works as an ActiveX conponent and the loop exits when all the connections are lost. It will also use a call from scripting to generate a new firework. However, it is 'suppposed' to do this right now:
Now the problem I am having is that as an Class or as a UserControl, I can't seem to get List.Add to work. I need to be able to keep all active Sparks in a list and execute them one by one, then later remove the ones I don't need anymore, but since I can't figure out how to make one so I can add it in the first place... I would also prefer to use a Class object, instead of a control, but that attempt simply generated a different error. :(
In any case, Hopefully someone else here has some clue what I need to do to make it work.
A huge purple fireball explodes in the sky.
Or something close to that, I don't remember the precise text right now, nor is it relevant to my problem. I am trying to work out the 'core' function needed to generate a set of fireworks in an external window in response to this. I am unfortunately still stuck at the stage where I can't even get the graphics to work. The code I have so far is this:
VERSION 5.00
Begin VB.Form Fireworks
Caption = "Form1"
ClientHeight = 3150
ClientLeft = 60
ClientTop = 390
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3150
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
Begin VB.PictureBox Display
BackColor = &H00000000&
Height = 3135
Left = 0
ScaleHeight = 3075
ScaleWidth = 4635
TabIndex = 0
Top = 0
Width = 4695
End
Begin VB.PictureBox Buffer
BackColor = &H00000000&
Height = 3135
Left = 0
ScaleHeight = 3075
ScaleWidth = 4635
TabIndex = 1
Top = 0
Visible = 0 'False
Width = 4695
End
End
Attribute VB_Name = "Fireworks"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Load()
Dim Call_it As Object
Dim Res As Boolean
Dim Temp_Obj As Object
Dim List As Collection
Set List = New Collection
Do
If List.count > 0 Then
Objs = List.count
Do
Res = List(Objs).Spark_Draw
If Res = True Then
List.Remove (Objs)
End If
Objs = Objs - 1
Loop Until Objs = 0
Fireworks.Display.Picture = Fireworks.Buffer.Image
'Replace with something to fade the colors to black.
Fireworks.Buffer.Cls
End If
If Rnd() < 0.1 Then
Set Temp_Obj = New Spark
Temp_Obj.XStart = Int(Rnd() * 200)
Temp_Obj.YStart = Int(Rnd() * 100)
Temp_Obj.Color = RGB(Int(256 * Rnd()), Int(256 * Rnd()), Int(256 * Rnd()))
List.Add Temp_Obj
Temp_Obj = ""
End If
Loop
Call_it = ""
End Sub
VERSION 5.00
Begin VB.UserControl Spark
Appearance = 0 'Flat
BackColor = &H80000005&
BackStyle = 0 'Transparent
ClientHeight = 90
ClientLeft = 0
ClientTop = 0
ClientWidth = 90
ScaleHeight = 90
ScaleWidth = 90
End
Attribute VB_Name = "Spark"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
Dim Px(100) As Integer
Dim Py(100) As Integer
Dim Vx(100) As Single
Dim Vy(100) As Single
Public XStart As Integer
Public YStart As Integer
Public Color As String
Private Step As Integer
Private Sub UserControl_Initialize()
Dim count As Integer
Dim PI As Single
Dim Vect As Single
PI = 3.1415926
For count = LBound(Px) To UBound(Px)
Px(count) = XStart
Py(count) = YStart
Vect = 2 * PI * Rnd()
Vx(100) = Int((Cos(Vect) * 20)) / 20000
Vy(100) = Int((Sin(Vect) * 20)) / 20000
Next
Step = 0
End Sub
Public Function Spark_Draw()
'Put code to calc and draw dots here.
Dim count
For count = LBound(Px) To UBound(Px)
Px(count) = Px(count) + Vx(count)
Py(count) = Py(count) + Vy(count)
Fireworks.Buffer.PSet (Px(count), Py(count)), Color
Vx(count) = Vx(count) * 0.999
Vy(count) = Vy(count) + 0.00001
Next
Step = Step + 1
If Step = 800 Then
Spark_Draw = True
Else
Spark_Draw = False
End If
End FunctionWhen I get this much to work, I will change to code so it works as an ActiveX conponent and the loop exits when all the connections are lost. It will also use a call from scripting to generate a new firework. However, it is 'suppposed' to do this right now:
1. Create some basic objects.
2. Start loop
a. Check to see the number of sparks that are active.
- Execute the Spark_Draw function for each object.
- Delete any Sparks that have finished.
b. Move the draw buffer to the visible picturebox.
c. Generate a random number and if under .1 create a new
spark object.
3. LoopNow the problem I am having is that as an Class or as a UserControl, I can't seem to get List.Add to work. I need to be able to keep all active Sparks in a list and execute them one by one, then later remove the ones I don't need anymore, but since I can't figure out how to make one so I can add it in the first place... I would also prefer to use a Class object, instead of a control, but that attempt simply generated a different error. :(
In any case, Hopefully someone else here has some clue what I need to do to make it work.