Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by Zheka. 06/20/24 14:26
Lapsa's very own thread
by rki. 06/19/24 11:27
A simple game ...
by VoroneTZ. 06/18/24 10:50
Face player all the time ...
by bbn1982. 06/18/24 10:25
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (TipmyPip, ozgur), 1,240 guests, and 10 spiders.
Key: Admin, Global Mod, Mod
Newest Members
squik, AemStones, LucasJoshua, Baklazhan, Hanky27
19060 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Paint program - C-script sourcecode #49582
07/19/05 20:52
07/19/05 20:52
Joined: May 2004
Posts: 1,510
Denmark
Claus_N Offline OP
Serious User
Claus_N  Offline OP
Serious User

Joined: May 2004
Posts: 1,510
Denmark
Hi!

Here's the C-script code for a little, (and very simple!), painting program
___________________________________________________________________________________________________
////////////////////////////////////////////////////////////////
// Paint program - (c) 2005 by Claus Nielsen
////////////////////////////////////////////////////////////////
bmap PAPER = <paper.bmp>;
bmap YELLOW = <color.bmp>;
bmap BLUE = <color.bmp>;
bmap BLACK = <color.bmp>;
bmap WHITE = <color.bmp>;
bmap RED = <color.bmp>;
bmap GREEN = <color.bmp>;
bmap CYAN = <color.bmp>;
bmap cursor = <arrow.pcx>;
bmap slider_bg = <slider_bg.bmp>;
bmap slider = <slider.bmp>;

var D3DCOLOR[3];
var BRUSHSIZE = 10;
var BRUSHDETAIL = 5;
var video_mode = 7;
var video_depth = 32;
var video_screen = 2;

font arial_font = "arial",0,18;
////////////////////////////////////////////////////////////////
panel paper_pan
{
bmap = PAPER;
pos_x = 0;
pos_y = 20;
flags = visible,refresh;
layer = 1;
}
////////////////////////////////////////////////////////////////
text desc1
{
font = arial_font;
pos_x = 295;
pos_y = 1;
string = "Detail:";
layer = 4;
flags = visible;
red = 1;
green = 1;
blue = 1;
}

text desc2
{
font = arial_font;
pos_x = 410;
pos_y = 1;
string = "Size:";
layer = 4;
flags = visible;
red = 1;
green = 1;
blue = 1;
}
////////////////////////////////////////////////////////////////
function NewColor(but,pan)
{
if(but == 1) {temp.red = 255;temp.green = 255;temp.blue = 0;}
if(but == 2) {temp.red = 0;temp.green = 0; temp.blue = 255;}
if(but == 3) {temp.red = 1;temp.green = 1;temp.blue = 1;}
if(but == 4) {temp.red = 255;temp.green = 255;temp.blue = 255;}
if(but == 5) {temp.red = 255;temp.green = 0;temp.blue = 0;}
if(but == 6) {temp.red = 0;temp.green = 255;temp.blue = 0;}
if(but == 7) {temp.red = 0;temp.green = 255;temp.blue = 255;}
vec_set(D3DCOLOR,temp);
}
////////////////////////////////////////////////////////////////
panel color_buts
{
pos_x = 5;
pos_y = 1;
button = 0,0,YELLOW,YELLOW,YELLOW,NewColor,null,null;
button = 18,0,BLUE,BLUE,BLUE,NewColor,null,null;
button = 36,0,BLACK,BLACK,BLACK,NewColor,null,null;
button = 54,0,WHITE,WHITE,WHITE,NewColor,null,null;
button = 72,0,RED,RED,RED,NewColor,null,null;
button = 90,0,GREEN,GREEN,GREEN,NewColor,null,null;
button = 108,0,CYAN,CYAN,CYAN,NewColor,null,null;
flags = visible;
layer = 2;
}
////////////////////////////////////////////////////////////////
panel detail_slider
{
bmap = slider_bg;
pos_x = 350;
pos_y = 1;
layer = 3;
flags = visible;
hslider = 0,0,50,slider,1,120,BRUSHDETAIL;
}

panel brush_slider
{
bmap = slider_bg;
pos_x = 455;
pos_y = 1;
layer = 3;
flags = visible;
hslider = 0,0,50,slider,1,120,BRUSHSIZE;
}
////////////////////////////////////////////////////////////////
function COLORIMG(_BMAP,&_D3DCOLOR)
{
var D3DFORMAT;
var D3DPIXEL;
var i;var k;
D3DFORMAT = bmap_lock(_BMAP,0);
D3DPIXEL = pixel_for_vec(_D3DCOLOR,100,D3DFORMAT);
while(i < bmap_height(_BMAP))
{
k = 0;
while(k < bmap_width(_BMAP))
{
pixel_to_bmap(_BMAP,k,i,D3DPIXEL);
k += 1;
}
i += 1;
}
bmap_unlock(_BMAP);
}
////////////////////////////////////////////////////////////////
function main()
{
var D3DFORMAT;
var D3DPIXEL;
var i;
var vi;
var 2DPOS[2];

vec_set(screen_color,vector(204,204,204));
vec_set(D3DCOLOR,vector(1,1,1));

temp.red = 255;temp.green = 255;temp.blue = 0;
COLORIMG(YELLOW,temp);
temp.red = 0;temp.green = 0;temp.blue = 255;
COLORIMG(BLUE,temp);
temp.red = 1;temp.green = 1;temp.blue = 1;
COLORIMG(BLACK,temp);
temp.red = 255;temp.green = 0;temp.blue = 0;
COLORIMG(RED,temp);
temp.red = 0;temp.green = 255;temp.blue = 0;
COLORIMG(GREEN,temp);
temp.red = 0;temp.green = 255;temp.blue = 255;
COLORIMG(CYAN,temp);

mouse_map = cursor;
mouse_mode = 2;
while(1)
{
mouse_pos.x = pointer.x;
mouse_pos.y = pointer.y;
if(mouse_left && (mouse_pos.x > paper_pan.pos_x && mouse_pos.x < paper_pan.pos_x + bmap_width(paper_pan.bmap))
&& (mouse_pos.y > paper_pan.pos_y && mouse_pos.y < paper_pan.pos_y + bmap_height(paper_pan.bmap)))
{
// Prepare for drawing
D3DFORMAT = bmap_lock(PAPER,0);

// Create the pixel to draw with
D3DPIXEL = pixel_for_vec(D3DCOLOR,100,D3DFORMAT);

// Drawing position
2DPOS.x = mouse_pos.x - paper_pan.pos_x;
2DPOS.y = mouse_pos.y - paper_pan.pos_y;

// Draw the pixel onto the bitmap
pixel_to_bmap(PAPER,2DPOS.x,2DPOS.y,D3DPIXEL);

// Use a circled brush
i = 1;
while(i < BRUSHSIZE)
{
vi = 0;
while(vi < 360)
{
if((2DPOS.x + int(fcos(vi,i)) > 0 && 2DPOS.x + int(fcos(vi,i)) < bmap_width(paper_pan.bmap))
&& (2DPOS.y + int(fsin(vi,i)) > 0 && 2DPOS.y + int(fsin(vi,i)) < bmap_height(paper_pan.bmap)))
{
pixel_to_bmap(PAPER,2DPOS.x + int(fcos(vi,i)),2DPOS.y + int(fsin(vi,i)),D3DPIXEL);
}
vi += BRUSHDETAIL;
}
i += 1;
}

// Unlock the bitmap
bmap_unlock(PAPER);
}
wait(0.1);
}
}
////////////////////////////////////////////////////////////////
___________________________________________________________________________________________________

It needs these files:
-color.bmp (I used an 18x18 white bitmap)
-paper.bmp (I used a 800x580 white bmap)
-slider_bg.bmp (the background for the slider)
-slider.bmp (the slider)
-arrow.pcx (Used the one from the templates )

A screenie:


Re: Paint program - C-script sourcecode [Re: Claus_N] #49583
07/19/05 20:55
07/19/05 20:55
Joined: Sep 2002
Posts: 344
São Paulo SP Brazil
Marcio Esper Offline
Senior Member
Marcio Esper  Offline
Senior Member

Joined: Sep 2002
Posts: 344
São Paulo SP Brazil
Very cool

congratulations.

It is possible to use this kind of a program to the player paint a image and use this to be a skin of an model in game with A6 C ?

best regards,

Marcio

Re: Paint program - C-script sourcecode [Re: Marcio Esper] #49584
07/19/05 21:04
07/19/05 21:04
Joined: May 2004
Posts: 1,510
Denmark
Claus_N Offline OP
Serious User
Claus_N  Offline OP
Serious User

Joined: May 2004
Posts: 1,510
Denmark
I haven't tried that before, but it might be possible...

Re: Paint program - C-script sourcecode [Re: Claus_N] #49585
07/19/05 21:13
07/19/05 21:13
Joined: Feb 2005
Posts: 728
Germany, Berlin
Asse Offline
Developer
Asse  Offline
Developer

Joined: Feb 2005
Posts: 728
Germany, Berlin


A6.31.4 Commercial AMD Athlon XP 2400+ Radeon 9800Pro 512MB DDR-Ram Windows XP Professional SP2 3D GameStudio Magazin
Re: Paint program - C-script sourcecode [Re: Asse] #49586
07/19/05 21:33
07/19/05 21:33
Joined: Sep 2002
Posts: 344
São Paulo SP Brazil
Marcio Esper Offline
Senior Member
Marcio Esper  Offline
Senior Member

Joined: Sep 2002
Posts: 344
São Paulo SP Brazil
Hi Asse.


Yes, I think in some thing like your program.

Very impressive

How do you do this ? need a dlls to works or the A6 have the way ?

thank you for attention.

Best regards,

Marcio

Re: Paint program - C-script sourcecode [Re: Marcio Esper] #49587
07/19/05 22:52
07/19/05 22:52

A
Anonymous
Unregistered
Anonymous
Unregistered
A



Hey, good job! I also have a paint program (made with 3DGS) but mine's different in the formulas it uses for the brushes since I have soft brushes (that fade to background), highlights, darkens, and a full spectrum with tens of thousands of colors to choose from...

Re: Paint program - C-script sourcecode [Re: Claus_N] #49588
07/19/05 22:53
07/19/05 22:53

A
Anonymous
Unregistered
Anonymous
Unregistered
A



I've made it easier for those who have trouble reading the code:
Code:
// Paint program - (c) 2005 by Claus Nielsen
bmap PAPER = <paper.bmp>;
bmap YELLOW = <color.bmp>;
bmap BLUE = <color.bmp>;
bmap BLACK = <color.bmp>;
bmap WHITE = <color.bmp>;
bmap RED = <color.bmp>;
bmap GREEN = <color.bmp>;
bmap CYAN = <color.bmp>;
bmap cursor = <arrow.pcx>;
bmap slider_bg = <slider_bg.bmp>;
bmap slider = <slider.bmp>;

var D3DCOLOR[3];
var BRUSHSIZE = 10;
var BRUSHDETAIL = 5;
var video_mode = 7;
var video_depth = 32;
var video_screen = 2;

font arial_font = "arial",0,18;

panel paper_pan
{
bmap = PAPER;
pos_x = 0;
pos_y = 20;
flags = visible,refresh;
layer = 1;
}

text desc1
{
font = arial_font;
pos_x = 295;
pos_y = 1;
string = "Detail:";
layer = 4;
flags = visible;
red = 1;
green = 1;
blue = 1;
}

text desc2
{
font = arial_font;
pos_x = 410;
pos_y = 1;
string = "Size:";
layer = 4;
flags = visible;
red = 1;
green = 1;
blue = 1;
}

function NewColor(but, pan)
{
if(but == 1) {temp.red = 255; temp.green = 255; temp.blue = 0; }
if(but == 2) {temp.red = 0; temp.green = 0; temp.blue = 255;}
if(but == 3) {temp.red = 1; temp.green = 1; temp.blue = 1; }
if(but == 4) {temp.red = 255; temp.green = 255; temp.blue = 255;}
if(but == 5) {temp.red = 255; temp.green = 0; temp.blue = 0; }
if(but == 6) {temp.red = 0; temp.green = 255; temp.blue = 0; }
if(but == 7) {temp.red = 0; temp.green = 255; temp.blue = 255;}

vec_set(D3DCOLOR, temp);
}

panel color_buts
{
pos_x = 5;
pos_y = 1;

button = 0, 0, YELLOW, YELLOW, YELLOW, NewColor, null, null;
button = 18, 0, BLUE, BLUE, BLUE, NewColor, null, null;
button = 36, 0, BLACK, BLACK, BLACK, NewColor, null, null;
button = 54, 0, WHITE, WHITE, WHITE, NewColor, null, null;
button = 72, 0, RED, RED, RED, NewColor, null, null;
button = 90, 0, GREEN, GREEN, GREEN, NewColor, null, null;
button = 108, 0, CYAN, CYAN, CYAN, NewColor, null, null;

flags = visible;
layer = 2;
}

panel detail_slider
{
bmap = slider_bg;
pos_x = 350;
pos_y = 1;
layer = 3;
flags = visible;
hslider = 0,0,50,slider,1,120,BRUSHDETAIL;
}

panel brush_slider
{
bmap = slider_bg;
pos_x = 455;
pos_y = 1;
layer = 3;
flags = visible;
hslider = 0,0,50,slider,1,120,BRUSHSIZE;
}

function COLORIMG(_BMAP,&_D3DCOLOR)
{
var D3DFORMAT;
var D3DPIXEL ;
var i; var k;

D3DFORMAT = bmap_lock(_BMAP,0);
D3DPIXEL = pixel_for_vec(_D3DCOLOR,100,D3DFORMAT);

while(i < bmap_height(_BMAP))
{
k = 0;

while(k < bmap_width(_BMAP))
{
pixel_to_bmap(_BMAP,k,i,D3DPIXEL);
k += 1;
}

i += 1;
}

bmap_unlock(_BMAP);
}

function main()
{
var D3DFORMAT;
var D3DPIXEL;
var i;
var vi;
var 2DPOS[2];

vec_set(screen_color, vector(204, 204, 204));
vec_set(D3DCOLOR, vector( 1, 1, 1));

temp.red = 255; temp.green = 255; temp.blue = 0;
COLORIMG(YELLOW, temp);

temp.red = 0; temp.green = 0; temp.blue = 255;
COLORIMG(BLUE, temp);

temp.red = 1; temp.green = 1; temp.blue = 1;
COLORIMG(BLACK, temp);

temp.red = 255; temp.green = 0; temp.blue = 0;
COLORIMG(RED, temp);

temp.red = 0; temp.green = 255; temp.blue = 0;
COLORIMG(GREEN, temp);

temp.red = 0; temp.green = 255; temp.blue = 255;
COLORIMG(CYAN, temp);

mouse_map = cursor;
mouse_mode = 2;

while(1)
{
mouse_pos.x = pointer.x;
mouse_pos.y = pointer.y;

if (mouse_left &&
(mouse_pos.x > paper_pan.pos_x &&
mouse_pos.x < paper_pan.pos_x + bmap_width(paper_pan.bmap)) &&
(mouse_pos.y > paper_pan.pos_y &&
mouse_pos.y < paper_pan.pos_y + bmap_height(paper_pan.bmap)))
{
// Prepare for drawing
D3DFORMAT = bmap_lock(PAPER, 0);

// Create the pixel to draw with
D3DPIXEL = pixel_for_vec(D3DCOLOR, 100, D3DFORMAT);

// Drawing position
2DPOS.x = mouse_pos.x - paper_pan.pos_x;
2DPOS.y = mouse_pos.y - paper_pan.pos_y;

// Draw the pixel onto the bitmap
pixel_to_bmap(PAPER, 2DPOS.x, 2DPOS.y, D3DPIXEL);

// Use a circled brush
i = 1;

while(i < BRUSHSIZE)
{
vi = 0;

while(vi < 360)
{
if((2DPOS.x + int(fcos(vi,i)) > 0 &&
2DPOS.x + int(fcos(vi,i)) < bmap_width(paper_pan.bmap))&&
(2DPOS.y + int(fsin(vi,i)) > 0 &&
2DPOS.y + int(fsin(vi,i)) <
bmap_height(paper_pan.bmap)))
{
pixel_to_bmap(
PAPER,
2DPOS.x + int(fcos(vi,i)),
2DPOS.y + int(fsin(vi,i)),
D3DPIXEL);
}

vi += BRUSHDETAIL;
}

i += 1;
}

// Unlock the bitmap
bmap_unlock(PAPER);
}

wait(0.1);
}
}



I hope I made it easier for you all to read the code.

Re: Paint program - C-script sourcecode #49589
07/20/05 07:01
07/20/05 07:01
Joined: Jun 2005
Posts: 734
Under your couch
Silent_Assassin Offline
Developer
Silent_Assassin  Offline
Developer

Joined: Jun 2005
Posts: 734
Under your couch
this is impresive work peoples


Visit us at www.m-tec-development.com WIP - Urban Conflict
Re: Paint program - C-script sourcecode #49590
07/21/05 17:37
07/21/05 17:37
Joined: May 2004
Posts: 1,510
Denmark
Claus_N Offline OP
Serious User
Claus_N  Offline OP
Serious User

Joined: May 2004
Posts: 1,510
Denmark
Thx Grayson

To use the painted image as a player skin, you can use the "bmap_draw" function, which can be found in the C-script section of NightHawk Arts (link in my sig.)

bmap* PL_SKIN;
...
PL_SKIN = bmap_for_entity(player,0);
bmap_draw(PL_SKIN,PAPER);

Re: Paint program - C-script sourcecode [Re: Claus_N] #49591
07/21/05 21:03
07/21/05 21:03

A
Anonymous
Unregistered
Anonymous
Unregistered
A



It always says an error has occurred when I try to draw on a player skin

Page 1 of 2 1 2

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1