Creating similar game to google dinosaur game
Show older comments
Hi, I was looking for some help to figure out how to stop my gaming function when the moving object hits the obstacle, like in the google dinosaur function and to show a running score on my figure for the high score. Anyone know some helpful tips to code this?
5 Comments
Walter Roberson
on 2 Dec 2017
How are you representing your moving object, and how are you representing the obstacles? Is movement at a constant speed (though potentially different directions?) Are all distances involved multiples of the constant speed, or is it necessary to interpolate the fact of having hit?
Lindsay Guerrero
on 2 Dec 2017
Lindsay Guerrero
on 2 Dec 2017
Edited: Walter Roberson
on 2 Dec 2017
Walter Roberson
on 2 Dec 2017
Remember, the above code is the same as
if all(all((Countrow <80) & (any(Background(400:640,101:180,:)==0,1)),2),3)
closeFunc();
The fragment
any(Background(400:640,101:180,:)==0)
only applies the any() to the first non-scalar dimension, leaving you with a 1 x 80 x something array that the default all() rules apply to
Lindsay Guerrero
on 2 Dec 2017
Answers (0)
Categories
Find more on Number games in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!