(some of the variables are useless in this situation because in the actual game to place a block you press down a key so the variable orientation is useless and I also removed the math part of sprite (which was useless also in this situation) so don’t tell me that because I already know)
I’ll be honest. With this many lines of code and a program that goes well beyond what a student would create while taking this course, this is a difficult one to debug.
A few general suggestions, though. There are a lot of yellow warning triangles that should be looked at and cleaned up. For example, lines 416 and 423 and again lines 491 and 498 are telling you that you are trying to declare a variable that has already been declared. Normal practice would be to declare the variable at the top of the program and then refer to it in the function. This could be causing the problem because all 4 of those lines are where you are trying to create a sprite at the mouse location.
There are other warnings where you are trying to use variables outside the scope they were created in.
If I had to guess, I think it would be one of those issues that is causing the problems, but again, with this large of a program that I personally didn’t write, it could take me a lot of time to get my head around what you are trying to do and think through the possible errors.
Good luck on it! It’s ambitious, but it looks like a very fun game!
I have not worked with the sprites, but in Scratch there’s a way to set the addressed point (location on the sprite that goes to the requested coordinates). Don’t know if there’s a similar concept here but may be worth looking into.
It was like that when I first did it without adding the extra stuff, still didn’t work so that’s why in the first place I set it to a key bind so you could place the block.
In my conquest to debunk your project, i realized that your not taking camera movement into effect when placing such blocks, in fact World.mouseX & World.mouseY only has a range of (0-400)
since that’s where the cursor can only be on the canvas which is the external element
Note: The difference between the internal and external positions of the canvas is very important to keep track of knowing the difference is key for this type of project
what your having an issue with is calculating the proper internal element named camera (which you have used to track the player around the screen) which means you will have to use both to calculate the accurate point in which you wish to place on the screen
Note: that camera is directly centered around the player -200 is required if you want it to be centered
here is some refactored code i managed to get working
if (orientation == "right") {
if (IBlockID == 1) {
var IBlock = createSprite(camera.x-200+World.mouseX, camera.y-200+World.mouseY);
IBlock.setAnimation("door");
IBlock.scale = 1.2;
IBlocks.add(IBlock);
blocks.add(IBlock);
IBlock.collide(topEdge);
}
var typeBlock = createSprite(camera.x-200+World.mouseX, camera.y-200+World.mouseY);
this should fix your issue with the right orientation code from 414 - 423
best of luck if you pursue fixing the rest