Player Lives not working correctly & bullets not lining up with player's ship.

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • Hi Guys

    I made my first game with CF 2.5, a clone of the Atari arcade game Asteroids and I'm having some minor issues that I just can't seem to work out.

    1st issue is that when my player gets killed, for the first time in the game, 2 lives are subtracted from number of lives. each time after that it works as intended by subtracting 1 life.
    2nd issue, the player bullets, when fired, are not lining up with the front of the space ship. I think I have the action points for the ship correct, but, most of the time the bullet is just not lining up where it should.


    This is a link to my game, I'm hoping someone can take a look at it & tell me what I may have done wrong. This is my 1st game, so, I have a lot to learn.

    Please login to see this link.

    Thanks for your time.

  • Hey DarkProgrammer,

    One of ways to fix the life-related bug and to give yourself an easier time is to streamline a sequence of related actions into one fastloop.

    For example, you have it when the "Player_StarFighter" collides with a specific object, the following happens:

    • the specific object is destroyed
    • A life is lost/subtracted
    • The "Explosion" sample plays
    • An "Explosion_Object" is created on the player
    • The "Player_StarFighter" is destroyed
    • The "Player_Respawn_Timer" is set to a specified value (300)

    The bottom 5 actions (bolded) could be grouped into one fastloop. Whenever this fastloop is ran, the program immediately performs the set of actions under the fastloop. This lets you program any series of actions once rather than multiple times.

    Here is what the events look like streamlined with fastloops.

    Please login to see this picture.

    Furthermore, events 20 - 22 could be consolidated into 1 event by putting the "Asteroid", "Enemy_UFO_Bullet", and "Enemy_UFO" into the Obstacle Qualifier; as shown below.

    Please login to see this picture.

    This effectively states that if the Player collides with any object which is tagged as an "Obstacle", that object is destroyed and the "lose_life" fastloop runs.



    Why Does this Happen?

    This happens because there are actually 2 "Player_Starfigher objects created initially. One is created during edittime. The other is created from event 25
    Please login to see this picture.
    This event is true at the start of the frame so one instance of the object is created right on the first instance. You can correct this by adding a "Number of 'Player_StarFighter' objects = 0" to the condition as shown below.

    Please login to see this picture.



    Summary

    The only thing wrong was event 25. However you can make your code cleaner and give yourself an easier time by consolidating those "Collision between 'Player_StarFighter' and 'Object X' " into fastloops and qualifiers.

    • Please login to see this link.

    Please login to see this picture.

  • Wow ProdigyX,

    Thank you so much for giving me those details. I have corrected step 25, as you have shown, & the player lives are working correctly now. I'm also going to modify the other steps in the game which you pointed out would make my code more efficient and cleaner.

    I'm still trying to figure out why the player bullets are not lining up with the front of the ship. I know it must have to do with the action points, would you have any insight on that too?

    Thank you again.

    Dark

  • Yeah, you can search of the forums about "Fastloops" or "Immediate Conditions".

    You could also try checking out this Please login to see this link.. Though this goes over immediate conditions in general, I think it might have what you'll want to know about fastloops.

    Creating Fast Loop

    Fastloops are found under the "Special Conditions Object." You execute the loop with the "Start loop" action.

    Please login to see this picture.

    After you call a loop, you need to use the "On Loop" condition within the "Special Conditions Object" execute actions under the loop.

    Please login to see this picture.

    • Please login to see this link.

    Please login to see this picture.

    Edited once, last by Yves (March 12, 2022 at 8:11 AM).

  • I don't want to undermine what Prodigy said BUT in this case adding fastloops might make things more complicated than they need to be, especially for someone who is new to this stuff.

    How to fix the lives problem: Add the condition "only one action when event loops" to each of your death scenarios and it will fix the problem. It fixed it for me.

    How to fix the ship alignment: The reason why it appears that the bullet isn't aligned is because you have only 8 directional animations for your ship but the game is still calculating a full range of motion when determining where the bullet will emerge. In other words, your ship is technically "turned" enough to fire a bullet at a slant, however it isn't turned enough to switch to the next directional animation. Change the number of directional animations to the max and it will give a much more accurate depiction. :)

  • Thanks to you all for responding. I'm going to read the tutorial on Fastloops & hopefully get a better understanding of them, I'm also going to examine my animations on the ship. I really appreciate the fast responses to my questions! :)

  • In the animation editor, look under the 8 direction indicator that contains the ship animations. There is a slider that you can drag left and right. Drag it all the way to the right to maximize directional slots for animations, then right click one of the ship animations and tell it to create rotated animations for all empty slots. :)

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!