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 / Need someone to write a simple code for me

Author
Message
McGrimace
16
Years of Service
User Offline
Joined: 11th Feb 2008
Location:
Posted: 11th Feb 2008 23:46
Im trying to get everything down before moving on in this dbp guide, but I can't figure out how to make the color of the line change. This is what the guide says
Quote: "Write a program that draws strips of colour using the LINE command going from left to right, that gradually change colour from red to blue, using one of the loops"
and here's what I have so far

Can someone more experienced than me write out how this should be written so I can compare and see the right way to code it. Also, to learn how to make gradually changing colors. Thanks a ton
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 12th Feb 2008 00:15 Edited at: 12th Feb 2008 13:11
It's far better to tell you how to do it rather than doing it for you.

In the line:

Ink rgb(0,0,255),0

the 255 is the intensity level of the colour blue (values allowed: 0 to 255). The preceding two 0's are the levels of red and green.

So, if 0,0,255 is full blue and 255,0,0 is full red then to complete the task, you just need to alter these values before drawing each line.

You can do this using the variables R, G and B instead of literal numbers. At the start you would use R=0, G=0 and B=255 along with the line Ink rgb(R,G,B),0.

So, the line:

For x = 1 to 1024 step 2

(which incidentally should really be 0 to 1023) is the X position of the line going across the screen. This gives 1024 lines to fit 256 colours into. 1024/256 = 4 so you simply deduct 1 from the blue colour value every 4 lines across the screen to get the blue value from 255 to 0.

As you need to also get the red value from 0 to 255, at the same time as deducting 1 from the blue you also add 1 to the red value.

Use a counter variable and an 'If Counter=5', altering the R and B variables then setting Counter back to 0.

Hope this helps...

[Edit] Realised I mentioned altering the green value instead of red by mistake. Corrected.

TDK_Man

McGrimace
16
Years of Service
User Offline
Joined: 11th Feb 2008
Location:
Posted: 12th Feb 2008 00:30
Thanks for the post TDK, I understand what your saying, but I think I need a clearer description of how to take a value away from the Red and blues. Ive tried making it like this

The reason why I was hoping someone would write it for me is because I examine the codes from the guide, and then I write my own code using what i've learned, and that usually helps me to remember how to use the codes. lol, thanks for the 0 to 1023 tip, i never thought about that
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 12th Feb 2008 11:34 Edited at: 12th Feb 2008 13:27
To increment / decrement the values...

inc red, 1
dec blue, 1


or...

red = red + 1
blue = blue - 1
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 12th Feb 2008 13:15 Edited at: 12th Feb 2008 13:18
Quote: "red=+1
blue=-1"


Red and Blue are variables. As Batvink says, use Inc and Dec.

You might find tutorials 1 to 4 useful here (as well as others):

http://forum.thegamecreators.com/?m=forum_view&t=99497&b=10

...as you will have to use an If..Then statement and set a condition using boolean operators (all covered in the tutorials).

TDK_Man

McGrimace
16
Years of Service
User Offline
Joined: 11th Feb 2008
Location:
Posted: 12th Feb 2008 23:18
Thanks for the help guys, but I still can't seem to get it to work, i just dont know the right place to put the inc or dec because whenever i try to use them, it comes up with an error. Also, thanks for those tutorials TDK, I just found those last night and when i'm done with this tutorial, im gonna go through all of your tutorials so that they clear everything up. Post if you can help me out some more, and thanks
Jimpo
19
Years of Service
User Offline
Joined: 9th Apr 2005
Location:
Posted: 15th Feb 2008 23:31 Edited at: 15th Feb 2008 23:36
It's best to learn yourself, but here's an example:


Just ask if you need any part explained.

TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 16th Feb 2008 05:59
Quote: "when i'm done with this tutorial, im gonna go through all of your tutorials so that they clear everything up."


As telling you how to get your program working would essentially mean typing in large sections from the tutorials you are going to check out later anyway, it would be easier for all concerned if I just gave you a heavily commented code snippet.



TDK_Man

McGrimace
16
Years of Service
User Offline
Joined: 11th Feb 2008
Location:
Posted: 18th Feb 2008 02:32
Alright, I think I got it now. Thanks for your help guys!

Login to post a reply

Server time is: 2024-11-25 07:48:52
Your offset time is: 2024-11-25 07:48:52