need help for converting something.

You must understand the Game Editor concepts, before post here.

need help for converting something.

Postby Game A Gogo » Sun Sep 10, 2006 7:59 pm

ok, i need help about converting a HSB value that are all 256 limit to an RBG value, anyone can please tell me how, if your going to run and find a solution, note me.

Note:
HSB meens Hue, Saturation and Brightness.
RBG meens Red, Green and Blue :P

and here is a screenshot of what im trying to make
Image[/img]
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby Kodo » Sun Sep 10, 2006 10:12 pm

Red: 162
Blue: 172
Green: 50

Try using Paintshop Pro, its pallet selection dialog displays RGB, HSB and HTML code for any colour.
Inogames: http://www.inogames.com iOS gaming
Firetop Adventure (app store): http://itunes.apple.com/us/app/firetop- ... ?mt=8&ls=1
User avatar
Kodo
 
Posts: 449
Joined: Thu Oct 20, 2005 8:20 pm
Location: UK
Score: 23 Give a positive score

Postby Game A Gogo » Mon Sep 11, 2006 11:28 pm

i meen in real time frame by frame, so the "demo im making" can show you how to make a simple color picker window, i know that screen shots looks like a regular prgram, but its actually something i made, and i was only been able to make the HSB tables, and i need it so when you click aply it saves the rbg value to a file called colors.clr and yeah
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby Kodo » Tue Sep 12, 2006 12:21 am

Type

convert RBG to HSL (or HSB)

Into google, you'll get loads of info on the subject including info on how to convert from one to the other.
Inogames: http://www.inogames.com iOS gaming
Firetop Adventure (app store): http://itunes.apple.com/us/app/firetop- ... ?mt=8&ls=1
User avatar
Kodo
 
Posts: 449
Joined: Thu Oct 20, 2005 8:20 pm
Location: UK
Score: 23 Give a positive score

Postby Game A Gogo » Tue Sep 12, 2006 10:27 pm

ok, ive found something, but the code only generate the RGB to HSL, but i need the oposite.

http://www.geekymonkey.com/Programming/ ... SL2RGB.htm

that is the link to the code, can anybody convert me that code for it??
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby Game A Gogo » Thu Sep 14, 2006 10:15 pm

ahh, i give up, since no one cares.
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby pioj » Mon Sep 18, 2006 3:23 pm

Hi, Game-aGogo

I saw sometime ago a blitzbasic code that fits your needs.

It's really easy to understand , by managin' with byte and rgb color values..

Dunno if GE have some POKE, and other pixel-like funtions, but I'll hope that...

Otherwise will be too many difficult..and slow.
pioj
 
Posts: 6
Joined: Mon Sep 18, 2006 2:20 pm
Score: 0 Give a positive score

Postby Game A Gogo » Mon Sep 18, 2006 11:15 pm

ahh, blitzbasic, a long long time! well unfortunetly, GE dosn't support Basic like language, i need a specefic C# script that fits in whit GE, i know i will have to use the global code.
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby makslane » Tue Sep 19, 2006 12:03 am

For H, S, V from 0 to 255, put this code in the Global Code editor:

Code: Select all
typedef struct stRGB
{
    int r;
    int g;
    int b;
} RGB;

RGB HSV_to_RGB(double H, double S, double V)
{
   //HSV values = From 0 to 255
   //RGB results = From 0 to 255
   //Code from: http://www.easyrgb.com/math.php?MATH=M21#text21

   RGB out;

   
   H /= 255.0;
   S /= 255.0;
   V /= 255.0;
 
   
   
   if ( S == 0.0 )
   {
         out.r = out.g = out.b = V*255;
   }
   else
   {
      double var_h, var_i, var_1, var_2, var_3, var_r, var_g, var_b;

      if(H == 1.0) H = 0.0;

      var_h = H * 6;
      var_i = (int)var_h;     
      var_1 = V * ( 1 - S );
      var_2 = V * ( 1 - S * ( var_h - var_i ) );
      var_3 = V * ( 1 - S * ( 1 - ( var_h - var_i ) ) );
   
      if      ( var_i == 0 ) { var_r = V     ; var_g = var_3 ; var_b = var_1; }
      else if ( var_i == 1 ) { var_r = var_2 ; var_g = V     ; var_b = var_1; }
      else if ( var_i == 2 ) { var_r = var_1 ; var_g = V     ; var_b = var_3; }
      else if ( var_i == 3 ) { var_r = var_1 ; var_g = var_2 ; var_b = V;     }
      else if ( var_i == 4 ) { var_r = var_3 ; var_g = var_1 ; var_b = V;     }
      else                   { var_r = V     ; var_g = var_1 ; var_b = var_2; }


      out.r = var_r * 255;
      out.g = var_g * 255;
      out.b = var_b * 255;
   }
   
   return out;
}


To use, just do:

Code: Select all
RGB color = HSV_to_RGB(209, 142, 111);


The result will be: RGB = (105, 49, 111)
You can check the results at:
http://webdeveloper.earthweb.com/reposi ... 1/hex.html
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby Game A Gogo » Tue Sep 19, 2006 12:28 am

i cant get it to work
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby makslane » Tue Sep 19, 2006 12:29 am

What's happen?
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby pioj » Tue Sep 19, 2006 2:40 pm

Wow!

I feel like I could port most of my blitzbasic 2d games to this tool...

Does the script editor support all c++ functionality or is there any limitation?

(Would be great to have some functions to get/set Actor's Current Animation Speed, or more commands for tiles and clones..)

Il hope you'll release the next version soon...
pioj
 
Posts: 6
Joined: Mon Sep 18, 2006 2:20 pm
Score: 0 Give a positive score

Postby makslane » Tue Sep 19, 2006 4:37 pm

There is not C++, but a C script engine.
You can copy and past almost anyl C code thats don't depends of external library.
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest

cron