[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Taking a part from character




On 03-Jan-2000 Wille Huuskonen wrote:
> Christian Reiniger <warewolf@mayn.de> wrote:
> 
>> Wille Huuskonen wrote:
>> >I loaded my sprites from a file to a character 'cars'. How I put
>> >0 , 0 - 10 , 10 from 'cars' to a character car1?
>> 
>> Wait a second - what do you want to know exactly? You're using some
>> toolkit, right? Which one? And perhaps you could post some example code.
> 
> 
> No,  I only don't know C enough to make this.
> 
> I have a character here: (this is just a example)
>     unsigned char cars[9*6]={
>     0, 3, 3, 0, 0, 0, 3, 3, 0,
>     9, 9, *9, *9, 9, 9, 8, 8, 0,
>     6, 4, *4, *4, 4, 6, 7, 7, 8,
>     2, 4, *4, *4, 4, 2, 7, 7, 8,
>     1, 1, 1, 1, 1, 1, 5, 5, 0,
>     0, 3, 3, 0, 0, 0, 3, 3, 0};
> 
> And I want to get those bytes(?) marked with * to a
> char[2*3] car.
> 

make a new array and copy the bits in by hand...

this is ugly and probably highly inaccurate...

for(y=0;y<newheight;y++)
    for(x=0;x<newwidth;x++)
        newarray[x+(y*newwidth)]=oldarray[x+xoffset+(y+yoffset)*oldwidth];

it'd be conceptually easier to make a 2dim array I think :) and read stuff on
blitting. (it'd be cheaper to memcpy entire rows at a time, too)

        -Erik <erik@smluc.org> [http://math.smsu.edu/~br0ke]

The opinions expressed by me are not necessarily opinions. In all
probability, they are random rambling, and to be ignored. Failure to ignore
may result in severe boredom or confusion. Shake well before opening. Keep
Refrigerated.