Question game help

malctron

New member
Joined
Jun 1, 2010
Messages
4
Programming Experience
Beginner
Hi,I have created a pacman sort of game, and I am having some problems with it, everything eorks but when I randomise the treasure pacman needs to collect it randomises it on the green which pacman isn't allowed to go on to. So I need to have a colour detection but I can't seem to get it to work, any help would be great cause this is a assignment project and I need it perfect, if anyone could have the code to look at I would be very gratefull.

Hope someone can help
malc
 
this is the code that I think is messing it up
Sub RandomLocation(ByVal s As Sprite)


s.x = Math.Floor(((Me.BackgroundImage.Width - s.getWidth) - 0 + 1) * Rnd() + 5)
s.y = Math.Floor(((Me.BackgroundImage.Height - s.getHeight) - 0 + 1) * Rnd() + 5)


End Sub

is there any way of incorparating a colour checker for the background on this?
 
Ok i've done a lot game development, especially in XNA so i'll try and help you as much as I can in a VB.NET way.

First of all, If you are having pacman wandering around and you would like him not to be able to pass onto certain areas. I recomend you initiate a tile map. (Google it, there's a lot of info on them)

Ok so back to your problem:

This could (should) work for you to be able to extract the color from your background image into an array. as r,g,b - and then you can use this to your willing:

VB.NET:
dim bgColor() as Color(background.Height, background.Width)
bgColor = mySprite.GetData

Note: this code won't compile, but you can see where im headed, just fiddle with it a bit to get it to work.
 
Thanks for the piece of code but I couldn't get it to work :S, I hate visual basic haha no offence if people love it.

I'll have to ask my tutour for help ¬¬
 
Back
Top