Pacman VB
Pacman VB
Pacman VB
Pacman VB
Pacman VB
Pacman VB Pacman VB Pacman VB Pacman VB Pacman VB Pacman VB Pacman VB Pacman VB
Pacman VB Pacman VB
Pacman VB
Go Back  Xtreme Visual Basic Talk > > > Pacman VB


Reply
 
Thread Tools Display Modes
  #1  
Old 12-13-2010, 06:53 AM
iSt00z0 iSt00z0 is offline
Newcomer
 
Join Date: Dec 2010
Location: Dundee, Scotland.
Posts: 2
Unhappy Pacman VB


Me and a friend are re-making the classic Pacman game on VB for our Adv. Higher Computing project.
I have a piece of Collision Detection code for Pacman.
Would anyone be able to give me an idea of how to adapt it to apply to one of the ghosts, just to start off?

Code:
Dim i As Long
Dim moveable As Boolean
moveable = True

Select Case moveref
Case 1
For i = 0 To wall.Count - 1
If pacman.Left >= wall(i).Left And pacman.Left <= wall(i).Left + wall(i).Width And pacman.Top - speed >= wall(i).Top And pacman.Top - speed <= wall(i).Top + wall(i).Height Then
moveable = False
End If
If pacman.Left + pacman.Width >= wall(i).Left And pacman.Left + pacman.Width <= wall(i).Left + wall(i).Width And pacman.Top - speed >= wall(i).Top And pacman.Top - speed <= wall(i).Top + wall(i).Height Then
moveable = False
End If
If pacman.Left >= wall(i).Left And pacman.Left <= wall(i).Left + wall(i).Width And pacman.Top - speed + pacman.Height >= wall(i).Top And pacman.Top - speed + pacman.Height <= wall(i).Top + wall(i).Height Then
moveable = False
End If
If pacman.Left + pacman.Width >= wall(i).Left And pacman.Left + pacman.Width <= wall(i).Left + wall(i).Width And pacman.Top - speed + pacman.Height >= wall(i).Top And pacman.Top - speed + pacman.Height <= wall(i).Top + wall(i).Height Then
moveable = False
End If

If moveable = True Then
moveit
End If
This is just the first case. I have it for 4 different cases.

Thanks for any help.
C:

[EDIT:]
I was just thinking, would it just be a case of renaming "pacman" with the seleceted Ghost?
E.g. "Blinky.left => ...."

Last edited by iSt00z0; 12-13-2010 at 07:16 AM.
Reply With Quote
  #2  
Old 12-13-2010, 06:25 PM
ZaCkOX's Avatar
ZaCkOX ZaCkOX is offline
Contributor
 
Join Date: May 2006
Location: CA
Posts: 645
Default Welcome

Hi, it would be better to keep the lines shorter. Either use "_" underscore to move statements to the next line or create functions to check certain statements.

Also I don't think this makes much sense:

If Pacman's Left Position is greater than or equal to the wall's left position... this should be within collision already? IF that was happening.

If you move pacman against a wall it would more likely be the wall's right position to the pacman's left position. So you should start slowly and look at how 1 position should be first. Then next position. You can download and review the picture example I made.

Ah now I'm all confused. I don't work well with very long text...

It would be nice to make a class for the ghost. Then you could instance it to all ghosts. Not to mention (or should haha), the ghosts should be able to go through each other.
Attached Images
File Type: jpg pacmanwallexample.JPG (8.6 KB, 23 views)
__________________
ZaCkO ... Who is your attitude?

Last edited by ZaCkOX; 12-13-2010 at 06:45 PM.
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
Pacman VB
Pacman VB
Pacman VB Pacman VB
Pacman VB
Pacman VB
Pacman VB Pacman VB Pacman VB Pacman VB Pacman VB Pacman VB Pacman VB
Pacman VB
Pacman VB
 
Pacman VB
Pacman VB
 
-->