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 / arrays for box colours

Author
Message
blank
21
Years of Service
User Offline
Joined: 4th Mar 2003
Location: My Computer
Posted: 17th Feb 2005 07:27 Edited at: 17th Feb 2005 07:28
hey,
im making a very simple text game, where im using 2d boxes and the likes to do the graphics, its all coming along nicely except for this one problem:

now the problem is that when i use a variable to store the colour in it works finr, however when i use an array the colour doesnt show it and the box goes a weird creamy colour. basically i have an array which holds the colour variable in it, and can get changed by the player, i want to use an array so that i can do this:

rather than write out:


You get what i mean, is there any way of storing the variables in arrays and draw a box, using arrays in the colour part as in :

thanks for your help, hope i explained that in and understandable way.

Formely Blank as a plank
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 17th Feb 2005 08:06
Try something along these lines:



Assign the values like so:



Then apply to your code:



"Droids don't rip your arms off when they lose." -H. Solo

REALITY II
blank
21
Years of Service
User Offline
Joined: 4th Mar 2003
Location: My Computer
Posted: 17th Feb 2005 19:42
ahh thanks for the code, i know what its supposed to do, but for some reason when i do the :
Tile(1).Tile1=Rgb(200,0,0)
bit it comes up with the error:
Could not find field "Tile1" in type integer.
ive written in all the other parts to your code aswell.
any ideas as to why this isnt working?
thanks

Formely Blank as a plank
wmf
20
Years of Service
User Offline
Joined: 6th Nov 2004
Location:
Posted: 17th Feb 2005 21:51
change this line: Dim Tile(20) as Integer
to this: Dim Tile(20) as Tiles
blank
21
Years of Service
User Offline
Joined: 4th Mar 2003
Location: My Computer
Posted: 18th Feb 2005 02:55
ahhhh, i had a feeling that may have something to do with it!
wait no i didnt.
thanks for the help.
look out in wip for my game, screenies soon!!!!

Formely Blank as a plank
blank
21
Years of Service
User Offline
Joined: 4th Mar 2003
Location: My Computer
Posted: 18th Feb 2005 03:16
hmmmm, sorry to bother you all again,
but i tried the thing but for some reason its still not working, the colours dont change when i change the values of the
Tile(1).Tile1 thing.
and for some reason theyre all set to a certain colour and wont change, like tile4 is blue even though its set to green and tile 3 is also blue, tile 1 is pink. any idea whats going on?
heres what ive got:

any ideas? thanks

Formely Blank as a plank
spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 18th Feb 2005 03:28
I'm confused at what you are trying to achieve. The box command draws a single box with each corner being a different colour that merges with the other colours forig a nice gradient effect. You are assigning the same colour Tile(1).Tile4 to every corner, which is green (0,255,0). So what are the other three values for?

I could understand if you were doing:



If you explain a bit more what you are trying to achieve I'll help you.

Boo!
blank
21
Years of Service
User Offline
Joined: 4th Mar 2003
Location: My Computer
Posted: 18th Feb 2005 03:36 Edited at: 18th Feb 2005 03:37
basically, im just assigning the same colours to make a filled box of one colour, i dont know if you can do that with one command or not. im assigning different colours though because im going to have different coloured boxes etc, represetning different things ie buildings etc.
so what i need to do is assign rgb values to tile(1), tile(2) etc
as i need to make like 200+ boxes, you see?
but the problem is that for some reason i cant get the colour to work right using an array or the thing that RiiDii showed me. thanks, any ideas how to fix the problem?

Formely Blank as a plank
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 18th Feb 2005 03:59
your frist Ideal was correct just put a - minus sign in front of tile(1)

eg

box 0,(screen height()/20)*5,screen width()/20,(screen height()/20)*6,-tile(1),-tile(1),-tile(1),-tile(1)

that should make it do its

In Space No One can Hear You Scream! (When your comm Line is cut?)
spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 18th Feb 2005 04:19
OK, try code below. It should output 7 boxes along the top using one method of outputting boxes, and then another row of boxes using another method. On my pc the colour order is red, green, blue, yellow, magenta, cyna, white. Code is scalable. Just keep adding colours and change variable at top.

If colours are coming out wrong then your graphics card probably needs updated drivers. Also, make sure you are running in 32bit colour mode as 16bit colour mode sometimes outputs wrong colours.



Boo!
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 18th Feb 2005 04:26
yep Spooky way is much better, well that another one to remember. dword.

In Space No One can Hear You Scream! (When your comm Line is cut?)
blank
21
Years of Service
User Offline
Joined: 4th Mar 2003
Location: My Computer
Posted: 18th Feb 2005 05:16
the bottom one works fine but method one dont work, its all purple for some reason, it loks like its doing exactly what it was doing for mine, and i cant use the method 2 unfortunately. any ideas as to why this isnt working for me? does it work for everyone else?

Formely Blank as a plank
spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 18th Feb 2005 05:16
Correct, rgb colours have to be held in 'dword' data types as they are too large for integers. That is why syntax for commands like rgb state:

SYNTAX
Return DWORD=RGB(Red Value,Green Value,Blue Value)

Boo!
blank
21
Years of Service
User Offline
Joined: 4th Mar 2003
Location: My Computer
Posted: 18th Feb 2005 05:25 Edited at: 18th Feb 2005 05:30
so, how come i cant get method 1 working? and does that mean if i change the :
type tiles
tile1 = integer
to dword, that will work?

EDIT: yep, the RiiDii method works, as long as the tiles are set as dword rather than integers

Formely Blank as a plank
spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 18th Feb 2005 05:37
Running my code should have given you:



Are you saying top row of boxes are blank?

Boo!
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 18th Feb 2005 06:00
Sorry about the code problems Blank. I must be gettin' tired => silly mistakes. Thanks for the debug Spooky!

"Droids don't rip your arms off when they lose." -H. Solo

REALITY II
blank
21
Years of Service
User Offline
Joined: 4th Mar 2003
Location: My Computer
Posted: 18th Feb 2005 07:55
no problem RiiDii

Formely Blank as a plank

Login to post a reply

Server time is: 2024-11-27 22:34:32
Your offset time is: 2024-11-27 22:34:32