Page 1 of 1

HELP anyone??WITH LASER code.

PostPosted: Fri Sep 04, 2009 6:52 am
by amanuob
Can anyone help me with the codes in laser (>,<)..
like in the laser defense game..
I dunno how to make laser. that changes its angle full 360 without making 360 frames for each angle (>,<).



:mrgreen: Thanx in advance :mrgreen:






---------------------------------------------------------------------------------------------------------------------------------------------------
two elderly couple talking.
grandpa:I'm gonna take a nap, remember to wake me up later so that I can take my medicine.
LATER.
grandma:grandpa it's time to take your medicine.
xxxxxxxxxxxxxxxxxxxxxx
grandpa took the medicine.
xxxxxxxxxxxxxxxxxxxxxx
(the medicine grandpa took was, sleeping pills)

Re: HELP anyone??WITH LASER,like in tower defense game.

PostPosted: Fri Sep 04, 2009 3:20 pm
by cforall
:)
Great tower demo by DST here :

viewtopic.php?f=6&t=7005

check the code of actor laser/laser2, use canvas.

Re: HELP anyone??WITH LASER code.

PostPosted: Fri Sep 04, 2009 9:57 pm
by amanuob
this are some hard codes. (>,<)....
any easier one? just the laser?

If there were a demo that would be great.

:mrgreen: thanx in advance :mrgreen:


oh I got to learn setpen function first,can you please direct me to any tutorial dealing with it so that I can understand it not just copy paste the codes. :mrgreen:

Re: HELP anyone??WITH LASER code.

PostPosted: Sat Sep 05, 2009 12:50 am
by cforall
:D
setpen: Define the actual pen for the Event Actor
void setpen(int r, int g, int b, double transp, int pensize)

r: red component (0 - 255)
g: green component (0 - 255)
b: blue component (0 - 255)
transparency: (0.0 - 1.0)
pensize: size of pen


Simplest laser code:
CanvasActor->DrawActor:
Code: Select all
 setpen(R, G, B, Trasnp, PenSize);
 erase(255,255,255,1);
 moveto(TowerPostionX, TowerPostionY);
 lineto(TargetPostionX, TargetPostionY);


Of course, this laser is just a line, if you want a real laser, check that demo. :mrgreen:

Re: HELP anyone??WITH LASER code.

PostPosted: Mon Sep 07, 2009 10:55 am
by amanuob
setpen(R, G, B, Trasnp, PenSize);
erase(255,255,255,1);
moveto(TowerPostionX, TowerPostionY);==> is this the starting position?
lineto(TargetPostionX, TargetPostionY);

are TowerPostionX, TowerPostionY,TargetPostionX, TargetPostionY set variables in laser def.?
if not is PositionX,Y a GE functions?

thanx (>,<) this really helped me. :mrgreen:


I didn't really have much time this days tweaking with GE. :(

Re: HELP anyone??WITH LASER code.

PostPosted: Mon Sep 07, 2009 11:16 am
by DST
Those are just variables he filled in for the example. Everything's done by variables, and everyone names them differently, which is confusing.

Try it this way, create your variables to be used, then
at the beginning of the script, you can set these variables to whatever you want.

canvas>draw actor>
Code: Select all
int x1=0;
int y1=0;
int x2=0;
int y2=0;

erase(255,255,255,1);

setpen(200,0,0,10);  //red diffused glow
moveto(x1, y1);
lineto(x2, y2);

setpen(255, 0, 0, 6); //red main line
moveto(x1, y1);
lineto(x2, y2);

setpen(255, 150, 0, 4); //orange transition
moveto(x1, y1);
lineto(x2, y2);

setpen(255, 255, 255, 2); //white core
moveto(x1, y1);
lineto(x2, y2);


Then just use a png for the glow/burn of the laser, at, of course, coordinates x2 and y2.

If you have a target, you can use target.x, target.y, but transfer them to the ints at the beginning and then reusing them during the script is much easier, notice if you want to change any of them, you only have to change them at the top, and not all thru the script.

Remember that it's an additive canvas, so the first thing drawn is at the bottom and the last thing drawn is on top.