Colision Between 2 Images on VB6.0
Colision Between 2 Images on VB6.0
Colision Between 2 Images on VB6.0
Colision Between 2 Images on VB6.0
Colision Between 2 Images on VB6.0
Colision Between 2 Images on VB6.0 Colision Between 2 Images on VB6.0 Colision Between 2 Images on VB6.0 Colision Between 2 Images on VB6.0 Colision Between 2 Images on VB6.0 Colision Between 2 Images on VB6.0 Colision Between 2 Images on VB6.0 Colision Between 2 Images on VB6.0
Colision Between 2 Images on VB6.0 Colision Between 2 Images on VB6.0
Colision Between 2 Images on VB6.0
Go Back  Xtreme Visual Basic Talk > > > Colision Between 2 Images on VB6.0


Reply
 
Thread Tools Display Modes
  #1  
Old 07-31-2017, 12:56 PM
kaitoby kaitoby is offline
Newcomer
 
Join Date: Jul 2017
Posts: 2
Unhappy Colision Between 2 Images on VB6.0


Hello, My name its cristobal
im currently doing a project. Its a "Ship" simulator in 2D
im using Visual basic 6.0 my current version to execute my program and until now everything its going well enought
but i had a problem.
i can made my "boat" move througt the module.
but it goes off the limits and doesnt colide with the other imageboxes.
i do literally all the codes
even with Bound the program simply doesnt recognize the codes i use...
Anyone can help me? i give the picture of the program and the code i use


e9d542cda73cf0048a6d0a3590ecdd70.jpg


Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 38 Then
    Bote.Top = Bote.Top - 10
    Bote.Picture = BoteARR.Picture
End If
If KeyCode = 40 Then
    Bote.Top = Bote.Top + 10
    Bote.Picture = BoteABJ.Picture
End If
If KeyCode = 37 Then
    Bote.Left = Bote.Left - 10
    Bote.Picture = BoteIZQ.Picture
End If
If KeyCode = 39 Then
    Bote.Left = Bote.Left + 10
    Bote.Picture = BoteDER.Picture
End If
End Sub
Reply With Quote
  #2  
Old 08-01-2017, 06:48 AM
TheRealTinTin's Avatar
TheRealTinTin TheRealTinTin is offline
Junior Contributor
 
Join Date: Nov 2008
Location: Glasgow, UK
Posts: 383
Default

Hi kaitoby,

Where is your collision detection logic? Objects will not simply collide, you have to code them to do so.
__________________
Artificial Intelligence is no match for natural stupidity
Reply With Quote
  #3  
Old 08-01-2017, 12:15 PM
kaitoby kaitoby is offline
Newcomer
 
Join Date: Jul 2017
Posts: 2
Default

Quote:
Originally Posted by TheRealTinTin View Post
Hi kaitoby,

Where is your collision detection logic? Objects will not simply collide, you have to code them to do so.
How do i do that? /: im really good programming
Reply With Quote
  #4  
Old 08-02-2017, 04:14 AM
Goggy's Avatar
Goggy Goggy is offline
Contributor
 
Join Date: Sep 2005
Location: Enschede,The Netherlands
Posts: 670
Default

Simply said....

Check all the corners of your object with all the corners of the other objects. When they overlap you have a collition.
__________________
As finishing touch, god created the Dutch!

utterly useless, but always trying to help
Reply With Quote
  #5  
Old 08-03-2017, 05:38 AM
TheRealTinTin's Avatar
TheRealTinTin TheRealTinTin is offline
Junior Contributor
 
Join Date: Nov 2008
Location: Glasgow, UK
Posts: 383
Default

As Goggy has said, you need to check where the boat is in comparison to all other objects. Given the simplicity of your map, you could simply create a 2D array that stores whether the relevant pixel is water or an object.

Imagine your image is 600x600. In the top corner, you have 1 square object that is 150x150. You would create an array
Code:
Dim Map(599, 599) As Int
Then define the object:
Code:
Dim x As Int
Dim y As Int

For x = 0 To 149
    For y = 0 To 149
        Map(x, y) = 1
    Next y
Next x
Now, when you move your boat you can use it's .Top, .Left, .Width and .Height properties to determine if it's hit anything by checking those co-ordinates against your array. If any of the array elements where the boat is are 1, it has hit something.
__________________
Artificial Intelligence is no match for natural stupidity
Reply With Quote
Reply

Tags
bote.top, bote.left, bote.picture, keycode, program, integer, codes, boteabj.picture, bound, simply, recognize, boteder.picture, literally, boteizq.picture, botearr.picture, private, form_keydownkeycode, imageboxes, code, shift, picture, module, simulator, ship, project


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
Colision Between 2 Images on VB6.0
Colision Between 2 Images on VB6.0
Colision Between 2 Images on VB6.0 Colision Between 2 Images on VB6.0
Colision Between 2 Images on VB6.0
Colision Between 2 Images on VB6.0
Colision Between 2 Images on VB6.0 Colision Between 2 Images on VB6.0 Colision Between 2 Images on VB6.0 Colision Between 2 Images on VB6.0 Colision Between 2 Images on VB6.0 Colision Between 2 Images on VB6.0 Colision Between 2 Images on VB6.0
Colision Between 2 Images on VB6.0
Colision Between 2 Images on VB6.0
 
Colision Between 2 Images on VB6.0
Colision Between 2 Images on VB6.0
 
-->