Removing the spaceship's strength and number of lives when touched by the laser ray of an enemy.

0 favourites
  • 11 posts
From the Asset Store
Surena Touch
$2.50 USD
A wrap from official Touch plugin to export touch/mouse input to other plugins.
  • I have created a code but it the code doesn't work properly. When I included the code, my intentions was the following: When the player's spaceship is touched by the laser ray of an enemy spaceship, the player loses 2 "spaceship's strength" points. If the "spaceship's strength" points reach 0 points, the player will lose 1 life (1 life will be subtracted in the txtLive object). If the number of lives reaches 0, the player's spaceship will expose.

    Unfortunately, my code doesn't work properly, please tells me what's wrong with my code. Here's my picture:

  • Which bit isn't working? You can track the variables in debug view to see what they're doing. The logic looks reasonable. I could see it not working if the starting value is not a multiple of 2 so strength doesn't equal 0 but drops below to negative number maybe. There would also be a delay before you saw any explosion but it should still work.

  • To plinkie:

    The initial value for the "SpaceshipStrength" variable is 10, so you can remove 2 points from 10 until you reach zero. Maybe that problem is to maintain the zero value for the spaceship's strength when the player's lives reach the zero value. I wonder how I am going to do this.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You still haven't said what the problem is, the variables look fine to me from that screenshot. Share the file and explain what the problem is, it can be debugged easily.

  • To Plinkie:

    How the variables and the text objects are supposed to work:

    Let's say that the "SpaceshipStrengh" variable equal to 10 and the "PlayersLives" variable equal to 3. Each time that the player's spaceship is touched by the laser ray of an enemy spaceship, the player will lose 2 "spaceship's strength" points from the "SpaceshipStrengh" variable. Each time that the spaceship's strength, reach 0 (zero), 1 Live is subtracted from the "PlayerLives" variable. If the "PlayerLives" variable reaches 0, the "SpaceshipStrengh" variable will also remain at zero and the player's spaceship will explode.

    The problem:

    Sometimes the Spaceship Strength displays a higher value in the txtSpaceshipStrength (the text object that indicates the number of strengths that the player's spaceship has), than in the txtLives (the text object that indicates the number of lives that the player have):

    Example:

    Spaceship Strength:8

    Lives: -5

    *Those values are impossible because you cannot have -5 lives (a value below zero) and still be alive and have a spaceship strength of 8. The number of spaceship strength only restores to 10 if the number of life is superior and not equal to zero. If the number of lives reaches zero, the number of Spaceship's strength values will remain at zero and the spaceship will be destroyed.

    I have submitted a picture of the issue so you can visually understand all the detail that I have explained in my post. Thank you for your time!:

  • Without the file it's difficult but because it's -5 I'm going to guess there are many bullets colliding in a short space of time meaning after that wait finished player lives is then less than 0. You could change players = 0 to less than or equal to 0, that might fix it. Or you can add another condition to strength=0 which is playerlives greater than 0. The main problem I guess is that this is all in one event in the first place but it should work.

  • To plinkie:

    The lives are still generating negative values. Earlier you were suggesting me to send you the file? I think that I will consider this option because I am wasting time on level 1 of my game for weeks now.

  • Sure share it on here, or I am on discord ant#4434

  • I guess this is again a Construct 2 issue, right ?

    Please, do post in the Construct 2 forums, stop using the Construct 3 forums for your issues with Construct 2.

    Do provide your capx whenever asking for help, this helps people answering your issues.

    Moving the topic to the Construct 2 forums.

  • To Kyatric:

    Can you give me a link to Construct 2 Forum so I can submit help request at the proper place?

    Thank you!

  • Under the title of your post :

    Construct Next Construct 2 Next How do I....? Next Viewing Topic

    In the index of the forums

    construct.net/en/forum

    First is the Construct 3 part, than the Construct 2 part.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)