So you see that there is a block swinging on top and when you hit 5 a COPY of it will fall down. now how to reach that? how to create objects in run-time? the answer is using Object Arrays.
you can create control arrays with most of the controls in VB6.
first add these controls.
A Label named lbTotal
A Label named lbCorrect
A Label named lbWrong
A Label named lbRemain
A Command Button named 'cmdU' - Visible : False
A Command Button named 'cmdD'- Visible : False
//labels are screaming their function and buttons are to scroll the building in the End.
Creating the Array (For the Blocks)
1. If you're using GIF images that have Transparency use Image control. if not, use PictureBox. (I've used PictureBox here)
2. Rename it to 'Block'
3. Set AutoSize property to True
4. Set BorderStyle property to None
5. Set Index property to '0' ***
6. click on Picture property then click on the button on the far right. Find your House block image and hit open.
7. Move it to the Top of the Form
*** that is the property that tells vb this is a control array. now if you copy and paste it you won't see the message saying 'Do you want to create a control array...'
Making the Block Swinging Animation:
to do this, add a Timer Control. with the name of : 'CCMove' (Crane Cable Move!) and the interval value of '25'. it must be Enabled by default.
but first create a Shape as the Ground level and put it down on the form. Name it 'BaseBlock' (The swinging Block works with the dimensions of this object)
now double-click on the timer you created and write this piece of code in Timer event.
If rev Then
'go right
Block(0).Left = Block(0).Left + 100
If Block(0).Left > BaseBlock.Left + BaseBlock.Width - (Block(0).Width 2) Then rev = False
Else
'go left
Block(0).Left = Block(0).Left - 100
If Block(0).Left < BaseBlock.Left - (Block(0).Width 2) Then rev = True
End If
now go to the General - Declarations section and type this:
Dim rev as Boolean
this will declare a variable named rev in type of Boolean. this variable is used in CCMove Timer to switch the movement direction.
Now hit 'Play' to run the project and test the swinging animation.
>>What does the Timer do?
It moves the block 0 in a direction until it reaches the limitation you set for then switches the direction. the limitation here is based on 'BaseBlock' object with the offset of 1/2 block width from left and right.
you can create control arrays with most of the controls in VB6.
first add these controls.
A Label named lbTotal
A Label named lbCorrect
A Label named lbWrong
A Label named lbRemain
A Command Button named 'cmdU' - Visible : False
A Command Button named 'cmdD'- Visible : False
//labels are screaming their function and buttons are to scroll the building in the End.
Creating the Array (For the Blocks)
1. If you're using GIF images that have Transparency use Image control. if not, use PictureBox. (I've used PictureBox here)
2. Rename it to 'Block'
3. Set AutoSize property to True
4. Set BorderStyle property to None
5. Set Index property to '0' ***
6. click on Picture property then click on the button on the far right. Find your House block image and hit open.
7. Move it to the Top of the Form
*** that is the property that tells vb this is a control array. now if you copy and paste it you won't see the message saying 'Do you want to create a control array...'
Making the Block Swinging Animation:
to do this, add a Timer Control. with the name of : 'CCMove' (Crane Cable Move!) and the interval value of '25'. it must be Enabled by default.
but first create a Shape as the Ground level and put it down on the form. Name it 'BaseBlock' (The swinging Block works with the dimensions of this object)
now double-click on the timer you created and write this piece of code in Timer event.
If rev Then
'go right
Block(0).Left = Block(0).Left + 100
If Block(0).Left > BaseBlock.Left + BaseBlock.Width - (Block(0).Width 2) Then rev = False
Else
'go left
Block(0).Left = Block(0).Left - 100
If Block(0).Left < BaseBlock.Left - (Block(0).Width 2) Then rev = True
End If
now go to the General - Declarations section and type this:
Dim rev as Boolean
this will declare a variable named rev in type of Boolean. this variable is used in CCMove Timer to switch the movement direction.
Now hit 'Play' to run the project and test the swinging animation.
>>What does the Timer do?
It moves the block 0 in a direction until it reaches the limitation you set for then switches the direction. the limitation here is based on 'BaseBlock' object with the offset of 1/2 block width from left and right.
Visual Basic 2017 Games
Visual Basic Game Programming for Teens (For Teens (Course Technology)) Jonathan Harbour on Amazon.com.FREE. shipping on qualifying offers. VISUAL BASIC GAME PROGRAMMING FOR TEENS, THIRD EDITION teaches teens and other beginners how to create their own 2D role-playing game (RPG) using the free-to-download and easy-to-use Visual Basic 2008 Express. Visual Basic Code, Games. Updated As much as possible! Tons of code examples java visual basic asp and java games and a lot more C C,Assembly, html, windows shortcuts, batch programming, Dhtml, PopupMaker.