it keeps freezing before i get a point. can someone take a look at it because i can’t figure it out
Flappy Bird Clone Attempt.wick (124.7 KB)
it keeps freezing before i get a point. can someone take a look at it because i can’t figure it out
Flappy Bird Clone Attempt.wick (124.7 KB)
I think I found what the error is. Your AddScore object is programmed to change the variable scoreNum. However, scoreNum is set to a local variable in your default script:
var scoreNum =0
This actually means it can’t be accessed by other scripts, because it is local to the default script. Your AddScore update script is trying to change this variable, but it can’t because it has only been defined in the default script. You can set it to global variable that can be accessed by other scripts by simply removing the “var” part:
scoreNum =0
Try changing that part, and it shouldn’t freeze up anymore.
Thank you so much! i never realized that it was local
Wick has a slightly unique approach to variables, where you can specify a variable as global by simply omitting “var”, and by including “var” you can specify as local. Glad it helped!
(Also, I really like your cartoon ghost, good luck on your game!)
so say i wanted the item named delete to reset the walls and make them different sizes would i use this
if (this.hitTest(Delete)) { this.x=2000; this.height=random.integer(50,650) }
The only thing that I think would cause an error is that you are using hitTest(Delete), when your object is called DeleteStuff. You would want to change it so the name matches.
Also, the height resizing works, but it also scales the outlines of your objects too. I think maybe the workaround for this would be to use walls of equal heights and just change the y value rather than the height value. I can try to make a little example project of what I mean later.
like this im almost done i just need to make a looping background
and i need to fix the new point problem
Almost_Complete.wick (16.0 KB)
Looks good! A looping background shouldn’t be too hard. If you want some tips, I’ve made some looping backgrounds before. What’s the point problem?
the line that give you a point sometimes gives you two points
The reason this is happening is because hitTest runs for every frame of the project. It doesn’t just detect the first time two objects touch, it keeps running for as long as those objects are touching. What’s happening is that sometimes your ghost is touching the bar for more than one frame, so the hitTest fires twice. You could do something like set a boolean to check if the bar hit the ghost yet. Here’s a possible fix using that method:
Almost_Complete_hitBool.wick (16.0 KB)
Here’s the code I added to the bar. In the default script, I set a boolean to false:
this.hitGhost = false;
Then in the update script, I took the code for adding the score when the ghost hits the bar, and added an additional if/else statement to test if the boolean is false:
if (this.hitTest(Ghost)) {
if(this.hitGhost===false){
scoreNum += 1;
this.hitGhost=true;
}
}
The way this works is that hitGhost has to be set to false for the scoreNum+=1 code to be executed. By setting hitGhost to true right after we added the score once, we can prevent the code from running multiple times. We also need to reset hitGhost to false once a new round starts, so I added this to reset it to false once the bar is in front of the ghost again:
if(this.x>Ghost.x){
this.hitGhost=false;
}
thanks for this
No problem, let me know if you run into any other issues