I need help with code for my game please

Fill this out this info to make it easier for the community to help you! If you don’t fill out this information, your post may be deleted or removed.

What Wick Editor Version are you using?
The most recent version for browser
Describe the Problem
What issues are you having in the Wick Editor?
I am making a tower defense game, but not your typical one. STORY: You have a christmas tree. The evil snails are gonna eat your christmas tree, so you locked it in a castle. However, the snails are now charging and you must kill them. GAMEPLAY: There are six targets. When you click on a target, the game runs code to see if a snail is touching said target. If it is, it gets removed. (also salt cannon gets blasted at them. ERRORS: If two snails are on top of the target you click, it says there is something wrong with my code and yanks me out of Playtesting. My second error, (a much more important one) is that when you double click on a target, it takes my out of Playtesting and says there is something wrong with my code.
Have you attempted anything et to fix the problem? Let us know!
I haven’t a clue why it’s doing this, and Wick is very good, so it’s probably user error. I just need to know what I did wrong and how I can fix it. (If you’re gonna fix it via the file, (PLEASE DO) just don’t change the art or sprites, just the code.
*Do you have a Wick Editor File that we can see?
Attach a .wick file if you have one in progress that can help us help you!
I can’t attach a file because I’m a “new user” so have the link: Click here for the file in Google Drive

2 Likes

Learn JavaScript first! Then do a little bit of practice games… don’t jump straight to making your dream game unless it is simple (which yours isn’t… not saying it isn’t possible but you’re just starting out).

That being said, you can get someone to help, but it’s not gonna be super easy.

1 Like

Thanks for the advice, but I cannot turn back, seeing as this is for an assignment. I’ll try some tutorials though.

1 Like

I agree with @glottisfandango, if you’re inexperienced then it would be best to start off smaller then expand.

Your game is still doable, I’ll try to break down the process for you.
To begin with, you’ll need to work with clones, so I recommend taking a look at this cloning demo and try to learn from it:

There are 2 things that you’ll want to clone:

  • 6 targets
  • Infinite snails

Start off by writing code to clone the targets 6 times and reposition them where you need them, and make sure to give them a mouselick script. For testing purposes, make the mouseclick script send a simple alert so you can make sure it works.

Next, you want to clone the snails. Say, you might want to make a snail once every 4 seconds or something, to do that you’d want to make a counter variable on the original (non-clone) snail, and continuously increase. Every time the counter passes a certain amount, reset it to zero and create a clone.

The clones for the snails will, by default, start at a specific x coordinate (maybe 2770?) and a random one of three different y positions for each row. You’ll want to learn about the random.integer(...) and random.choice(...) functions for this part. You can find them in the reference library.

And ofc you’d want to add in code to make the snails move to the left, towards the tower, and when they hit the tower to lose the game. You’ve already coded something that does that, so you’re good there.

After this step, you’ll want to make it so that when the target is clicked, to check through all the clones of the snail and see which one is hitting the target. The cloning tutorial should be a great help here.
Every objects has an array of it’s clones, you can refer to as objectName.clones (where objectName is replaced with the name of the object).

You’ll also need to use the hits function again to detect when the snails are touching the target.

Try to go through this process again and let me know where you might find difficulties.

3 Likes

Oh my god, thanks so much. I’m going to try this right now.