Search Tools Links Login

Moving Stars. Tutorial. Graphics. Includes Image

Visual Basic 6, or VB Classic

This articles makes moving stars. It could be used to create a star shooting game. For beginners.

Original Author: Rodrigo Bola??os


'By Rodrigo Bola??os

'For beginners who want to learn the Pset. And

'the parameters that need to be use

Option Explicit

Dim Px(1 To 150) 'Pixel X position

Dim Py(1 To 150) 'Pixel Y positon

Dim P_LastY(1 To 150) 'Pixel Y last position

Dim i As Integer ' Just for the For and Next

Dim a As Integer ' Just for the For and Next

Private Sub Form_Load()

Me.BackColor = vbBlack

For a = 1 To 140

Px(a) = Rnd * Me.ScaleWidth 'Create Random X

'position for the pixel

Py(a) = Rnd * Me.ScaleHeight 'Create Random Y

'position for the pixel

Next a

End Sub

Private Sub Timer1_Timer() ' This is our main


On Error Resume Next 'Just in case theres an


For i = 1 To 140

Py(i) = Py(i) + 10 ' Move the stars.

If Py(i) > Me.ScaleHeight Then Py(i) = 0 'If we

'have reached the bottom part of the form ,

'put them in the top part

P_LastY(i) = Py(i) - 10 Calculates where the last

'star we draw is.

Me.PSet (Px(i), P_LastY(i)), vbBlack
'Erase our last star

Me.PSet (Px(i), Py(i)), vbWhite 'Set our new star

Next i

End Sub

'This code made 100% made by me

'Please comment

'Please Vote

About this post

Posted: 2003-06-01
By: ArchiveBot
Viewed: 193 times


Visual Basic 6


No attachments for this post

Loading Comments ...


No comments have been added for this post.

You must be logged in to make a comment.