HELP anyone??WITH LASER code.

Non-platform specific questions.

HELP anyone??WITH LASER code.

Postby amanuob » Fri Sep 04, 2009 6:52 am

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)
Last edited by amanuob on Fri Sep 04, 2009 9:31 pm, edited 2 times in total.
Questions are necessary for the development of our own knowing, without questions How would we know??? and lesser would be my posts or none...therefore I know little or none.
User avatar
amanuob
 
Posts: 33
Joined: Sat Aug 29, 2009 11:47 am
Location: In Earth
Score: 1 Give a positive score

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

Postby cforall » Fri Sep 04, 2009 3:20 pm

:)
Great tower demo by DST here :

viewtopic.php?f=6&t=7005

check the code of actor laser/laser2, use canvas.
User avatar
cforall
 
Posts: 65
Joined: Thu Aug 06, 2009 2:46 pm
Location: Shanghai
Score: 8 Give a positive score

Re: HELP anyone??WITH LASER code.

Postby amanuob » Fri Sep 04, 2009 9:57 pm

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:
Questions are necessary for the development of our own knowing, without questions How would we know??? and lesser would be my posts or none...therefore I know little or none.
User avatar
amanuob
 
Posts: 33
Joined: Sat Aug 29, 2009 11:47 am
Location: In Earth
Score: 1 Give a positive score

Re: HELP anyone??WITH LASER code.

Postby cforall » Sat Sep 05, 2009 12:50 am

: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:
User avatar
cforall
 
Posts: 65
Joined: Thu Aug 06, 2009 2:46 pm
Location: Shanghai
Score: 8 Give a positive score

Re: HELP anyone??WITH LASER code.

Postby amanuob » Mon Sep 07, 2009 10:55 am

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. :(
Questions are necessary for the development of our own knowing, without questions How would we know??? and lesser would be my posts or none...therefore I know little or none.
User avatar
amanuob
 
Posts: 33
Joined: Sat Aug 29, 2009 11:47 am
Location: In Earth
Score: 1 Give a positive score

Re: HELP anyone??WITH LASER code.

Postby DST » Mon Sep 07, 2009 11:16 am

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.
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron