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.

DarkBASIC Discussion / box command need help please

Author
Message
viperjay
22
Years of Service
User Offline
Joined: 19th Dec 2002
Location: United States
Posted: 28th Jul 2003 09:34
Hi,

I would like to draw 4 equal size boxes anywhere on the screen and then loop and color each square a color. I have looked at the tutorial from www.darkbasic.com webpage under the 2d section and the example from darkbasic help but are still confused of the way the squares are being ploted and understanding how to do this mathematically, so far this is what I got from the code.

I think I am getting hung up on the math.

Thanks for your time

Pentium 4 cpu 1600mhz
768 MB of ram
darkbasic classic 1.13
nvidia geforce3 ti200
Lecks
21
Years of Service
User Offline
Joined: 20th Jul 2003
Location: - Please Select -
Posted: 28th Jul 2003 10:10 Edited at: 28th Jul 2003 10:14
when u create a box it creates it at 0,0,0 (X,Y,Z) in 3D space (which is also where the camera starts. you can then position the box somewhere in 3d space, which you will want to be infront of the camera.
maybe this will help:


it makes 4 boxes and positions them, then colours them using random rgb values. i can simplify it a bit if u don't understand the programming concepts i've used

EDIT: oops i just realised you're trying to work in 2D .
I've heard darkbasic is very slow in 2D, and you would be better off using 3D 'planes' and positioning them right infront of the camera

ReD_eYe
22
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 28th Jul 2003 10:46
the way boxes work is that you specify two sets of coordinates(x and y) on the screen and then the command draws a box between these 2 points so for instance this command
box 10,10,100,100
will make a box with the top left corner at 10,10 and the bottom right corner at 100,100 so:
box x1,y1,x2,y2 is how to do it and the main thing to remember is top left bottom right.
to answer specifically what you wanted to do heres sme code


and here's a function that allows you specify just 1 set of coordinates and a size value to place a box


and heres how to use it


hope that helps

You know whats weird???
Donald duck never wore pants, yet everything time he got out of the shower he put a towel around his waist...
Whats with that???
freak
22
Years of Service
User Offline
Joined: 20th Jan 2003
Location:
Posted: 28th Jul 2003 15:22
I've heard darkbasic is very slow in 2D, and you would be better off using 3D 'planes' and positioning them right infront of the camera

when you only use commands like box, line, dot, circle, paste image etc your programs can be fast (if your code is okay)

only when you use sprites with the default flag settings it's very slow... in that case it might be smarter to use 3d plains instead

[href]www.bernardfrancois.com[/href]
viperjay
22
Years of Service
User Offline
Joined: 19th Dec 2002
Location: United States
Posted: 28th Jul 2003 18:53
ReD_eYe the code you created hit's it right on the button but I do not understand it. how did you know to div x-(size/2),y-(size/2),x+(size/2),y+(size/2). I tired to look at some math books on graphing but it base on the o,o being in the middle of the screen and acording to you and the web and help system 0,0 starts at the upper right of the screen.


freak and Lecks thank you for your information as well.

Thanks for your time.
ReD_eYe
22
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 28th Jul 2003 19:32
0,0 starts at the top left.
its hard to explain but basically you need to find the 2 sets of coordinates based on one set and the size so if the single set of coordinates is in the middle of the box it is half way between the two coordinates needed to make the box, so to find the two other coordinates we need to add or minus half the size. its not really complicated maths just takes a while to get your head around.

You know whats weird???
Donald duck never wore pants, yet everything time he got out of the shower he put a towel around his waist...
Whats with that???
viperjay
22
Years of Service
User Offline
Joined: 19th Dec 2002
Location: United States
Posted: 28th Jul 2003 21:31
Red_eye

This is what I understand so far the box statment
box(left,top,right,bottom)
If I type box 10,10,20,20 it would look something like this
x
10 20 30 40 50
10 x---
| |
y 20 ---x

now if I wanted to say draw a box next to that one I would have to look at the graph and figure out this by hand and say
box 30,10, 40,20

x
10 20 30 40 50
10 x--- x ---
| | | |
y 20 ---x --- x


It is very hard for me to visualize this on the screen without drawing a graphic like this. I have a feeling that math would make this alot faster but I need either a step by step way of learning this method or a book I could read on the subject, because of my weak math skills I can't just wing it, I need to know why it is that number. The math part is really holding me back on game projects.

Thanks for your time and help
viperjay
22
Years of Service
User Offline
Joined: 19th Dec 2002
Location: United States
Posted: 28th Jul 2003 21:42
Somehow my graphic got goof up let me know if you want me to draw it in case you don't understand what I am saying

If I type box 10,10,20,20 it would look something like this

x = 10
y = 10
x = 20
y = 20

now if I wanted to say draw a box next to that one I would have to look at the graph and figure out this by hand and say
box 30,10, 40,20

x = 30
y = 10
x = 40
x = 20

again thanks for your time
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 28th Jul 2003 22:13
if x is at 10 and the box is 20 wide then the edge of the box is at 30 (10+20=30)

likewise

if the box has x=30 and is 50 wide then box ends at 80 (30+50)

easy yes?

you do the same for the y co-ordinate, just add x to x to get the postion of the far edge and y to y to get the position of the lower edge.
the darkbasic system has the top left as 0,0 and the values increase as you right and down, if you have the screen set to 640,480 then position 640,480 is the bottom most righthand pixel on the screen, if the screen was 1024,768 then the lowest position is 768 and the rightmost is 1024, oh! and a pixel is the small square dot that makes up the image on a computer when they are all added together, cheers.

Mentor.

ReD_eYe
22
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 28th Jul 2003 22:30
viperjay i think you've got it! although i've never really found boxes that useful other than for quick sprite image creation

I have a website!!!
So go there: http://www.freewebs.com/darkb/index.htm
on second thought you probably shouldn't
viperjay
22
Years of Service
User Offline
Joined: 19th Dec 2002
Location: United States
Posted: 28th Jul 2003 23:02
Mentor

when you say "...the box is 20 wide" do you mean y varible ? ex
box 10,wide, <-- ?

Also when you say "do the same for the y co-ordinate..."
e.g. box 10,20,30,40 and so if I wanted to draw next to this box I would add x to x y to y ? twice ? box 10+30,20+40,10+30,20+40 ? I am so confused

Thanks for your time
ReD_eYe
22
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 28th Jul 2003 23:22
when he says its 20 wide he means that there is 20 pixels from one edge of the box to another


I have a website!!!
So go there: http://www.freewebs.com/darkb/index.htm
on second thought you probably shouldn't
viperjay
22
Years of Service
User Offline
Joined: 19th Dec 2002
Location: United States
Posted: 29th Jul 2003 00:31
"if x is at 10 and the box is 20 wide" does this mean box 10,0,0,20?

"add x to x to get the postion of edge and y to y to get the position of the lower edge" --> still a puzzle to me

Red eye in your example is this how would code it in box statment?
box 0,0,20,20 or x=0,y=0,x=20,y=20

Thanks for your time
Lecks
21
Years of Service
User Offline
Joined: 20th Jul 2003
Location: - Please Select -
Posted: 29th Jul 2003 08:44
have u had a look at the example from the help? just remember ink rgb() sets the colour, and rnd(640) makes a random number from 0-640. I think that's all you might not know
good luck


ReD_eYe
22
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 29th Jul 2003 11:38
if x is at 10 and the box is 20 wide so

x=10
x2=10+width of box(20)=30
y=10
y2=height of box(20)=30
box x,y,x2,y2

this will make a box that has all sides equal each side will be 20 pixels in length.

I have a website!!!
So go there: http://www.freewebs.com/darkb/index.htm
on second thought you probably shouldn't
viperjay
22
Years of Service
User Offline
Joined: 19th Dec 2002
Location: United States
Posted: 30th Jul 2003 09:08
Thanks for everyone's help. I now get how to draw a box next each other but now I am having a hard time a box from the top to bottom and then a box next to that one. I am going to sleep on it. I can't wait!!! once I conquer this hopefully I will be able to understand get image statment. Cant wait , can't wait ... so tired ..... sleepy.... zzzz
freak
22
Years of Service
User Offline
Joined: 20th Jan 2003
Location:
Posted: 30th Jul 2003 10:03
viperjay, if you want such text drawings not messed up, place them between code tags



[href]www.bernardfrancois.com[/href]
ReD_eYe
22
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 30th Jul 2003 16:03
thats a very pretty picture freak!

I have a website!!!
So go there: http://www.freewebs.com/darkb/index.htm
on second thought you probably shouldn't
freak
22
Years of Service
User Offline
Joined: 20th Jan 2003
Location:
Posted: 30th Jul 2003 20:07
I didn't made that picture: I just found it on google searching 'ascii art'

I tried a few times to make such pictures but they were never that good... I would rater write a program for it

[href]www.bernardfrancois.com[/href]
Ag3ntSm1th
22
Years of Service
User Offline
Joined: 13th May 2003
Location:
Posted: 30th Jul 2003 23:18 Edited at: 30th Jul 2003 23:19
i know this is off subject, but here's a really cool asciimation...


"The secret to creativity is knowing how to hide your sources." - Einstein
my DarkBasic creations - http://www.sixurbanninjas.tk
viperjay
22
Years of Service
User Offline
Joined: 19th Dec 2002
Location: United States
Posted: 31st Jul 2003 05:58
That is really cool
ReD_eYe
22
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 31st Jul 2003 11:57
bugger me thats good!

I have a website!!!
So go there: http://www.freewebs.com/darkb/index.htm
on second thought you probably shouldn't
Hell IVIonkey
22
Years of Service
User Offline
Joined: 1st Apr 2003
Location: Outer Limits
Posted: 31st Jul 2003 12:33
Looks like an AALIB conversion of an animation.

freak
22
Years of Service
User Offline
Joined: 20th Jan 2003
Location:
Posted: 31st Jul 2003 13:52
nice, but not as small as text... using javascript it could be much smaller I guess

[href]www.bernardfrancois.com[/href]
Hell IVIonkey
22
Years of Service
User Offline
Joined: 1st Apr 2003
Location: Outer Limits
Posted: 31st Jul 2003 14:55
Here's something both awesome and terribly sad at the same time...
AALIB Quake!
http://webpages.mr.net/bobz/ttyquake/ss/ - screenies

freak
22
Years of Service
User Offline
Joined: 20th Jan 2003
Location:
Posted: 31st Jul 2003 18:32
indeed... looks cool but I don't think it's very playable...
can you download it somewhere?

[href]www.bernardfrancois.com[/href]
Lecks
21
Years of Service
User Offline
Joined: 20th Jul 2003
Location: - Please Select -
Posted: 31st Jul 2003 21:38
http://webpages.mr.net/bobz/ttyquake/
its for linux and u need quake

viperjay
22
Years of Service
User Offline
Joined: 19th Dec 2002
Location: United States
Posted: 3rd Aug 2003 02:17
how come my topic folder turn red ?
UnderLord
21
Years of Service
User Offline
Joined: 2nd Aug 2003
Location:
Posted: 3rd Aug 2003 03:01
Because your special...

http://www.freewebs.com/independant/
viperjay
22
Years of Service
User Offline
Joined: 19th Dec 2002
Location: United States
Posted: 3rd Aug 2003 07:35
I am slowing getting it. I tried the get image command and I could grab and paste it any where on the screen which made me feel really good. I am now working on tut eight "walking sprite" the image is 640 x 240. in the code example there is this line "get image 1+x+(y*7),(x*89),(y*120),(x*89),(y*120)+120". I do not understand why he multiplied the y varible first when the rule is to multiply x first next I don't understand where he got the number 89 from ? I understand how he got 120 by dividing 240 by 2
thanks for your time

viperjay
Lecks
21
Years of Service
User Offline
Joined: 20th Jul 2003
Location: - Please Select -
Posted: 3rd Aug 2003 10:26


x = 0 to 6 : theres 7 sprites along the x axis. 640 / 7 = around 89

1+x+(y*7) : either 1+6 or 1+x+7. just the object number. if you look at the loop and step through it mentally, this will be 1-14 by the time both for loops have ended.

(x*89) : the left position of the current sprite in the bitmap. will be 0, 89, 178, 267, to 534.

(y*120) : the top of the current sprite in the bitmap. will be either 0 or 120.

(x*89) + 89 : the right position of the current sprite in the bitmap. will be 89, 178, 267 to 623.

(y*120)+120 : the bottom of the current sprite in the bitmap. will be either 120, or 240.


Quote: "
I do not understand why he multiplied the y varible first when the rule is to multiply x first.
"

I don't know what rule you're talking about . the first multiplication is simply to get the image number. the syntax for get image is:
GET IMAGE Image Number, leftx, topy, rightx, bottomy

I hope this helps, good luck.

viperjay
22
Years of Service
User Offline
Joined: 19th Dec 2002
Location: United States
Posted: 5th Aug 2003 00:27
after looking at this and blocking out all the operations I see that
each frame is 89x120 or in a image statement 1,0,0,89,120?

quote: "640 / 7 = around 89"
my calculator says 91.428571428571428571428571428571 how did you around 89 ? wouldn't it be 91 ?

thanks for your time
Lecks
21
Years of Service
User Offline
Joined: 20th Jul 2003
Location: - Please Select -
Posted: 5th Aug 2003 10:44
the 2.428571428571428571428571428571 * 7 pixels are probrably at the right edge of the bitmap, and they just made it 640 wide to make it a 'special' number, which is compatible with more video cards (i think). dont i dont know the exact equation, but textures should be in certain sizes. i know 1 method is 2^X, eg 2x2, 4x4, 8x8, 16x16, 32x32, 64x64, 128x128, 256x256, 512x512, 1024x1024, or combinations such as 128x256.

these numbers can also be added together, eg. 512+128 = 640, and 128 + 64 + 32 + 16 = 240.
The only rule is every number can only be added once. This is because of how binary works, but i wont go into that

viperjay
22
Years of Service
User Offline
Joined: 19th Dec 2002
Location: United States
Posted: 5th Aug 2003 21:42
quote " 2^X, eg 2x2, 4x4, 8x8, 16x16, 32x32, 64x64, 128x128, 256x256, 512x512, 1024x1024, or combinations such as 128x256"

Is there a method of finding out how the person that created the image divided up the frames ?

thanks for your time
Lecks
21
Years of Service
User Offline
Joined: 20th Jul 2003
Location: - Please Select -
Posted: 6th Aug 2003 07:47
(totalx - gaponright) / number of frames along x= x
(totaly - gaponbottom) / number of frames along z= z

i dont really understand your question, is that what you mean?

viperjay
22
Years of Service
User Offline
Joined: 19th Dec 2002
Location: United States
Posted: 7th Aug 2003 21:17
What I am trying to say is how do you know the size of the frame? is there a way to calculate it with math ?

thanks for your time
Lecks
21
Years of Service
User Offline
Joined: 20th Jul 2003
Location: - Please Select -
Posted: 8th Aug 2003 08:26
the forumulas above will do it

viperjay
22
Years of Service
User Offline
Joined: 19th Dec 2002
Location: United States
Posted: 27th Aug 2003 21:59
What I would like to do is load a big graphic like a boss and the a small object like his bullets or fire or bombs or whatever that is kept in a 640 by 480 box. Is there a way to figure this out ?

thanks for your time
viperjay
22
Years of Service
User Offline
Joined: 19th Dec 2002
Location: United States
Posted: 3rd Sep 2003 04:12
Please help me!!

thank you
viperjay
22
Years of Service
User Offline
Joined: 19th Dec 2002
Location: United States
Posted: 14th Sep 2003 04:51
I am so confused I now understand that you would copy each frame at a given size but what if I copy an image that is bigger that the size have set? also how do you just copy the image an not the background ? ie. black around it ? Thanks for your support ... need help

Login to post a reply

Server time is: 2025-05-20 17:59:31
Your offset time is: 2025-05-20 17:59:31