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 / Please help, problems drawing bricks (breakout)

Author
Message
Whaddaboe
18
Years of Service
User Offline
Joined: 15th Jul 2006
Location:
Posted: 15th Jul 2006 16:25
Hi, im a real n00b at darkbasic (using pro btw)and iv decided to make a breakout game as my second project (did pong a few days ago)

im using an array to record the bricknumber,x position,y position and "whether it has been destroyed or not" for each brick
it looks like this


Then I used this code here to draw the bricks


I ran the program and there were no syntax errors, but it did not draw the bricks. I think im probably missing out a command or something here, so i searched the codebase and found nothing.

Please help,
Thanks in advance
Daemon
18
Years of Service
User Offline
Joined: 16th Dec 2005
Location: Everywhere
Posted: 15th Jul 2006 18:31
You are declaring you array wrong.

What you want are user defined types.

This means before you declare the array you should put-



then you would declare the array-



and then you would access the memory like this



Good luck with this game. (I've already made my own version)

Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 15th Jul 2006 19:57
Actually, he is declaring the array wrongly - and he is referencing it wrongly.

If you want to use plain arrays without getting into UDTs yet (and I would advise mastering arrays first - UDTs are very powerful, but get the basics sorted first!), you need to do

Then you reference it:
brick(1,1) is the x coordinate of brick 1
brick(1,2) is the y coordinate of brick 1
brick(1,3) is whether brick 1 exists
or
brick(29,1) is the x coordinate of brick 29
brick(12,2) is the y coordinate of brick 12
brick(6,3) is whether brick 6 exists

As I said, best to get this under your belt before worrying about UDTs!

"You get what everyone gets, you get a lifetime!" - Death, The Sandman Library

First you Dream, then you ... - Neil Gaiman, 2001
Jay Bee
18
Years of Service
User Offline
Joined: 15th Jul 2006
Location: Ashford, Kent, England
Posted: 16th Jul 2006 07:09
Er thats interesting, for a start you aren't giving bnum a value, and I don't know why it's in the array anyway. Surely you would define bnum outside as 40, and then the array would go a little something like this:



And then the loop to draw the bricks would be:



Hope this helps

-J
Whaddaboe
18
Years of Service
User Offline
Joined: 15th Jul 2006
Location:
Posted: 16th Jul 2006 14:30
OK, iv done what u said, but now i have a different problem.
my array looks like this...

and the code to draw looks like this...

However, when i run the program it says-
"Runtime Error 118 - Array does not exist or array subscript out of bounds at line 62"

line 62 is this line
sprite 3, brick(brick,1), brick(brick,2), imagenumber

Please help
Jay Bee
18
Years of Service
User Offline
Joined: 15th Jul 2006
Location: Ashford, Kent, England
Posted: 16th Jul 2006 18:02
I think you have the wrong end of the stick. Such is my understanding, you can't draw the same sprite multiple times with different image numbers, in fact it is different sprite numbers with the same image number. This code worked for me:

Login to post a reply

Server time is: 2024-09-25 03:39:37
Your offset time is: 2024-09-25 03:39:37