Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / A couple of issues

Author
Message
Pog Mo Hone
14
Years of Service
User Offline
Joined: 21st May 2010
Location:
Posted: 24th Jun 2010 06:10
Ive always had trouble working with arrays. For those who have responded to my previous posts, you have an idea Im creating a simple block break game. I based my code off the Dark Invaders tutorial from the GDK files. I replaced the alien ships with my own sprites and made them stationary. The array was 5x5 which I managed to make larger. Its quite confusing on how to make the sprites to show properly. The for loops used start with the declared integer with a 9 or a 10...when I altered the for loops to show more sprites in the array it often would have random sprites missing from the array when I ran the program. I had to raise the integer from 9 or 10 to about 100 to show a 7x8 array. I am still confused on why this is.

My game displays a 7x8 array and all respond to the ball touching them, which makes them disapear...my problem is a couple things: one is that the second block in the upper left corner disapears when the ball touches the first one to the left of it. Another is the collision. Ive tried used dbSpriteCollision() with the dbTimer as one showed me to do with the ball/paddle collision and it doesnt seem to work. Oddly, when I placed in the code that was similar to the paddle/ball collision, the ball would bounce off the blocks(not all of them), but would bounce off at a very different angle. I got rid of that and am still at a stop on how to get the ball to bounce off of them.

If anyone understands what I am saying, would it be possible to explain how the for loops work with the arrays for the alien ships on the Dark Invader game? And also mind directing me on how to make the ball bounce off the blocks for my game?

Thanks!

"Wisemen say: Forgiveness is divine, but never pay full price for late pizza." - Michaelangelo
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 25th Jun 2010 03:36
It would really be helpful if we could see the relevant code. Show some code and we'll see what we can do to help.

JTK
Pog Mo Hone
14
Years of Service
User Offline
Joined: 21st May 2010
Location:
Posted: 28th Jun 2010 04:51
Ah ya sorry. =) I figured I should have done that. First, how do I place the code snippets. I see the little icon for code and two brackets pop up. I put the code within and it doesnt work.

"Wisemen say: Forgiveness is divine, but never pay full price for late pizza." - Michaelangelo
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 28th Jun 2010 06:56 Edited at: 28th Jun 2010 06:57
Ok. You have the "code" button at the top of the edit box that you use to edit your message; but that aside:

type "[""code""]"
then paste your code...
then type "[""/code""]"

without the quote marks, that should do it...

If you click the "code" button, make sure you do it before and after the code that you place...

Regards,

JTK
Pog Mo Hone
14
Years of Service
User Offline
Joined: 21st May 2010
Location:
Posted: 29th Jun 2010 07:20
Thanks.

Now this what Ive come to. when I set it up as a 7x8 array I had to raise the integer variable iSprite to 101. I tinkered with it long enough to find that raising this number so it would show all the blocks in the array because all the lower numbers would have 3-5 blocks randomly missing. As I raised the number and tested it, it seemed to shift the missing blocks over one place. I incremented until 101 showed them all. This is the function for the blocks:



This is the entire function for the collision between the ball and block, which I had to set them to fit the array.



The problem Im having is, of course, the bounce response with collision. The other thing is that the ball starts the game moving to the upper left screen. When it hits the first set of blocks in the lower left part it causes the first and second blocks of the array to disapear too before they were even touched.

"Wisemen say: Forgiveness is divine, but never pay full price for late pizza." - Michaelangelo
Pog Mo Hone
14
Years of Service
User Offline
Joined: 21st May 2010
Location:
Posted: 2nd Jul 2010 20:03
Anyone anyone? Im close to having this game finished! Plllleeasssee Eddie!

"Wisemen say: Forgiveness is divine, but never pay full price for late pizza." - Michaelangelo
Pog Mo Hone
14
Years of Service
User Offline
Joined: 21st May 2010
Location:
Posted: 9th Jul 2010 21:52
133 views on this topic and no one can give any information?

"Wisemen say: Forgiveness is divine, but never pay full price for late pizza." - Michaelangelo
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 9th Jul 2010 22:44 Edited at: 9th Jul 2010 22:45
Sorry, I forgot about this thread...

Quote: "
a couple things: one is that the second block in the upper left corner disapears when the ball touches the first one to the left of it. Another is the collision.
"


With only the above code snippets, I'll tell you what I'm seeing that may cause this problem...

The very first command you have in the for(ix)..loop (ballcheckhitblocks function) is to increase the block sprite's ID. This will completely by-pass the first block-sprite id that you created in the blockspawn function. You can alleviate this problem by defaulting blockspriteId's value to 100 instead of 101...

Hope this helps some...

JTK
Pog Mo Hone
14
Years of Service
User Offline
Joined: 21st May 2010
Location:
Posted: 9th Jul 2010 23:06
But why does the variable have to be so high? That variable before the for loop is really throwing me off.

"Wisemen say: Forgiveness is divine, but never pay full price for late pizza." - Michaelangelo
Pog Mo Hone
14
Years of Service
User Offline
Joined: 21st May 2010
Location:
Posted: 9th Jul 2010 23:08
Hmm that made it worse too. It hits the next two to the right of the left blocks.

"Wisemen say: Forgiveness is divine, but never pay full price for late pizza." - Michaelangelo
Pog Mo Hone
14
Years of Service
User Offline
Joined: 21st May 2010
Location:
Posted: 9th Jul 2010 23:27
Alright I got it to work. Had to raise blockSprite to 110 and iSprite to 111. All blocks show and respond to the ball properly. Now its down to gettin the ball to bounce off the blocks. I tried the dbTimer = collisionOn set up you refered to me with the ball and paddle collision, JTK. Would this situation work with the array too?

"Wisemen say: Forgiveness is divine, but never pay full price for late pizza." - Michaelangelo
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 9th Jul 2010 23:47
Quote: "
I tried the dbTimer = collisionOn set up you refered to me with the ball and paddle collision, JTK
"


I don't recall mentioning anything like this so you're probably thinking about someone else. But thread are you talking about (I recall reading something like that) and I'll see if I can answer your question...

JTK
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 10th Jul 2010 00:00
Ok, I found it here. It was cuddle bunniezzz that made that suggestion.

Anyway, to answer your question, yes. It will work with arrays too, but you would have to store the "last-hit" time in an array (the same size as the blocks array)



However, in my opinion, you should be wrapping all of this stuff into a single struct and storing that struct in the array:



and replace your current blocks_alive array with it instead...

Otherwise, you would need an array of last_times that is the same dimensions as the current blocks_alive array for reference.

I hope this helps,

JTK
Pog Mo Hone
14
Years of Service
User Offline
Joined: 21st May 2010
Location:
Posted: 15th Jul 2010 19:52
Very nice. Thanks for answering. I will work on this and get back to ya in anything else comes up. Greatly appreciate your knowledge.

"Wisemen say: Forgiveness is divine, but never pay full price for late pizza." - Michaelangelo

Login to post a reply

Server time is: 2024-07-04 09:43:01
Your offset time is: 2024-07-04 09:43:01