Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Want to check condition if 2 objects meet together


Reply
 
Thread Tools Display Modes
  #1  
Old 03-29-2001, 08:26 AM
Kezman Kezman is offline
Freshman
 
Join Date: Mar 2001
Posts: 41
Default Want to check condition if 2 objects meet together


i have just tried doing that
but i have only succeed in one part of it....
and not the other part....

im trying to do a game
which involve to object shooting each other
one will shoot upwards
while another will shoot downwards....

for the one shooting upward im able to get it
but not the one shooting downwards

so i hope u guys can assist me

<<<my source code for shooting up>>>
Private Sub tmrHit_Timer()
If imgEnemy.Top - imgbullet(0).Top <= 480 And imgEnemy.Top - imgbullet(0).Top >= 0 Then
If imgEnemy.Left - imgbullet(0).Left <= 240 And imgEnemy.Left - imgbullet(0).Left >= -240 Then
Enemylife.Value = Enemylife.Value - 10
imgbullet(0).Visible = False
If Enemylife.Value = 0 Then
imgEnemy.Visible = False
End If
End If
End If


can someone help me figure out the shooting down part ?
if u need other information
pls tell me

Reply With Quote
  #2  
Old 03-29-2001, 08:38 AM
Ad1 Ad1 is offline
Senior Contributor

Retired Moderator
* Expert *
 
Join Date: Feb 2001
Location: UK
Posts: 1,287
Default Re: Want to check condition if 2 objects meet together

I have made a similair game before
my code was something like this
<pre>if imgBullet.top>imgEnemy.top and imgbullet.top < imgenemy.top + imgenemy.height then
if imgbullet.left > imgenemy.left and imgbullet.left < imgenemy.left + imgenemy.width then

'''enemy dead
endif
endif

Reply With Quote
  #3  
Old 03-29-2001, 09:19 AM
Kezman Kezman is offline
Freshman
 
Join Date: Mar 2001
Posts: 41
Default Re: Want to check condition if 2 objects meet together

the code does works
but it isnt really wat im looking for

the enemylife.value is actually a progress which i wanted to show wat's the current health of the unit
each hit it will decrement 10 points
the total is 100....

after combining both ur code and mine....
the decrement value was increase


Reply With Quote
  #4  
Old 03-30-2001, 01:30 AM
Ad1 Ad1 is offline
Senior Contributor

Retired Moderator
* Expert *
 
Join Date: Feb 2001
Location: UK
Posts: 1,287
Default Re: Want to check condition if 2 objects meet together

<pre>dim intenemylife as integer
intenemylife=100

if imgBullet.top > imgEnemy.top and imgbullet.top < imgenemy.top + imgenemy.height then
if imgbullet.left > imgenemy.left and imgbullet.left < imgenemy.left + imgenemy.width then
intenemylife = intenemylife - 10
text1.text = intenemylife
if intenemylife = 0 then
subEnemyExplode
endif
endif
endif</pre>
this should work for you

Reply With Quote
  #5  
Old 03-31-2001, 11:02 AM
Kezman Kezman is offline
Freshman
 
Join Date: Mar 2001
Posts: 41
Default Re: Want to check condition if 2 objects meet together

oh yes....
it does works this time......
thank you!

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
 
 
-->