Help with my Block escape Game
Help with my Block escape Game
Help with my Block escape Game
Help with my Block escape Game
Help with my Block escape Game
Help with my Block escape Game Help with my Block escape Game Help with my Block escape Game Help with my Block escape Game Help with my Block escape Game Help with my Block escape Game Help with my Block escape Game Help with my Block escape Game
Help with my Block escape Game Help with my Block escape Game
Help with my Block escape Game
Go Back  Xtreme Visual Basic Talk > > > Help with my Block escape Game


Reply
 
Thread Tools Display Modes
  #1  
Old 11-24-2009, 12:19 PM
asidebottom asidebottom is offline
Newcomer
 
Join Date: Nov 2009
Posts: 3
Unhappy Help with my Block escape Game


Hi guys. Not sure if this is in the right section, but i am making a Game in VB 6 as a collage project and i really need some help, i have looked at tutorials all over but i cannot find out how to make it so i can
click and hold the green box and slide it left and right only.

the only way i have managed to make it move is by clicking the image so it moves =100 from the left

Any help ?? i have attached the project too
Attached Files
File Type: zip blockescape.zip (55.9 KB, 8 views)
Reply With Quote
  #2  
Old 11-26-2009, 07:07 AM
Iceplug's Avatar
IceplugHelp with my Block escape Game Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

1. Use App.Path for filenames:
Instead of "H:\Year 2\ED Programming\Assignment 1\Escape Block\yes.gif"
use App.Path & "\yes.gif"
I do not have Assignment1\Escape Block folders, etc.

2. LoadPicture ("H:\Year 2\ED Programming\Assignment 1\Escape Block\yes.gif")
That line does nothing useful. It loads the picture from file and then promptly dumps it because you don't assign it to anything. The next line does something helpful.
Image1.Picture = LoadPicture("H:\Year 2\ED Programming\Assignment 1\Escape Block\yes.gif")

3. Private Sub cmdrst_Click()
Form1.Load
End Sub
Form1.Load is not a subroutine.
You need to write a subroutine that resets everything that moves back to their initial locations.

4.
If imgmainblock.Left > 4200 Then
Image1.Picture = LoadPicture(App.Path & "\yes.gif")
Else
Image1.Picture = LoadPicture(App.Path & "\no.gif")
End If
This code should not be in a timer. You only need to check this after imgmainblock actually moves. The block is not going to mysteriously move on its own or through some random net command.
Move the code to the spot that is after where imgmainPicture goes up by 100.
Otherwise, you're loading a picture from memory 100 times every second. That's very wasteful if nothing is changing. Moving this code to the mousedown event now makes the timer useless and you can delete it.

5.
Select Case imgindex
You have a select case with no cases or an End Select.

6.
Private Sub Greenblock2_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single)

End Sub
You won't be able to windows-style dragging unless the block has a DragMode of Automatic. Also, you don't want Windows-style dragging if you only want it to go up and down. And Greenblock = Source.Tag will not work at all. I don't know what you're trying to do there.

7. To get the referenced item in a control array (i.e. Greenblock2), you have to use
Greenblock2(Index)
e.g. Greenblock2(Index).Tag or Greenblock2(Index).Top

8. To drag only up and down, you have to do your own dragging.
To do this, you need to use the MouseDown and MouseMove event.
Each event passes an X and Y coordinate that indicates where you clicked.
You'll want to monitor the changes in the Y coordinate as you move the mouse around while holding down the mouse button. In order to see the change in the Y coordinate, you need the old value of Y.
Ex:
You click and hold the left mouse button on the greenblock at Y = 160. 160 is passed into the MouseDown event as Y.
While holding the left mouse button, you move the mouse to Y = 150. 150 is passed into the MouseMove event as Y.
Now, Y has decreased by 10... so you'd want to move the greenblock up by 10.

But, how can you tell that Y has decreased by 10? Without any way to have the computer remember the value of 160, you can't tell that Y has decreased by 10 to get to 150.
This is where you have to declare a variable. This is very important when making programs - making variables. Lots of people get caught up in the controls that they take too long to transition to declaring variables to hold values in memory.
Dim OldvalueofY As Single 'Variable that holds the value of Y from MouseDown.
So, when you MouseDown, store the value of 160 (or whatever it is) that comes into the MouseDown into the OldvalueofY variable.
OldvalueofY = Y 'Like this, you assign values into the variable.
Now, when you move the mouse with the left button pressed, the MouseMove event will run.
The value of Button will be 1, as opposed to 0, when you move the mouse over the block with no buttons.
check if Button = 1
If Button = 1 Then
'move greenblock
End If
if it is, compare the Y value that comes into the MouseMove (150 or whatever) to the OldvalueofY variable.
The change is new minus old, or Y - OldvalueofY.
This is what you'll change the Greenblock.Top value by:
Greenblock2(Index).Top = Greenblock2(Index).Top + (Y - OldvalueofY)
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #3  
Old 11-27-2009, 08:53 AM
asidebottom asidebottom is offline
Newcomer
 
Join Date: Nov 2009
Posts: 3
Default :o

Thanks ever so much for your help. Not only did you answer my question but you gave me a discription of how it all works and i couldnt really ask for more Thanks for sorting out other pieces of my code too. I got it all working correctly
When i have finished ill upload it again and see what you think. Thanks again
Reply With Quote
  #4  
Old 11-27-2009, 11:09 AM
Iceplug's Avatar
IceplugHelp with my Block escape Game Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

Other things that you may be interested in:
http://www.xtremevbtalk.com/showthread.php?t=54042 Detecting collisions- if your box is touching another box, I assume that you'd want some way to keep the blue box from sliding through the green boxes to the end.
Object Browser F2 - go to MouseButtonConstants. These are the constants that you can use for the different mouse buttons.
If you are only using two images on your form, you can declare StdPicture variables and put the images in those, put hidden image boxes on your form, or use an Imagelist component to put the two images in.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #5  
Old 12-08-2009, 09:33 AM
asidebottom asidebottom is offline
Newcomer
 
Join Date: Nov 2009
Posts: 3
Default Stuck, again!

Hi. Thanks for the post about the collisions, unfortuanatly i havnt been able to understand how to make the boxes colide after hours of stdieing your programs, i was wondering if you could help me a bit more and check to see if i have been doing this project right and help me a little more on the colisions. Thanks. Ash
Attached Files
File Type: zip escapeblock.zip (56.0 KB, 11 views)
Reply With Quote
  #6  
Old 12-12-2009, 06:33 AM
Iceplug's Avatar
IceplugHelp with my Block escape Game Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

Why do you randomly have the word "pop" typed in your code?

To make collision detection easier, you could have all of the greenblocks in one array instead of in two.
To determine if you should only move left or right, perhaps it would be best if you checked if the Width were greater than the Height... if so, then you put your horizontally moving code in the If block... and then you put the vertically moving code in the Else block. It should allow you to move the pieces accordingly while in the same control array.

Did you look at post #4 in the link that I gave you above? Because the If blocks that I provided don't seem to manifest itself anywhere in your program. I see that you have prevented the blocks from sliding out of the area, but in order to check collisions with greenblocks, you have to use the method that I mentioned.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Help with my Block escape Game
Help with my Block escape Game
Help with my Block escape Game Help with my Block escape Game
Help with my Block escape Game
Help with my Block escape Game
Help with my Block escape Game Help with my Block escape Game Help with my Block escape Game Help with my Block escape Game Help with my Block escape Game Help with my Block escape Game Help with my Block escape Game
Help with my Block escape Game
Help with my Block escape Game
 
Help with my Block escape Game
Help with my Block escape Game
 
-->