Discuss Scratch

scruffydude
Scratcher
11 posts

Independent Clone Variables and other stuff for my game

I'm working on a survival game and there are a few things I'm planning to put into it that I'm not sure of.
In this game you have to collect materials to build a base and craft tools, weapons and other stuff.
1
Independent Clone Variables. The zombies won't die after just 1 hit with a weak weapon. I can only use clones for the zombies, and the health variable will apply to all the clones. I'm not sure how I can give each clone their own health bar, and I've been thinking about this for a very long time now.

2
So in a scroller game, there are many objects around you, and when you press the key to go left, all the objects move right. But I want the zombies to start moving towards me when I get a certain distance close to them, when I'm moving and when I'm still. They still need to have something like this code:
forever
go to x: ((mapX) + (eh)) y: ((mapY) + (eh))
end
3
Building would most likely include the “create clone of ….” block, and also take away the amount of materials it uses from the materials' variables themselves. How can I do that in a scroller game, though? Will it have to be set to the mapX and mapY positions + the position of the cursor?
4
So after you destroy an object, like a tree or an ore, it drops materials that you pick up. How do I make clones appear around another sprite's clone?

Minor stuff I also need help with:
-Zombie only losing health when touching the weapon AND when the weapon is in motion + knockback
-Character not being able to walk through objects
-Putting object health into an interaction box (e.g. Tree HP- 40/100 Drops wood and sometimes fruit.)

Also an AUTOSAVE SYSTEM SOMEONE PLEASE TELL ME HOW TO MAKE ONE

This game is based off Island 2 on Roblox
scruffydude
Scratcher
11 posts

Independent Clone Variables and other stuff for my game

Once I've finished the game(might take about half a year idk) I will make copies of it and edit each copy for different game modes!
hair444y
Scratcher
46 posts

Independent Clone Variables and other stuff for my game

Ok, that seems like a lot of things to get through. Here are my answers:
1
You can make independent health bars for clones with lists. Each index in the list is a separate clone's health.
2
The code you have there is just about what you would want to have. Just have certain list values for the sprites x and y position added to the scroll x and y position. Like this:
go to x: ((scrollX) + (item (ID)  of [zombie x positions v] :: list)) y: ((scrollY) + ((item (ID) of [zombie x positions v] :: list)))
3
Yes
4
Sorry I can't answer this right now, I'll try to answer this later.

If you don't understand parts of it, tell me. Hope this helps

;
PutneyCat
Scratcher
500+ posts

Independent Clone Variables and other stuff for my game

Re 1, if you select “for this sprite only” when creating a health variable each clone will have its own independent health variable.

Re 4, the destroyed tree clone could maybe set two global variables to its own position. Those could then be used to make the materials clones go to the right place when they are created. By the way note that the “create clone” block can also be used to create clones of other sprites. So the destroyed tree (or whatever) clone can create clones of other sprites (the materials).

scruffydude
Scratcher
11 posts

Independent Clone Variables and other stuff for my game

PutneyCat wrote:

Re 1, if you select “for this sprite only” when creating a health variable each clone will have its own independent health variable.
Thanks! I made a test game with that, and it works! If you want to have a look - https://scratch.mit.edu/projects/221957482/#player

PutneyCat wrote:

Re 4, the destroyed tree clone could maybe set two global variables to its own position. Those could then be used to make the materials clones go to the right place when they are created. By the way note that the “create clone” block can also be used to create clones of other sprites. So the destroyed tree (or whatever) clone can create clones of other sprites (the materials).
I didn't realise it was that easy. Thank you for the info.

Last edited by scruffydude (May 10, 2018 08:39:35)

scruffydude
Scratcher
11 posts

Independent Clone Variables and other stuff for my game

I just realized the finished product would have more scripting than griffpatch's Paper Minecraft. Still as hard as I thought, but I'll keep trying.

Powered by DjangoBB