+ 4

Should I Give Up On A Code?

I've had this code which everyone including me is sick of. I feel very guilty asking for help because I've had a number of people put a lot of time into this. And just by assumption, although they volunteered to help, I can tell they are sick of me. It has a bug that no one knows how to fix and I've had one person not answer and the rest have no idea how to fix. Should I just give up? I've put myself and others through hell because of my own actions and I so guilty because of it. Is it normal to lose all motivation and hope over 1 single code?

30th Jul 2019, 7:46 PM
Clueless Coder
Clueless Coder - avatar
20 odpowiedzi
+ 7
Take a hint from the user name of JTLZ 🇨🇦 [#NeverGiveUp!] .
31st Jul 2019, 3:44 AM
Sonic
Sonic - avatar
+ 6
If you have really checked it over and over again, and haven’t found any errors, start looking for errors in the most basic and obvious parts of the code, say the parenthesis or semi-colons etc. I’ve wasted hours over complicated codes just to find out in the end that I was missing a bracket. And don’t give up! Try to make the code a bit simpler. Then add features to it one at a time to see where it starts calling you crazy.
30th Jul 2019, 10:01 PM
7Pineapple
7Pineapple - avatar
+ 4
Maybe you need to take a step back and focus on something else for a while? I’ve found that if I bang my head against a wall over an error I’m trying to fix, 90% of the time all it does it stress me out and cause me to over-think the situation, which leads me nowhere other than to the medicine cabinet for an advil for my headache. Sometimes stepping back will give you perspective and completing a separate project will boost your confidence, I can’t even count how many times I’ve randomly solved an issue with one of my codes by working on a separate code, or after taking a break and coming back to it with my head in the right place. I would never advise you entirely give up though, I lose hope almost daily lol, but it’s all worth it in the end. Just dont get caught up on one failure.
30th Jul 2019, 8:15 PM
Jake
Jake - avatar
+ 3
what is the code you are struggling with? maybe we can help you out
30th Jul 2019, 8:06 PM
Bebida Roja
Bebida Roja - avatar
+ 3
what do you need to do?
30th Jul 2019, 8:10 PM
Bebida Roja
Bebida Roja - avatar
+ 3
the collide method is blank
30th Jul 2019, 8:13 PM
Bebida Roja
Bebida Roja - avatar
30th Jul 2019, 8:09 PM
Clueless Coder
Clueless Coder - avatar
+ 2
Bebida Roja I can't test if the player hits the left or right of the tile. And it appears the player is stuck and unable to move despite it working before. Even a gold moderator who made a tutorial on this particular subject can't fix it. I feel like everyone has given up on me
30th Jul 2019, 8:12 PM
Clueless Coder
Clueless Coder - avatar
+ 2
√ ... 👌JavaScripter✌️... √ Well I got the player to move by replacing line 102-111 with: this.move = () => { if (this.left){ this.x-=5; } else if (this.right){ this.x+=5; } } } so perhaps there is an issue with your speed variable somewhere?
30th Jul 2019, 8:22 PM
Jake
Jake - avatar
+ 2
Bebida Roja Is it? I have just looked and the Direction() collision method is at the bottom and the if statements are right above. In the if statement I right a response if the collision is top, bottom, left or right
30th Jul 2019, 8:22 PM
Clueless Coder
Clueless Coder - avatar
+ 2
Jake When the player hits the side of a tile the speed is set to 0. This makes the player stop in place preventing the player to phase through the wall. The only explanation I have is that the side collisions are true despite the player clearly being on the top. It seems the variable vectorX is inaccurate but I don't know why
30th Jul 2019, 8:25 PM
Clueless Coder
Clueless Coder - avatar
+ 2
Jake somethings’s definitely derpy with the collision detection. Because derpy is totally 100% accurate, precise scientific coding terminology :D. I think it detects vertical edges as horizontal and visa versa
30th Jul 2019, 11:25 PM
Jason Stone
Jason Stone - avatar
+ 1
If you really can’t figure it out then maybe scrap it and rewrite the whole thing with a different approach to accomplishing your goal. Perhaps there isn’t a problem with the code but instead your current method of implementation just doesn’t work and a different one is needed. Edit: you know what, what am I saying. There can’t possibly be something so fundmentally wrong about your approach you have to scrap it. It doesn’t mean there isn’t a better or easier approach, but someone can make this work somehow, given enough time.
30th Jul 2019, 9:49 PM
Jason Stone
Jason Stone - avatar
+ 1
in your draw function you have if statements for dir == “left” and dir == “right”. In those ifs you multiply the block’s speed by 0.01. This immobilizes the block for left/right movement. Commenting out that assignment (the only uncommented-out contents of those ifs) lets the block move side to side with proper horizontal collision. Vertical collision still needs work as it moves the block side to side instead of simply stopping its vertical movement. I still need to study your code some more to fix vertical collision.
30th Jul 2019, 10:17 PM
Jason Stone
Jason Stone - avatar
+ 1
Commenting out line 290 seems to fix vertical collision
30th Jul 2019, 10:25 PM
Jason Stone
Jason Stone - avatar
+ 1
Jason Stone I had replaced that line with “player.x += 1;” it fixed the collision on that hotizontal ledge and phasing through the left wall, however you’ll notice everytime you jump on that ledge, the player is moved along the x axis by 1, this leads me to believe it is registering the top of that ledge as a vertical Y surface instead of horizontal X
30th Jul 2019, 10:58 PM
Jake
Jake - avatar
1st Aug 2019, 8:13 AM
Clueless Coder
Clueless Coder - avatar
+ 1
Happy to help! Too bad I can’t mention you because I can’t type those square roots.
1st Aug 2019, 4:06 PM
Jason Stone
Jason Stone - avatar
+ 1
Jason Stone Sorry, me neither. I have a bunch of special symbols in my clipboard in case I need them
1st Aug 2019, 4:35 PM
Clueless Coder
Clueless Coder - avatar