Page 1 of 1

This doesnt work because ???? (drawing lines in a canvas)

PostPosted: Tue Jul 31, 2007 8:23 pm
by foleyjo
Draw actor event on a canvas

Code: Select all
int i;
i = 0;

for (i=0; i<=100; i++)
{
    setpen(255, 0,255, 0 ,i);
    lineto(1000, i);
}

PostPosted: Tue Jul 31, 2007 11:06 pm
by makslane
You must use at least one move to before use a line to:

Code: Select all
moveto(0, 0);
lineto(0, 10);
lineto(10, 10);

PostPosted: Wed Aug 01, 2007 8:09 am
by foleyjo
Makes ence

Thank You!!

PostPosted: Thu Aug 02, 2007 9:06 am
by foleyjo
Well it seems I just wasted time here.

I wanted this code to make an energy bar. it worked my energy bar works.
It changes colour when it gets lower down it oes up when you pick up health.

The Problem. When I put it on the GP2X it now crashes the game
The Question - Can you not use the canvas on GP2X games?

PostPosted: Thu Aug 02, 2007 10:07 am
by pixelpoop
it is the erase part of your code that causes the crash.

PostPosted: Thu Aug 02, 2007 10:35 am
by foleyjo
OK then Ive taken that into acount and changed my code to avoid it.
Is there a better way to do this

in canvas draw actor
Code: Select all

//set pointer variable
int i;
i = 0;

//Make the whole energy bar black
setpen(0,0,0,0,i);

for (i=0; i<=10; i++)
{
    moveto(0,i);
    lineto(100, i);
}


//Change energy colour Green = safe Yellow = warning Red = Danger
//Energy is from 0 to 100 at 0 player character is destroyed
setpen(0, 255,0, 0 ,i);

if (player.plr_energy <=50)
   setpen(255,252, 0,0 , i);
if (player.plr_energy <=25)
     setpen(255,0,0,0,i);

//Draw  energy with colour
for (i=0; i<=10; i++)
{
    moveto(0,i);
    lineto(player.plr_energy, i);
}

PostPosted: Thu Aug 02, 2007 11:33 am
by pixelpoop
You could use a sprite, that seems much simpler.

PostPosted: Thu Aug 02, 2007 11:42 am
by foleyjo
I wanted an exact representation of the energy. I would need 100 frames to do it with sprites

PostPosted: Thu Aug 02, 2007 1:12 pm
by pixelpoop
It is easy if you use an animation program. Here is one I did in Flash in less than 5 minutes.

PostPosted: Thu Aug 02, 2007 1:55 pm
by foleyjo
See theres another problem i dont know how to make animations. I dont even know what package is best to use :oops:

PostPosted: Thu Aug 02, 2007 2:42 pm
by pixelpoop
You can use this animation for your project if you want.
Free software for animations and drawing/photo editing have been brought up many times in these forums. Do a search here or in google to find some. Look for software that has good documentation and walkthroughs.

Flash is a great tool but kind of pricey for just doing health bars.

PostPosted: Thu Aug 02, 2007 3:18 pm
by foleyjo
Ok. Thank you very much. I think I have all I need to be getting on with my game now.
Lets see how long I can go without getting stuck again :lol:

PostPosted: Thu Aug 02, 2007 9:11 pm
by pixelpoop
hey foleyjo

Makslane may have a fix for your erase problem soon. Keep your fingers crossed.