Discuss Scratch

IdleCannon
Scratcher
7 posts

Incorrect Variable counting

So i'm working on a game that is very similar to tron. It is two player with the main goal being to not touch any lines.
I have a counter for each player and their scores, but for some reason, when the blue is supposed to lose, it still gains a point.

Link is to project- https://scratch.mit.edu/projects/194245665/
mstone326
Scratcher
1000+ posts

Incorrect Variable counting

You are testing for the same 2 colors for each sprite that changes their respective scores. I'd think that the blue bike would look for brown or red and the red brown or blue. That is from a quick look

High School Athletic Director / Middle School Tech Teacher / High School Baseball Coach
Kung Fu by Nintendo 1984 - https://scratch.mit.edu/projects/369994801/
Taco Defense - Speed Typing - https://scratch.mit.edu/projects/316795450/
Halloween Boss Battle - Taking Back our Woods - https://scratch.mit.edu/projects/257155118/
Almost Pong - https://scratch.mit.edu/projects/656276979/
Studio - My Best Projects - https://scratch.mit.edu/studios/4125978/
Forum Help Project Examples - https://scratch.mit.edu/studios/4133335
StrangeMagic32
Scratcher
1000+ posts

Incorrect Variable counting

Clear the trails before they move to their beginning positions

Last edited by StrangeMagic32 (Dec. 18, 2017 16:04:33)



“Remember the worth of souls is great in the sight of God;”
- Doctrine and Covenants 18:10


I have since moved to @JollyWinter
IdleCannon
Scratcher
7 posts

Incorrect Variable counting

Uniquename1
Scratcher
100+ posts

Incorrect Variable counting

It's what mstone said. To fix it you can add an if touching color but only the opposite color around the block that actually changes the score. You'll also want to move that up to be the first thing that happens when you crash because they'd no longer be touching that color after you clear the lines and reset to the starting positions.

Like so : https://scratch.mit.edu/projects/194290177/

Try my games.
Scratch Sprite Club VI Soccer
Star Fighter Shooting
Space Marines: Boarding Party Strategy
Lion Runner Running/ Platformer
deck26
Scratcher
1000+ posts

Incorrect Variable counting

I'd start by slowing it all down. If I set the move to 2 steps instead of 5 steps it seems to detect no collisions at all so perhaps there is something else going on. If I change pen size to 2 it seems to work better but still shows the problem you indicate.

But the scripts for detecting colour are doing too much. All you need is

forever
if <<(play) = [1]> and <<touching color [#4158af] ?> and <touching color [#4158af] ?>>> then
set [play v] to [0]
change [P1 or P2 v] by [1]
end
end
Your other scripts will raise the pen and clear the screen.

Making those changes seems to fix it for me. Not sure exactly what was happening though.

Powered by DjangoBB