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.

Newcomers DBPro Corner / I need help learning more, please help me out.

Author
Message
Grmreepr
20
Years of Service
User Offline
Joined: 30th Dec 2003
Location: USA
Posted: 14th Jan 2004 01:45
Hi everyone! Well Darkbasic has so far been pretty good, i think ive been learning good (ive had it for about 2 weeks now). Well i've gone through Chris Knott's tutorial in this forum for pong, which helped me out a lot! But i want to continue learning and have seemed to come to a block in the road Anyway, i need to learn more about collision and such mostly. I wanted to try a breakout game because i think its the next step up from pong, but i dont know how to make the blocks go away when they get hit, mostly because of this problem i dont know where to start!? and im not sure how to implement pictures/bmp's (maybe blocks) into it.
I know how to paste the pictures onto the screen, and where to put them, but i dont know how to do the collision and make them go away when hit(blocks). I guess i dont really need pictures if i make it all 3d, but still dunno how to do collision..
Can someone explain how i can do this, and maybe start me off on breakout. Thanks a lot and i hope i learn a lot from it! Once i learn this i'll be able to go to the next step up hopefully with a little less help! Thanks!
By the way, im using DBpro! Thanks!

Amd Athlon 1ghz, 608mb SDRAM, Nvidia GeForce FX 5200 128 DDR ram PCI
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 14th Jan 2004 04:43
I made breakout first, then tetris, then pong. Ok, maybe a strange direction for most, but I go in order of personal preference. Here's some theory, no code, for ya.

Before you add the bricks, make your bat and ball controls into the game first. Make sure you can bounce the ball around ok. Now add the bricks. Because bricks are rectangles, its very easy to write your own collision. It's basically, if ball is within bounding box. You may have to look for some code examples to figure out which side of the brick the ball hits. A few ways you can handle the bricks disappearing after you've hit them. The bricks should be stored in an array. If you're using DBP, then you could make a BRICK TYPE. The BRICK would have 3 variables in it: x, y locations, and an object number(or sprite number if using 2d). You could then make an array of type BRICK. The x and y coordinates would be used for the collision. If there is a collision, then delete the object by the number you have specified at that index in the array. Also, if using DBP, you could use a list array instead of a normal array. When you delete a brick, you would delete the associated array element from the list. Otherwise, you would have to keep a seperate variable containing the number of bricks left. Once the array list reaches zero elements, or the variable reaches zero, then all bricks are gone, level has been completed.

"eureka" - Archimedes
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 14th Jan 2004 13:46
Hi Grmreepr there is also a Grim Reaper on the site. It might be an idea to use a different name.

zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 14th Jan 2004 17:59
For Break Out, images on the screen is not enough. You will need an array that hold the status of every block you have. When you hit a block, you need to update the array location as well. This gets tobe real important when a block needs two or more hits to be removed.

For example, an array like this might describe three rows of blocks with gaps at the end and in the middle. And, the inner row of blocks are doubles that need to be hit twice in order to be reduced to zero.

0,0,0,0,0,0,0,0,0,0,0,0,0
0,1,1,1,1,1,0,1,1,1,1,1,0
0,2,2,2,2,2,0,2,2,2,2,2,0
0,1,1,1,1,1,0,1,1,1,1,1,0
0,0,0,0,0,0,0,0,0,0,0,0,0

An array like this is also important when you think about loading levels or building a level designer.
--
TAZ

Grmreepr
20
Years of Service
User Offline
Joined: 30th Dec 2003
Location: USA
Posted: 14th Jan 2004 23:01
Ok, im starting to get the bigger picture now Im gonna go ahead and code the level and make the ball bounce off the walls. Ill try making the blocks and implementing arrays, but i might (probably) need some help there. Ill probably need help on collision with the array and how to update the array.
Quote: "When you hit a block, you need to update the array location as well."

I also dont know how to implement a list array
Quote: "Also, if using DBP, you could use a list array instead of a normal array. When you delete a brick, you would delete the associated array element from the list. "

I think its the same thing zircher was explaining, but im not sure. I need help here cause i dont have any experience with arrays Anyway, ill go ahead and code as much as i can, maybe experiment with arrays, and ill come back, probably for help with the arrays and collision with them.
Thanks a lot for helping me out!! I appreciate it!

Amd Athlon 1ghz, 608mb SDRAM, Nvidia GeForce FX 5200 128 DDR ram PCI
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 15th Jan 2004 01:00
Arrays come in several flavors with DBP. You have your standard one dimensional and multi-dimensional arrays, but DBP offers the ability to grow and shrink arrays like a stack or a queue (list). It's very clever, but something that you may want to save for later.

For Break Out, a simple 2 dimensional array will suffice. Later on, when you decide to make a Arkanoid clone, you might want a three dimensional array, an array of user defined types, or two indentical arrays (one for brick strength and another to hold which bricks have specials hidden in them.) But, that's a topic for another day.

As part of the game logic, you would not check for collision with the array. The array is your memory and not the game board, per se. When you hit the brick in the 3rd row, 5th column, that's when you update the array location that matches that row and column.

Some psuedo code:


Clear as mud?
--
TAZ

Grmreepr
20
Years of Service
User Offline
Joined: 30th Dec 2003
Location: USA
Posted: 15th Jan 2004 04:19
Thnx a lot zircher! Pretty dang clear Ill be implementing it and once im done with everything we'll see what i end up with. We'll probably see that tomorrow, since its kinda late and i got school tomorrow (unless i get a snow day, snowing quite a lot right now)
Thnx a lot and seeya later hopefully with the finished game!

Amd Athlon 1ghz, 608mb SDRAM, Nvidia GeForce FX 5200 128 DDR ram PCI
Grmreepr
20
Years of Service
User Offline
Joined: 30th Dec 2003
Location: USA
Posted: 16th Jan 2004 01:56
Well, I didnt get that snow day but thats ok.
I finished my main controls, bouncing off walls and paddle, and i'm now ready to add the bricks. I'll be implementing your tips on arrays you gave me and tinkering around with them, if I have any problems I cant solve i'll let you know. I've also included my source code thus far, so you can check it out, its kinda weird. x=0 y=0 is in the middle of the screen, and I had one weird problem I solved

when I had it at bally#=newyvalue(bally#,balla#,2) it thought that 90 degrees was really 0 degrees, and it went up instead of to the right, kinda like that. I suggest you take out that (+90) and see for yourself.... I dont remember why I added the -2 instead of +2, it works either way, I must've did that trying to solve the problem or something. If you know why this problem happened please tell me and explain, so I can learn. It was a weird problem, I solved it through trial and error, o well.
Also, if you have any more tips or suggestions on arrays, do tell!

p.s. @ pincho and others - I like the name grmreepr and have always used it, my email is grmreepr@att.net , if it starts to cause some big problem i'll change it, otherwise i'm really used to the name already and I like it Thanks for letting me know of grim reaper so there wont be any/more mixups!
Seeya later!

Amd Athlon 1ghz, 608mb SDRAM, Nvidia GeForce FX 5200 128 DDR ram PCI
Grmreepr
20
Years of Service
User Offline
Joined: 30th Dec 2003
Location: USA
Posted: 16th Jan 2004 20:59
Wow, I was just trying to figure out the whole array thing, and i totally realized how dumb i am, i cant figure out how to implement the blocks, i thought i knew how to do it after reading zircher's post, which did help in my understanding, but it don't know like how to add the actual blocks into it and how the array plays it's part with them. Ugh, my mind is twisted right know trying to get this, can someone really make it clear for me? My source code for my breakout is on my above post if you want to implement it.
Thanks a lot for everything guys!

Amd Athlon 1ghz, 608mb SDRAM, Nvidia GeForce FX 5200 128 DDR ram PCI
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 17th Jan 2004 00:23
Well, tips are just tips of the iceberg. One thing that you'll need is a fuction that will draw a brick. Somthing where you send the function the brickX, brickY, and the strength of the brick (in case you color code your bricks based on strength or perhaps make all brick with a strength of 9 indestructable and gray like stone.)

To start with, you can use DATA statements or you can create strings and use a loop with the MID command to hold your data.



Every SYNC, you'll need to re-draw the screen. Instead of walking through the set up strings, you'll loop through the array and pass the array values to an updateBrick function. The update function is like the makeBrick function but there is no need to set the array values.
--
TAZ

Login to post a reply

Server time is: 2024-09-21 15:33:29
Your offset time is: 2024-09-21 15:33:29