using whatdotcolour for my game
Author |
Message |
weebly
|
Posted: Thu Jun 05, 2008 9:17 pm Post subject: using whatdotcolour for my game |
|
|
i need to use watdotcolour for my game that i m making. it is basically like a space game, where you move around a space ship and try to dodge asteroid, if the asteroid hits the ship, it's game over, if not, then game continues until the ship has dodged 200 asteroids. what i need to know is how to detect the colosion of the asteroid an the ship. the background colour of the display is black. someone told me i need to use whatdotcolour, but i dont knoe how.
please respond ASAP, thank you
please tell me if u need my code, i will post that after |
|
|
|
|
|
Sponsor Sponsor
|
|
|
weebly
|
Posted: Thu Jun 05, 2008 9:37 pm Post subject: RE:using whatdotcolour for my game |
|
|
oh man, no one is answering |
|
|
|
|
|
Tony
|
Posted: Thu Jun 05, 2008 9:41 pm Post subject: Re: using whatdotcolour for my game |
|
|
weebly @ Thu Jun 05, 2008 9:17 pm wrote: someone told me i need to use whatdotcolour, but i dont knoe how.
It's ok, they don't know what they are talking about anyway.
whatdotcolour will tell you the colour of the pixel at a given location, treating the entire screen as a giant 2D array, full of pixels. The theory is that you check the colour at a location and determine collision from the colour. Except that colour don't overlap, you either see the asteroid or the ship (and even then, only for a certain colour and a certain pixel), then you have to figure out the rest from the locations.
so whatdotcolour becomes redundant, it's unreliable, and it's accuracy depends on how many pixels (and how) you check.
just look into the circular collision detection (that is, collision between two circles). It's a fairly good estimate to the shape of asteroids and/or ships.
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
weebly
|
Posted: Thu Jun 05, 2008 10:06 pm Post subject: RE:using whatdotcolour for my game |
|
|
ok, wow, u just confused me, dude, im a grade 9 student, this is my isp, please explain in simple words, given a code example, like u said 2 circles coliding, make a simple code for that and bit of explaination, and that will do it.
and can u give me tips on how to check for collison, like, my background screen is black so do it say if whatdotcolour not = black, then put "game over" ? i need to understand the logic to it, and a bit of code example, but thnx for ur effort for trying to help me
thnx |
|
|
|
|
|
Tony
|
Posted: Thu Jun 05, 2008 10:12 pm Post subject: RE:using whatdotcolour for my game |
|
|
Try to work it out on paper first. I've already posted a picture of a diagram, above, to get you started. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
weebly
|
Posted: Thu Jun 05, 2008 10:14 pm Post subject: RE:using whatdotcolour for my game |
|
|
k, thnx |
|
|
|
|
|
weebly
|
Posted: Thu Jun 05, 2008 10:16 pm Post subject: RE:using whatdotcolour for my game |
|
|
but 1 more question, how can u keep tract of the coordinate of the ship and asteroids, there is not only one asteroid there r many asteroid coming at once, so how do i kepp tract of each of their coordinate. i guess this is my main problem. i get the logic now |
|
|
|
|
|
weebly
|
Posted: Thu Jun 05, 2008 10:19 pm Post subject: RE:using whatdotcolour for my game |
|
|
"someone told me i need to use whatdotcolour, but i dont knoe how".<<< that someone was my programming teacher, lol, she knoes teaches all programming languages, gr9-12, java, c, c++, c+, turing, etc. so ya, and now back to my question. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
Posted: Thu Jun 05, 2008 10:23 pm Post subject: RE:using whatdotcolour for my game |
|
|
that requires arrays. Now, I realize that arrays are not usually in the scope of grade 9 material (grade 10 topic? depends on the school), but it's actually quite simple. If you read the tutorials (linked to from the Turing Walkthrough), arrays will make this much easier. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
Tony
|
Posted: Thu Jun 05, 2008 10:24 pm Post subject: Re: RE:using whatdotcolour for my game |
|
|
weebly @ Thu Jun 05, 2008 10:19 pm wrote: that someone was my programming teacher
Tell her to join the community. Maybe she'll learn something as well |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
jeffgreco13
|
Posted: Fri Jun 06, 2008 8:35 am Post subject: Re: using whatdotcolour for my game |
|
|
Tony's right your best bet is to create 2 arrays, one for asteroid's x-val and another for the y-val. and then run a procedure that randomly assigns values to each array. That way you'll have randomly placed asteroids, and the number of values you set will be the number of asteroids at one time. To make this program as good as it can be, it's gonna require you to reallly learn past waht you are being taught.
Oh and about your teacher, we're smarter here!!!
and always remember the height and width of your ship play a HUGE role in collision detection, think about it. |
|
|
|
|
|
Tony
|
|
|
|
|
SNIPERDUDE
|
Posted: Fri Jun 06, 2008 9:10 am Post subject: RE:using whatdotcolour for my game |
|
|
types and records are usually best |
|
|
|
|
|
jeffgreco13
|
Posted: Fri Jun 06, 2008 9:33 am Post subject: Re: RE:using whatdotcolour for my game |
|
|
Tony @ Fri Jun 06, 2008 9:07 am wrote: @jeffgreco13 -- I did not say to use parallel arrays.
What exactly are you suggesting Tony? I might be mistaken.. |
|
|
|
|
|
SNIPERDUDE
|
Posted: Fri Jun 06, 2008 10:32 am Post subject: RE:using whatdotcolour for my game |
|
|
he is saying making seperate arrays for x and y values wouldn't be as effective as using something like a record.
So insted of:
code: |
var x : array 1 .. (max num of objects) of int
var y : array 1 .. (max num of objects) of int
|
it would be better if you used something like this:
code: |
type coordinatesProperties : record
X, Y : int
end record
var Coordinates : array 1 .. (max num of obj) of coodinatesProperties
|
then you could easily just call all the coordinates by using a line like this:
code: |
Coordinates(number).X := (whatever)
|
EDIT: It would also be effective if you put all of the objects' properties in the records too, to reduce the number of 'stray' variables lying around that involve the object as well.
An example being:
code: |
type AsteroidProperties : record
X, Y, xVelocity, yVelocity : int
(Any other propertie you want, colour, size, active, health, whatever)
end record
var Asteroid : array 1 .. (max num of obj) of AsteroidProperties
|
...and do a similar thing with the spaceship's properties
(except you wouldn't put that in an array, just use var Ship : ShipProp) |
|
|
|
|
|
|
|