[RESOLVED] Need Help for point and click game
Hi,
For my high school project i need to make a game and i am trying to make it point and click style, i'm am have problems making it stop at a certain location, i can make it so it go straight to were the mouse is clicked but i want it so i click and it moves there then it stops, any help well be appreciated, thanks, Nevets_rulz123
P.S, sorry for bad spelling.....:bigyello:
Re: Need Help for point and click game
Welcome to the forums...:wave:
Did you tried coding something ? If so, show us your code...:wave:
Re: Need Help for point and click game
You would want to use a Do loop, such as...
Code:
Do While x < PointClicked
Character.Left = x + 1
Loop
Of course that isn't the entire solution. You'd want to check for the current position of the character to decide if you need to go backwards or forwards, up or down
Re: Need Help for point and click game
Check out the ,Drag & Drop Game, link below. Thi s may offer you some ideas.
Re: Need Help for point and click game
this is my code
Dim xpos As Integer
Dim ypos As Integer
Dim Xtarget As Integer
Dim Ytarget As Integer
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
xpos = X
ypos = Y
If Button = 1 Then
Xtarget = X
Ytarget = Y
End If
End Sub
Private Sub Timer1_Timer()
Shape1.Move Xtarget
End Sub
Private Sub Timer2_Timer()
Shape1.Move Xtarget
End Sub
this makes it appear in the clicked location however it doesn't make it go up or down for some reason.... only horizontal
P.S, thanks for all the help
Re: Need Help for point and click game
Try this code:
Code:
Option Explicit
Dim Xtarget As Long
Dim Ytarget As Long
Dim revX As Boolean
Dim revY As Boolean
Dim xReached As Boolean
Dim yReached As Boolean
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 50
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Xtarget = CLng(X)
Ytarget = CLng(Y)
If Xtarget > Shape1.Left Then
revX = False
Else
revX = True
End If
If Ytarget > Shape1.Top Then
revY = False
Else
revY = True
End If
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
If revX = False Then
If Shape1.Left < Xtarget Then
Shape1.Left = Shape1.Left + 50
Else
xReached = True
End If
Else
If Xtarget < Shape1.Left Then
Shape1.Left = Shape1.Left - 50
Else
xReached = True
End If
End If
If revY = False Then
If Shape1.Top < Ytarget Then
Shape1.Top = Shape1.Top + 50
Else
yReached = True
End If
Else
If Ytarget < Shape1.Top Then
Shape1.Top = Shape1.Top - 50
Else
yReached = True
End If
End If
If xReached = True And yReached = True Then
xReached = False
yReached = False
Timer1.Enabled = False
End If
End Sub
.....:wave:
Re: Need Help for point and click game
Worked like a charm Thanks so much :)
Re: Need Help for point and click game
You're welcome...:wave:
If the problem is solved, please make sure to mark the thread as RESOLVED (you can use the Thread Tools found at the top of this page)
Good luck...:thumb: