Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: GM6 Help. How do you add a trailing effect to an object  (Read 2232 times)

0 Members and 1 Guest are viewing this topic.

ali

GM6 Help. How do you add a trailing effect to an...
« on: April 01, 2007, 07:56:50 am »
I need a code for adding a trailing effect

As if the object was moving really fast and you could see the image really blurry behind it

Please Help
« Last Edit: April 01, 2007, 09:12:23 pm by 4Sword »
Logged
Re: GM6 Help. How do you add a trailing effect t...
« Reply #1 on: April 01, 2007, 08:04:31 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 121
you could make objects with a lower alpha or you could make a 2d array where

array[trailnumber,0] = x
array[trailnumber,1] = y
array[trailnumber,2] = image_index
array[trailnumber,3] = sprite_image
array[trailnumber,4] = alpha

then you draw in a for loop and erase them from the array when they fade and then make code to check where a free place in the array is


Logged

ali

Re: GM6 Help. How do you add a trailing effect t...
« Reply #2 on: April 01, 2007, 08:09:05 am »
you could make objects with a lower alpha or you could make a 2d array where

array[trailnumber,0] = x
array[trailnumber,1] = y
array[trailnumber,2] = image_index
array[trailnumber,3] = sprite_image
array[trailnumber,4] = alpha

then you draw in a for loop and erase them from the array when they fade and then make code to check where a free place in the array is




wait uh what goes where???
Logged
Re: GM6 Help. How do you add a trailing effect t...
« Reply #3 on: April 01, 2007, 08:25:52 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 121
create code
Code: [Select]
/* Creates twenty variables, 'prev_x[1]' and 'prev_y[1]' through
   'prev_x[10]' and 'prev_y[10]'. The first is the current location
   of the object and each of the others represents a previous "ghost"
   of the object, with number 10 being the latest one (10 steps ago).
*/

for (ii = 1; ii < 10; ii +=1;) {
 prev_x[ii] = 0;
 prev_y[ii] = 0;
}

step when going fast
Code: [Select]
// Update the current object's positions.
prev_x[1] = x;
prev_y[1] = y;

// Update each of the "ghosts".
for (ii = 10; ii > 1; ii -= 1;) {
 prev_x[ii] = prev_x[ii-1];
 prev_y[ii] = prev_y[ii-1];
}

draw
Code: [Select]
// Draw the sprite and its 9 "ghosts" at logical alpha values.
for (ii = 1; ii < 10; ii += 1;) {
 draw_sprite_ext(sprite_index,-1,prev_x[ii],prev_y[ii],1,1,0,c_white,0.5*(10-ii)/10);
}
Logged

ali

Re: GM6 Help. How do you add a trailing effect t...
« Reply #4 on: April 01, 2007, 08:30:29 am »
When I pu the code in it is not colored
So I think it doesn't work

WTF is up wit that?
Logged
Re: GM6 Help. How do you add a trailing effect t...
« Reply #5 on: April 01, 2007, 08:31:38 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 121
what do you mean?

post your code
Logged

ali

Re: GM6 Help. How do you add a trailing effect t...
« Reply #6 on: April 01, 2007, 08:44:40 am »
what do you mean?

post your code

I put the same thing you put except when I pasted it into the code area
It was all black instead of colored
Logged
Re: GM6 Help. How do you add a trailing effect t...
« Reply #7 on: April 01, 2007, 08:46:09 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 121
i dont see how that could happen.

could you post all your objects code to see if a can see anything that could cause it.
Logged

ali

Re: GM6 Help. How do you add a trailing effect t...
« Reply #8 on: April 01, 2007, 08:50:13 am »
i dont see how that could happen.

could you post all your objects code to see if a can see anything that could cause it.

the name of the object that is moving, The ship
is
Code: [Select]
objship
that is the only thing you really need
Logged
Re: GM6 Help. How do you add a trailing effect t...
« Reply #9 on: April 01, 2007, 08:56:17 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 121
my code does not make things black so its probably somewhere in your code

wait post your draw code i think i know what it is.
Logged

Bistian

Procedurally generated bro.
Re: GM6 Help. How do you add a trailing effect t...
« Reply #10 on: April 01, 2007, 09:36:19 am »
  • That's right, I'm back.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 129
Drag and Drop :

If Step () {
Create Objtail at 0*0 relative Position
}

For Tail :

If Animation End {
Destroy self
}
Logged

mit

Re: GM6 Help. How do you add a trailing effect t...
« Reply #11 on: April 01, 2007, 11:12:59 am »
  • QBASIC programmer since age 4. Take that, world.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 1079
I don't think anyone's noticed that drawing your previous positions wouldn't create a nice trail. When the object moves, the faster the movement, the larger the gaps between the trailing bits. It's not a pretty effect, trust me.

When needs to be done is pay attention to when a trail should appear. It should only remember one previous position, which is already stored by GM. It should then look at the distance travelled this step, and draw a trail accordingly. It's much nicer, and uses less memory.

I guess it doesn't matter if you're moving at a consistent speed, but whatever.
Logged
Programmer / Spriter / Level designer / Game Director / Web Designer / Music Sequencer for
Random Highscore table:

Play the Kousou Arcade today!
  • Kousou Games

Bistian

Procedurally generated bro.
Re: GM6 Help. How do you add a trailing effect t...
« Reply #12 on: April 01, 2007, 01:23:34 pm »
  • That's right, I'm back.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 129
If the Main Object have larger Speed in a Direction you simple make the Trail moving to the Main Object to !  ::)
Logged

mit

Re: GM6 Help. How do you add a trailing effect t...
« Reply #13 on: April 01, 2007, 02:40:11 pm »
  • QBASIC programmer since age 4. Take that, world.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 1079
Uh, not quite sure what you mean...

Here's an example of my way
Logged
Programmer / Spriter / Level designer / Game Director / Web Designer / Music Sequencer for
Random Highscore table:

Play the Kousou Arcade today!
  • Kousou Games
Re: GM6 Help. How do you add a trailing effect t...
« Reply #14 on: April 01, 2007, 05:33:07 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 121
use mits it is the best.
Logged

ali

Re: GM6 Help. How do you add a trailing effect t...
« Reply #15 on: April 01, 2007, 09:10:22 pm »
Thanks mit, I will try it now
Logged
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.122 seconds with 70 queries.

anything