Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Score Counter problem

Author
Message
moony
4
Years of Service
User Offline
Joined: 2nd Jun 2014
Location:
Posted: 2nd Jun 2014 14:43 Edited at: 3rd Jun 2014 10:53
Hey everyone, Im trying to do a very basic 2D left to right shmups game. I have now only a ship that shoots one projectile and an ennemy that is cycling up and down.
Im trying to count the score and display it on the top of the screen.

So the projectile is the sprite num 3 and the ennemy is sprite num 201. This is suposed to be just a test so I have only 5 numbers (sprites that will be displyed (sprites 12 to 15 are the numbers from 1 to 5 and the sprite 21 is 0)).
The problem is that it doesnt count right: in the beggining before a collision it is at zero which is fine but when the first collision occurs it jumps to the sprite 14 that displays the number 3 and any other collision doesnt change anything...
I have no clue how to do it so it adds just 1 to the score each time a collision occurs. Theese objects are of course in the while ( LoopGDK ( ) ). Does anyone know what to do here? Thank you all in advance
The Tall Man
5
Years of Service
User Offline
Joined: 16th Nov 2013
Location: Earth
Posted: 2nd Jun 2014 18:03 Edited at: 2nd Jun 2014 18:24
dbSpriteCollision() returns a 1 if one sprite is overlapping another. Once they begin to overlap, they'll continue doing so for several frames. Hence each frame, your score increases. Although I see you're deleting the sprite, so that shouldn't happen. It could be a bug in the command. If you proceeded the command with a dbSpriteExist() call, that should solve it if that's what's going on - unless you're re-creating that sprite somewhere else?



Are you aware that both sc==1 and sc==3 both show sprite 12?

May I suggest a simpler score-showing function?



In the forum you can use the code tag so that source code will display properly. Just select your code, and then click the code button.

Judging what we see is the greatest blinder and self-limiter in the universe.

What we perceive is never reality. It is only a story we tell ourselves based on our current perspective, which has far more to do with our beliefs about ourselves than with anything else.
moony
4
Years of Service
User Offline
Joined: 2nd Jun 2014
Location:
Posted: 3rd Jun 2014 12:59
Thanks, you solved the counter problem. A simpler score-shover would be nice. Not sure though about the thing you suggested. I tried to do something inspired by you. Basically I made a variable sc and sc2 each for a digit in the score number. Ex the goal would be to get 100 points. 82 woud be sc=2 and sc2=8 i.e. sc are units and sc2 are tens. I tried this:


The problem I have with this one is that it hides all the score sprites. btw I now have two sets of sprites for numbers 12-21 being as you suggested '0' to '9' and sprites 22-31 the sprites for the second digit also from '0' to '9'
The Tall Man
5
Years of Service
User Offline
Joined: 16th Nov 2013
Location: Earth
Posted: 3rd Jun 2014 19:55 Edited at: 3rd Jun 2014 19:56
You're welcome!

There is a command you might try to get your score-showing sprites to show on top.

Quote: "dbSetSpritePriority
This command will set the relative priority of the specified sprite. All sprites start with a value of zero giving them equal chance of being drawn last. By setting a single sprite a value of one will cause that sprite to be drawn last. You can specify a unique priority value for each sprite creating an order of drawing for every sprite in your program. "




But you say it would be nice to have have a simple score-shower? I had kindof assumed you were using sprites for the specific reason of giving the text your own style. But I'm wondering now if my assumption was incorrect? There is a simple way to display text and numbers on the screen.





Judging what we see is the greatest blinder and self-limiter in the universe.

What we perceive is never reality. It is only a story we tell ourselves based on our current perspective, which has far more to do with our beliefs about ourselves than with anything else.

Login to post a reply

Server time is: 2019-04-25 01:49:32
Your offset time is: 2019-04-25 01:49:32