Character troubles

So, I made a Dragon that should go left to right (back and forth) hopefully spitting fireballs in the direction of the Player when he gets within 400 pixels. If the player jumps on the Dragon the Dragon should be removed and replaced with an explosion that then also goes away after running it’s animation.
At least that’s what I thought was going to happen.
What happens:
The Dragon goes right until the turn point, then there are two flashing Dragons making their way left. No fireballs, not explosion when the Dragon is killed.
I am stumped. :confused:
Thank you for your help!
The code is attached below.

youtu.be/JNt9FX5bM0A

This is a video of the dragon doubling.
I need to figure out the fireball also. I would like it to shoot one every 3 seconds, not a whole string of them! And in the right direction.
Thanks!

0 - That is not a dragon, that’s Ridley :imp:
1 - The dragon is not doubled, it’s moving very fast back and forth, check the sprite animations, make sure the origin is not messed up between frames.
2 - Yeah, you’re firing a fireball each frame, now GD supports per-object timers so you can do it:

[code]Conditions: At the beginning of the scene
Actions: Reset the timer “fire” of Dragon

Conditions: Timer “fire” of Dragon is greater than 3 seconds
Player distance to Dragon is bellow 400 pixels
Actions: Create FireBall
Reset timer “fire” of Dragon[/code]
3 - Also, to shoot the fireball in the direction of the player: Create the fireball, rotate the fireball to the player position (there is an action to do it) with speed 0 (automatic rotation), add a force (at creation with damping = 1 or every frame with damping = 0) to the fireball with angle = fireball angle.
4 - You’ve to create the explosion before deleting the dragon, otherwise GD doesn’t know what “Dragon.PointX(x)” is :wink:

Hope it helps :slight_smile:

Thanks Lizard-13! I’m off to try all this now!
Ridley is just a placeholder 'til I draw my own.
Right now I’m just ‘fleshing out’ the concepts of how to do this.
It’s interesting!
Thanks for your help!

Okay! Things are working better. I’m understanding more.
I have gotten the Dragon ( I drew up another Dragon character) to shoot a shorter stream of fire balls but can’t seem to get it to shoot just one at a time. It is triggered by proximity to the Player.
The jumpy glitch when flipped was due to my changing the center of the animation. Reset to Center and is is well.

The Player… I have an animation for the Player to play guitar when I press the “p” key.
I added an MP3 clip to play at the same time but it seems to be echoing (I think it keeps triggering the Play as I hold down the key)
In fact, any prolonged Collision makes the event (Score, Audio, etc.) play multiple times. If I walk into a Score giving item but don’t want it to go away only to be able to give an addition + Score again later. It seems it would be the Timer but no matter in which sequence I add it into the script it messes something up, i.e. the sound won’t play or the ‘hit’ won’t take.

1 Like

Here is an example of one problem.
I think I have set up my Player so that when I Press the “p” key he should play a little animation and song as long as the key is pressed. In reality what is happening is that he plays the animation but the music only starts after I lift my finger from pressing the key and then plays in it’s entirety.

Thanks for all your help.
I am starting to get the hang of some of it.
I’m having fun learning GD

You have the “p key is released” event as a sub-event of the “p key is pressed event”, so it will never be triggered (the key can’t be simultaneously pressed and released). If you move that to a separate event it should stop the music playing on release of the key.

I took that out. What happens is:
I press the key and the animation plays.
I release the key and the music starts.

I would like them to play the animation and the music until I take my finger off the key.
Then it should resume idle with no music.

Move the playing music action up to the a p key is pressed part. Then make sure that the animation you want is in there too. Then in the a p key is released part that is where you stop the animation and the music.

I did that. Same problem.
I press the key and the animation plays.
I release the key and the music starts.

Goal: Press “p” key to play the animation and the music until I take my finger off the key.

I guess you’re missing the “Trigger once” condition, it should be “If p key is pressed AND Tigger once >> Play music” so it start to play in the first touch, also as it was suggested don’t put the “p key released” as a sub-event of “p key pressed”, not sure if both can be true at the same time, so it should be:

[code]Conditions: Player is stopped
“p” key is pressed
Trigger once
Actions: Play music “Guitar.mp3” on channel 0, repeat: yes

Conditions: “p” key is released
Actions: Stop music on channel 0[/code]

For the guitar animation, you might want to explore conditional statements to ensure the MP3 clip doesn’t echo. Also, consider incorporating a cooldown period after each collision to prevent rapid triggering.