Problem With Lives (Dino Shooter Game)

Hello! The Game Is almost Completed. Thanks to Someone I was able to Fix the Spawning Issue. I Added a New Lives System and Added Music. But there is One Bug that I Can’t Seem to find its Source. When You Spawn You Should Have 5 Lives But it Shows that you Have 1 Life Only. Could Someone Please Check my Code and Try to Find the Problem. Thanks!

(Link to Game)

Hi
In your code, i see “lives = 20” and in the game, i see “hearts = 20” like you are requesting.

Pic 1

Pic 2

Oops I Might of Sent in the Wrong one

Should Be Updated now. Sorry for the Incovenice!

Hi
If you make like this, the life is 5 :wink: :wink:

Hi @Liam_WONG_08E,

You have some unusual and creative coding there! I suggest you have a look at the following demo for how to use CoSpace Properties correctly:

There are several issues with your code:

  1. Events inside Run Parallel - you don’t need the run parallel - simply set your event listener at the beginning and let it do all the work
  2. Putting a variable value as the name of your CoSpace Property - while this is actually a useful advanced technique, I don’t think this is what you intended.
  3. Mixing variables & CoSpace Properties - you use the change variable by block as well as CoSpace Properties blocks
  4. I can’t see where you initialise the variable Lives.

Once you’ve looked at the above CoSpace, also search the Gallery for “techleap” - there are many demos there on how to use variables, CoSpace Properties, and other aspects of CoSpaces Edu.

Hope that helps! Let me know if you have any further questions about this. If this solves your problem, please mark this post as the Solution.

Many thanks,
Geoff @ TechLeap

1 Like

Hello, I’m not an expert in this domain, but as far as I remember from my coding classes, different apps instantly verify your code and tell you where the error is.