Gamestudio Links
Zorro Links
Newest Posts
Lapsa's very own thread
by Lapsa. 06/26/24 12:45
Executing Trades on Next Bar Open
by Zheka. 06/20/24 14:26
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
0 registered members (), 959 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mino, squik, AemStones, LucasJoshua, Baklazhan
19061 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Paint program - C-script sourcecode [Re: ] #49592
07/21/05 21:20
07/21/05 21:20
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
Do you have more info on that error?

BTW. Got it working with this:

////////////////////////////////////////////////////////////////
// Paint program - (c) 2005 by Claus Nielsen
// v1.2 Paints onto player's skin
////////////////////////////////////////////////////////////////
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>;
bmap* PL_SKIN;

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;
/////////////////////////////////////////////////
function map_scaled(coord,oldmax,newmax)
{
return(max(coord,1) / oldmax * newmax);
}
/////////////////////////////////////////////////
function bmap_draw(TBMAP,SBMAP)
{
var i;var k;var t;
var D3DPIXEL;
var D3DFORMAT;
while(i < bmap_height(TBMAP))
{
k = 0;
t += 1;
while(k < bmap_width(TBMAP))
{
// Read a pixel
bmap_lock(SBMAP,0);
temp.x = int(map_scaled(k,bmap_width(TBMAP),bmap_width(SBMAP)));
temp.y = int(map_scaled(i,bmap_height(TBMAP),bmap_height(SBMAP)));
D3DPIXEL = pixel_for_bmap(SBMAP,temp.x,temp.y);
bmap_unlock(SBMAP);

// Draw a pixel
D3DFORMAT = bmap_lock(TBMAP,0);
pixel_to_bmap(TBMAP,k,i,D3DPIXEL);
bmap_unlock(TBMAP);

k += 1;
t += 1;
if(t - (max_loops-1) >= 0) {wait(1);t = 0;}
}
i += 1;
if(t - (max_loops-1) >= 0) {wait(1);t = 0;}
}
}
////////////////////////////////////////////////////////////////
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];

level_load("level.wmb");
wait(3);

player = ent_create("hero.mdl",nullvector,null);

vec_set(bg_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(!key_enter)
{
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);
}
camera.x = player.x + fcos(player.pan,100);
camera.y = player.y + fsin(player.pan,100);
camera.z += 10;
camera.pan = player.pan + 180;
paper_pan.visible = off;
PL_SKIN = bmap_for_entity(player,0);
bmap_draw(PL_SKIN,PAPER);
var cam_pan;
cam_pan = camera.pan;
while(1)
{
camera.x = player.x + fcos(cam_pan,100);
camera.y = player.y + fsin(cam_pan,100);
vec_set(temp,player.x);
vec_sub(temp,camera.x);
vec_to_angle(camera.pan,temp);
if(mouse_left)
{
mouse_mode = 0;
cam_pan -= mouse_force.x * 10;
}
else
{
mouse_mode = 2;
mouse_pos.x = pointer.x;
mouse_pos.y = pointer.y;
}
wait(1);
}
}
////////////////////////////////////////////////////////////////

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

A
Anonymous
Unregistered
Anonymous
Unregistered
A



I may suggest you use a code tag: [ code] [ /code]

It makes it easier to read than what you have since without the code tag, the forum brings down all the spaces to the left.

Re: Paint program - C-script sourcecode #49594
07/22/05 21:29
07/22/05 21:29
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 know. But I don't know why I didn't use the code tag

Editing... Hmm... Too late for editing that post
sry...

Last edited by Claus_Nielsen; 07/22/05 21:30.
Re: Paint program - C-script sourcecode [Re: Claus_N] #49595
07/25/05 23:26
07/25/05 23:26

A
Anonymous
Unregistered
Anonymous
Unregistered
A



Thanks Claus,
I guess I wasn't using a bmap pointer: I never use a lot of labels in my code.

Re: Paint program - C-script sourcecode [Re: Claus_N] #49596
07/28/05 19:13
07/28/05 19:13
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
Quote:

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);




Hi,

Very cool your site.

Congratulations, you make a great work.

best regards,

Marcio

Re: Paint program - C-script sourcecode [Re: Marcio Esper] #49597
07/28/05 19:15
07/28/05 19:15
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
Thanks for the kind words

It's always nice to hear things like that

Page 2 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