Page 1 of 1

Need help with Visual Basic.

Posted: Wed Oct 31, 2007 12:43 pm
by RuYi
Ok, my turn for a Help with VB topic.

Basically, I want this:
Image
The little squares should be dragged onto the big square.
The little circles to the big circle.

If a circle goes to the square, it should be set back to the start point or whatever.

Problem is, I got no idea how to create a code for that. I been trying to figure it out for the past 2 days and I really have no idea.

I can make everything draggable, but the only problem I got is how to make the circle refuse the squares adn the square should refuse the circle. Don't matter how, as long as they refuse it.

Anyone can help me? :(

Posted: Wed Oct 31, 2007 12:45 pm
by Firemouse
I can't help you, but if it makes you feel any better I tried dragging them :)

Posted: Wed Oct 31, 2007 12:56 pm
by TwelveEleven
msn: twelveeleven1211@gmail.com

We might be able to work something out together.

Posted: Wed Oct 31, 2007 7:48 pm
by Innovacious
Oooh, a game (kinda...) I know how to do this, i made a space invaders in VB once. That was probably one of my greatest creations in VB. And it wasnt just some silly single level clone. It had an unlimited amout of levels, each level the enemy would get faster and shoot more until about level 50 when they would stay the same (got a bit crazy when i made it go faster) Even had pickups n whatnot and the ship that passes by every now and then up the top. I even got so bored i made a bot that would play the game. Wasnt an 100% accurate bot of course, that would be boring, it would even seek out powerups when they came down, if 2 came down it would go for the best and if one was coming down but too many aliens were shooting it would stay back so it didnt get shot.

Damn, i went abit off topic :\ sorry, i loved that game, but i lost all of it, its completley gone :(

anywho, all the shapes (well, almost all objects) have a .left and a .top property, this contains the position of the top of the object and the left of the object (duh). You will also need to use the .width and .hieght properties too.

Code: Select all

if SCircle.left > BCircle.left and (SCircle.left + SCircle.width) < (BCircle.left + BCircle.width) then

      if SCircle.top < BCircle.top and (SCircle.top-SCircle.Height) > (BCricle.top - BCircle.Height then
            'whatever you want to do when the small shape is in the big one
      end if

end if


S=Small B=Big

Of course youll need to modify the names n whatnot and change the code to work with a square too. You could use an array of objects for the smaller shapes but im not sure if they are available in vb.net onwards, they took some sort of array out of it, cant remember which though.

Im guessing i might be a bit late on this anyway, been a while since you posted it.

Posted: Wed Oct 31, 2007 8:00 pm
by RuYi
Not late lol, I got until Friday and I was still clueless about that code.
It helps alot, thanks! :love:

It's cool you managed to create a whole game in it, the codes and all that stuff are too confusing for me. Shame you lost it though. :(