I am doing a little game program where there are some images which you must prevent from reaching the bottom of the screen. Eventually they will move diagonally and at different speeds as more are added later on. I used an array so i can add more later easily.
My problem is with the slowdown portion of my code. When you click the image it moves upwards and slows down incrementally. Everything about that works fine, except that if you click another picture while the one is moving up that picture stops and the new picture starts moving with the slowdown applied from the last picture. Like this diagram
highest height without interruption
|
|
|
|
| |height when interrupted
| |
| | |next height if you click before the counter is up still.
|_______|________|______
Could i maybe fix this by resetting the counter to 0 when clicked?
But the problem still remains that the picture will stop when another is clicked
What can i do to prevent this? Currently you cannot survive the first wave
Quote:
'Array problem
Dim begin As Boolean
Dim intcounter As Integer
Dim imageclick As Boolean
Dim curslowdown As Currency
Dim intindexclick As Integer
Option Explicit
'This makes imageclick true and assigns intindexclick so that the object you clicked moves
Private Sub Picture1_Click(Index As Integer)
imageclick = True
intindexclick = Index
Call Timer1_Timer
End Sub
'This controls the movement of the objects towards the bottom
Private Sub Timer1_Timer()
begin = True
If begin = True Then
'the picture begins moving down
Picture1(intcounter).Top = Picture1(intcounter).Top + 150
'this is a counter to go through the array of pictures
intcounter = intcounter + 1
If intcounter = 6 Then
intcounter = 0
End If
End If
'controls the upwards movement of the picture that is clicked
If imageclick = True Then
Picture1(intindexclick).Top = Picture1(intindexclick).Top - 150 + curslowdown
'slowdown is incremented until it reaches 150, which is the value that it moves up, so it stops and it moves back down
If curslowdown = 150 Then
curslowdown = 0
imageclick = False
Else
curslowdown = curslowdown + 2
End If
End If
End Sub
|
Here is my code, any ideas on what i can do? Should i just scrap the array idea even though it would be easier to add more with an array later?
bleh, just ignore the diagram, it screwed up when i posted the message