Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ General
➜ Problem getting an idea to work in VB...
Problem getting an idea to work in VB...
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Shadowfyr
USA (1,791 posts) Bio
|
Date
| Fri 26 Sep 2003 06:08 PM (UTC) Amended on Fri 26 Sep 2003 06:14 PM (UTC) by Shadowfyr
|
Message
| 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:
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 Function
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:
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. Loop
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. | Top |
|
Posted by
| Magnum
Canada (580 posts) Bio
|
Date
| Reply #1 on Sat 27 Sep 2003 11:59 AM (UTC) |
Message
| Man, you sure take on some silly projects, just for the fun of programming them. ;)
Sorry, that kind of programming isn't my specialty, can't help. |
Get my plugins here: http://www.magnumsworld.com/muds/
Constantly proving I don't know what I am doing...
Magnum. | Top |
|
Posted by
| Shadowfyr
USA (1,791 posts) Bio
|
Date
| Reply #2 on Sat 27 Sep 2003 06:18 PM (UTC) |
Message
| Hmm. Well, I got the part I was having trouble with the work after changing the code back to a Class, but now I am having a problem where the stupid things refuses to let me set the propeties, so it still isn't bloody working. I'll toss it up on a VB Forum and see what sticks.
Oh, and Magnum... This isn't as silly as it looks. ;) It will use my window docking trick, assuming I ever get it to work. And being able to create and throw out copies of an object as they are no longer needed it what you need for things like custom toolbars, etc. Though those would use the forms control array collection, instead of the one I am using, so... | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
10,979 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top