Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » DUG DUG Fail
- MsTirre
-
Scratcher
14 posts
DUG DUG Fail
https://scratch.mit.edu/projects/1370318923
Hi everyone! I could use another set of eyes on a student’s Scratch project because I think I’ve officially coded myself in circles.
My student is building a beginner-level Dig Dug–style game, and I’ve really let him take the lead on the project. We’ve tried to band-aid a few problems along the way, and I think some of those fixes have now created other problems.
The basic idea is that as the cat/player moves down, the rows of blocks move up, giving the illusion that the player is traveling deeper underground. If the player moves back up, those blocks should come back onto the screen in their correct positions. As the player continues downward, new rows also need to appear below.
Right now we’re having two main problems:
Some blocks are getting “stuck” in certain positions instead of moving/reappearing where they should.
New rows are not appearing where I expect them to, and I think I’ve overcomplicated the logic trying to fix it.
I’m wondering if part of the solution is simply resetting sprites with some go to x/y blocks, but at this point I’ve looked at the code for too long and would love another perspective.
Important caveat: This is a beginner-ish student. I know there are much cleaner ways to build something like this using lists, more advanced cloning systems, etc., but I’m purposely trying to avoid those right now. A My Block would be okay because I can walk him through that, but otherwise I’d much rather have extremely long, repetitive, surface-level Scratch code that he actually understands than elegant code that is over his head.
If anyone is willing to take a peek at the project and point me toward the simplest fix, especially for the block positioning and generating/recycling rows, I would really appreciate it!
And yes, I normally feel much more competent at Scratch than I do today. I have officially stared at this one too long.
Hi everyone! I could use another set of eyes on a student’s Scratch project because I think I’ve officially coded myself in circles.
My student is building a beginner-level Dig Dug–style game, and I’ve really let him take the lead on the project. We’ve tried to band-aid a few problems along the way, and I think some of those fixes have now created other problems.
The basic idea is that as the cat/player moves down, the rows of blocks move up, giving the illusion that the player is traveling deeper underground. If the player moves back up, those blocks should come back onto the screen in their correct positions. As the player continues downward, new rows also need to appear below.
Right now we’re having two main problems:
Some blocks are getting “stuck” in certain positions instead of moving/reappearing where they should.
New rows are not appearing where I expect them to, and I think I’ve overcomplicated the logic trying to fix it.
I’m wondering if part of the solution is simply resetting sprites with some go to x/y blocks, but at this point I’ve looked at the code for too long and would love another perspective.
Important caveat: This is a beginner-ish student. I know there are much cleaner ways to build something like this using lists, more advanced cloning systems, etc., but I’m purposely trying to avoid those right now. A My Block would be okay because I can walk him through that, but otherwise I’d much rather have extremely long, repetitive, surface-level Scratch code that he actually understands than elegant code that is over his head.
If anyone is willing to take a peek at the project and point me toward the simplest fix, especially for the block positioning and generating/recycling rows, I would really appreciate it!
And yes, I normally feel much more competent at Scratch than I do today. I have officially stared at this one too long.
- 10goto10
-
Scratcher
1000+ posts
DUG DUG Fail
I think the basic problem is that sprites are forced to stay at least partially on the screen. That means that the Y adjustments will become wrong since Scratch is adjusting the y position of the clones at the edges of the screen.
People handle this by keeping track of virtual positions and showing the clones only when they are in view. It's also possible to trick Scratch to not do this fencing but I didn't do that.
I tried to fix some of the errors and I added a few comments. I'm not sure that I made the simplest fix. Also, I was not sure what was supposed to happen when the cat is at the bottom of the screen so that's the bottom of the virtual play area. I can't remember what happens in the actual game.
My remix is at https://scratch.mit.edu/projects/1370360754/
People handle this by keeping track of virtual positions and showing the clones only when they are in view. It's also possible to trick Scratch to not do this fencing but I didn't do that.
I tried to fix some of the errors and I added a few comments. I'm not sure that I made the simplest fix. Also, I was not sure what was supposed to happen when the cat is at the bottom of the screen so that's the bottom of the virtual play area. I can't remember what happens in the actual game.
My remix is at https://scratch.mit.edu/projects/1370360754/
- Discussion Forums
- » Help with Scripts
-
» DUG DUG Fail