Multiple platform collision detection
Multiple platform collision detection
Multiple platform collision detection
Multiple platform collision detection
Multiple platform collision detection
Multiple platform collision detection Multiple platform collision detection Multiple platform collision detection Multiple platform collision detection Multiple platform collision detection Multiple platform collision detection Multiple platform collision detection Multiple platform collision detection
Multiple platform collision detection Multiple platform collision detection
Multiple platform collision detection
Go Back  Xtreme Visual Basic Talk > > > Multiple platform collision detection


Reply
 
Thread Tools Display Modes
  #1  
Old 01-12-2010, 04:11 PM
wilkewitz wilkewitz is offline
Newcomer
 
Join Date: Jan 2010
Posts: 12
Default Multiple platform collision detection


Lately I have been making a platformer game, just to experiment and see how it would work, and after making two very basic levels I realized that it would take a lot of code to include several or more platforms.

My first question: what is the best way to redesign my code so that it will detect any collisions between the character and any of my platforms without writing code for each individual platform.

Currently I'm trying to use arrays for the left, top, and right properties of all my platforms. I would like to simply change the size of each array to allow for more platforms when needed. I would also like to use a loop for storing all of those properties to the arrays, and also another loop for detecting collisions.

So my second question: Is it possible for me to, inside of the loop, assign each of the different platforms' properties to the arrays?

For example:

Code:
dim numberofplatforms As Integer = 10

Dim platformleft(10) As Integer

For a As Integer = 0 To numberofplatforms

   platformleft(a) = 'My problem is naming the controls for each specific sequence of the variable a
 
Next
That was my original idea, but I don't know how to finish it. So could anybody either help me finish this idea, or explain a better way to include universal platform detection?

Thanks!

Last edited by wilkewitz; 01-12-2010 at 04:27 PM.
Reply With Quote
  #2  
Old 01-12-2010, 06:33 PM
Iceplug's Avatar
IceplugMultiple platform collision detection Iceplug is offline
MetaCenturion

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

Quote:
My first question: what is the best way to redesign my code so that it will detect any collisions between the character and any of my platforms without writing code for each individual platform
Well, I'd recommend storing the values inside of a Rectangle structure and then using an array of rectangles. That way, you have all of the pertinent data grouped together.
Using a List or an Arraylist will let you hold a dynamic number of platforms.
Quote:
So my second question: Is it possible for me to, inside of the loop, assign each of the different platforms' properties to the arrays?
That question doesn't make sense to me - the properties of the platforms (Left, Top, and Right) are the arrays. Where is the data coming from and what should it be going to?

Perhaps my Platform Tour tutorial will be of help (scroll down and use the VB.NET links)
http://www.iceplug.us/code.htm
__________________

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 01-13-2010, 01:55 PM
wilkewitz wilkewitz is offline
Newcomer
 
Join Date: Jan 2010
Posts: 12
Default

Iceplug, In the end I want my arrays (platformleft, platformright, and platformtop) to hold each of my platforms' properties. so my first platforms left property would be stored to platformleft(0), and so on. I also want to be able to do that inside a loop. Each time it loops around it stores the next platform's properties into each of those arrays, but how can my loop know which platform to use for each looparound?

As for your suggestion, a few of those terms I'm not familiar with, so I'll have to figure those out and see for myself.

I will also check out your tut, I might have already just to get the basics of some of the physics.

Thanks!
Reply With Quote
  #4  
Old 01-13-2010, 02:07 PM
Iceplug's Avatar
IceplugMultiple platform collision detection Iceplug is offline
MetaCenturion

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

I still don't know if I understand. It sounds like you want to load default values into your platforms, in which case, you can set them directly into the array using the array initializer
PlatformLeft = New Integer() {200, 300, 400, 700, 260, 600, 500}
Quote:
Each time it loops around it stores the next platform's properties into each of those arrays,
Where are the numbers coming from? I don't think I understand this specific part. From what I have so far, you have all of the platforms' left values stored in the PlatformLeft array, but what does that mean when you say you want to store the platform's "property" into the array which should already contain the left, top, or right value?
Do you mean you want to load a preset map into your game?
__________________

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 01-13-2010, 02:24 PM
wilkewitz wilkewitz is offline
Newcomer
 
Join Date: Jan 2010
Posts: 12
Default

lol

Ok, I looked at your tut and realized you do a totally different take on this than I have been doing.

Like I said in my first post, I just started this to see if it would work and to experiment with the physics and stuff, so yes, I'm currently using a preset map the idea never occurred to me that I could create my platforms after my program has started. I'm not that experienced with game creation, I've taken Computer programming 1 at school and am currently taking 2, but I think I have enough down to continue with my program using your tut.
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
Multiple platform collision detection
Multiple platform collision detection
Multiple platform collision detection Multiple platform collision detection
Multiple platform collision detection
Multiple platform collision detection
Multiple platform collision detection Multiple platform collision detection Multiple platform collision detection Multiple platform collision detection Multiple platform collision detection Multiple platform collision detection Multiple platform collision detection
Multiple platform collision detection
Multiple platform collision detection
 
Multiple platform collision detection
Multiple platform collision detection
 
-->