Asking for value but sets value to

(look at the end of the start block)

I am setting the enemy base’s image to a random value from my “Bases” array.
I am then flipping the image and changing the colors (I am doing this to make it look like an enemy submarine). It does that, but as I change the enemy base’s image, it also changes the image in my “Bases” array. By the way, the base is like the hull of the ship. How can I prevent it from changing the image in my array?

Also, this is my game for the Jam, please don’t copy it.

  • Game God
5 Likes

Oh yeah, so this is a little bit of Arcade trickery–when you pick the image from the Bases array, it doesn’t make a copy of the image, it just points to the image that lives in the array. So when you do “flip EnemyBase image” there’s only one underlying “image” object; the sprite image is also the image in the Bases array.

You can get around this by using the “clone picture” block from the Images category:

image

Which will make a copy of the Base image and change that instead of the one in the array. Be careful when using “clone”, though, a lot of large images can slow a game down!

(Also this looks incredible, I can’t wait to see your final game!)

2 Likes

HOLY COW!!! THE ART ON THIS IS BEAUTIFUL!!!

:point_right: :point_left: also- how did you do the character “skin” selection screen?

2 Likes

Thanks!

For the menu, I just made a 160x120 sprite and gave it a low depth (z). For the selector, I made a sprite that changes size depending on its position and a variable called “CursorPosition”. Search my code for it (yes, I know my code is messy).

3 Likes

Thanks!