The Daily Click ::. Forums ::. Klik Coding Help ::. Laser Beam (TGF)
 

Post Reply  Post Oekaki 
 

Posted By Message

Flava



Registered
  30/07/2002
Points
  684

Has Donated, Thank You!Code MonkeyVIP MemberThe Cake is a LieThe Spinster
12th September, 2004 at 04:45:10 -

Basically i'm making a side-screen scroller ship game thing - if you remember my other game Fantasy World, i'm making the sequel.

And I need it to be able to fire a laser beam. So user holds space bar and a beam fires out. I dont want it to just fire an object - I want it like those beams you see in DBZ (not that I watch it or anything) or something like that..

I've tried alsorts - but I guess i'm still not good enough to know how to do it, or if its even possible in TGF.

If you have any ideas, please share them with me !

 
This is a signature. Have this one on me.

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
12th September, 2004 at 05:05:12 -

TGF has fastloop, doesn't it? Yeah, just have two objects, one the front of the fireball (if you want your laser to be lead by a fireball like those in DBZ), and the other a round circular thing that fades from say, white to dark blue. I'll call them Fireball and Lazer respectively.

Number of Fireball > 0
- start loop 0 for 7 loops

Loop trigger #0
- Fireball: X position = X(Fireball) + 1
- Create Laser at (0,0) from Fireball

Laser animation stopped is over
- Destroy Laser

Change the number of loops for the fireball to move faster accross the screen, and make the Laser animation longer for a longer trail. If you want it to be more of a normal laser rather than a dbz Ki ball, make the fireball look just like the Laser's first frame.

You can then test if Fireball collides with an enemy and destroy it, or if you want a more Gradius-style laser, use a much faster loop (say, 20ish loops per action), and test whether enemies are colliding with Laser instead (but don't destroy Laser, use a flag instead to make each one only hit once).

 
n/a

Flava



Registered
  30/07/2002
Points
  684

Has Donated, Thank You!Code MonkeyVIP MemberThe Cake is a LieThe Spinster
12th September, 2004 at 05:10:40 -

Ok well I need the fastloop extension - which i'm downloading now.
So I'll try it out - thanks.

 
This is a signature. Have this one on me.

Flava



Registered
  30/07/2002
Points
  684

Has Donated, Thank You!Code MonkeyVIP MemberThe Cake is a LieThe Spinster
12th September, 2004 at 05:24:42 -

Ok I've tried it - but it isnt quite how I wanted it.
I want it so that when I hold space bar, it still keeps firing the laser up to a certain distance (and when the ship moves, the laser moves with it)

Its hard to explain what I want, and if it's possible in TGF.

 
This is a signature. Have this one on me.

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
12th September, 2004 at 05:33:17 -

Okay, so do this:

Number of Fireball > 0
- start loop 0 for X loops

Loop trigger #0
+Fireball value A < (the distance you want the laser to go in px)
- Fireball: X position = X(Fireball) + 1
- Fireball: Add 1 to alterable value A
- Create Laser at (0,0) from Fireball

Loop trigger #0
+Fireball value A >= (the distance you want the laser to go in px)
- Destroy Fireball

Laser animation stopped is over
- Destroy Laser

Then set the number of loops (X) to something high, like 25-30, and make the Laser animation much shorter.

 
n/a

Flava



Registered
  30/07/2002
Points
  684

Has Donated, Thank You!Code MonkeyVIP MemberThe Cake is a LieThe Spinster
12th September, 2004 at 06:01:27 -

well thats better than before.
But a few stupid questions:

1. How can I make it so the laser follows my ship
2. How can I make it so it only fires the laser when holding space bar?

 
This is a signature. Have this one on me.

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
12th September, 2004 at 06:13:27 -

Make the fireball look like normal laser, and use

Repeat while fire 1 is held
+No. of Fireball = 0
- Create fireball at (0,0) from ship (action point)

You should also have the laser animation as a plain colour (or something, but no fade) so it'll appear as a constant beam.

Increase the number of loops and alter the length of laser's animation till you get the effect you want.

 
n/a

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
12th September, 2004 at 06:18:19 -

A simpler way, but you can't have cool effects:

Create a 'laser' object, say 200 px long, 5 high. That's your laser.

Always
- laser: set position to (0,0) from ship (action point)

Repeat while spacebar is pressed
- laser: reappear

NEGATE: Repeat while spacebar is pressed
- laser: make invisible

 
n/a

Flava



Registered
  30/07/2002
Points
  684

Has Donated, Thank You!Code MonkeyVIP MemberThe Cake is a LieThe Spinster
12th September, 2004 at 06:24:38 -

I already knew about the second laser theory thing - but I prefer the other.
I tried doing what you said - but now its really messed up.
I have uploaded the .gam file to show you - maybe you could fix it (if you dont mind/have the time)

http://www.opix.org/flava/fwlaser.gam

 
This is a signature. Have this one on me.

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
12th September, 2004 at 06:28:41 -

I'll have a look, though I only have MMF so I don't think I'll just be able to fix it and give it back.

 
n/a

Flava



Registered
  30/07/2002
Points
  684

Has Donated, Thank You!Code MonkeyVIP MemberThe Cake is a LieThe Spinster
12th September, 2004 at 06:32:06 -

Well I also have MMF - just not use to using it at the moment.
Find TGF a lot easier.

 
This is a signature. Have this one on me.

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
12th September, 2004 at 06:37:35 -

Well, anyway your problem is simple.

Changes I made:

Added another frame to 'laser,' and set animation speed to 50.
Changed the number of loops to 60.

Added 'set Y position to ship + 7' for both laser and fireball in the first fastloop event.

It's still not perfect, but if you were using a custom movement for the ship it could be.

 
n/a

Flava



Registered
  30/07/2002
Points
  684

Has Donated, Thank You!Code MonkeyVIP MemberThe Cake is a LieThe Spinster
12th September, 2004 at 10:19:33 -

That doesn't seem to make a difference..

 
This is a signature. Have this one on me.

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
12th September, 2004 at 10:31:01 -

Delete all the laser and fireball objects on the playfield before you run, since there's only ever supposed to be one on-screen at the time (and you'll probbaly hit the object limit if it's trying to draw four lasers at once).

 
n/a

Dr. James MD

Addict

Registered
  08/12/2003
Points
  11941

First GOTW AwardSecond GOTW AwardThird GOTW AwardPicture Me This -Round 26- Winner!
12th September, 2004 at 18:52:07 -

http://www.create-games.com/download.asp?id=3782

how about something like that (sorry if your using dial up, its 5mb). very basic, just one big object.

 
Image
http://uk.youtube.com/watch?v=j--8iXVv2_U
On the sixth day God created Manchester
"You gotta get that sand out your vaj!" x13
www.bossbaddie.com
   

Post Reply



 



Advertisement

Worth A Click