Page 1 of 1

Array Help

PostPosted: Tue Nov 29, 2005 1:50 am
by willg101
I just now discovered somwhat how arrays work. Can someone tell me what's wrong with this code?
Code: Select all
xm1=&xmouse+120;
xm2=xmouse+120;
ym1=&ymouse+160;
ym2=ymouse+160;
if(draw == 1)
{
  screen_to_actor(&xmouse, &ymouse);
  xmouse1[xm1]=1;
  xmouse2[xm2]=1;
  ymouse1[ym1]=1;
  ymouse2[ym2]=1;
  lineto(xmouse, ymouse);

}

This is part of my "save canvas" code. The xmouse arrays are 240 and the ymouse arrays are 320.

Image

PostPosted: Tue Nov 29, 2005 6:29 am
by Joshua Worth
Funny, I had that same problem just a couple of days ago

PostPosted: Tue Nov 29, 2005 1:39 pm
by makslane
Code: Select all
xm1=&xmouse+120;


&xmouse its the address of xmouse variable.
Doesn't make sense to use here.

PostPosted: Tue Nov 29, 2005 9:29 pm
by willg101
Hmm...
I can't say I was think logically when I wrote this, I was just trying to save all the info so I could reload it later on. How should I go about doing this?

PostPosted: Wed Nov 30, 2005 1:07 am
by makslane
What you need to save?

PostPosted: Wed Nov 30, 2005 1:59 am
by willg101
I am trying to save/reload a canvas.

Actually, now I have the save code down:
Code: Select all
ym0=ymouse;
xm0=xmouse;
if(draw==1)screen_to_actor(&xmouse, &ymouse);
if(draw==1)lineto(xmouse, ymouse);
if(draw==1)xm[xm0]=1;
if(draw==1)ym[ym0]=1;

(I know I could've done the conditional action part better. I just forgot how when I wrote this code.)

If anyone has a better idea of how to save a canvas, please tell me, but I think I've got it now...

Thank you very much!

PostPosted: Wed Nov 30, 2005 12:35 pm
by makslane
Are working?

PostPosted: Thu Dec 01, 2005 2:22 am
by willg101
I think the save part is working.