Highscore and complex animation problem, please help!

Non-platform specific questions.

Highscore and complex animation problem, please help!

Postby m93c » Tue Mar 12, 2013 2:43 pm

Hi guys!
I'm new to this forum and I recently started using GE. I'm surprised how easy is to use it and how powerful is!
However, as i sad, it's easy to learn and use, but when I decided to put a highscore system in my game I have had some problems... :cry:
I would like to have a top 10 list with name and score and when you do a higher score, the new replaces the old.
Except the name I have done this with saveVars and I'm able to have 10 different scores, from higher to lower.
The problem is that I don't want to simply replace the old score but I want the lower scores to "go down".
For example if I have 10 scores, I realize the new highscore and the old one becomes the second score, the second becomes the third and so on...
Actually I use ten Actors.
here is a picture of how it should work
Image

The other thing is that when my player actor collides with objects, a balloon has to explode until you have no balloons remaining.
At game start I have 3 balloons.
The problem is that when I collide with player right side, the right balloon explodes and so on... but I can't do this, or better I can do this (maybe) with 6 Actors ( too much :shock: )
Can you help me?
User avatar
m93c
 
Posts: 14
Joined: Mon Mar 11, 2013 3:03 pm
Score: 0 Give a positive score

Re: Highscore and complex animation problem, please help!

Postby skydereign » Tue Mar 12, 2013 5:34 pm

m93c wrote:I would like to have a top 10 list with name and score and when you do a higher score, the new replaces the old.
Except the name I have done this with saveVars and I'm able to have 10 different scores, from higher to lower.
The problem is that I don't want to simply replace the old score but I want the lower scores to "go down".
For example if I have 10 scores, I realize the new highscore and the old one becomes the second score, the second becomes the third and so on...
Actually I use ten Actors.

You can still use saveVars/loadVars. You just need to use string arrays and int arrays. Then you need to use a sorting algorithm to actually sort the lists. The trick to this though is you want to sort both the arrays, based off of the integer values (so if you move one in the integer array., move the same one in the string array). Another thing, instead of using 10 actors to display to display the 10 scores, use one actor, clone it 10 times, and use cloneindex to determine which score to show.
m93c wrote:The other thing is that when my player actor collides with objects, a balloon has to explode until you have no balloons remaining.
At game start I have 3 balloons.
The problem is that when I collide with player right side, the right balloon explodes and so on... but I can't do this, or better I can do this (maybe) with 6 Actors ( too much :shock: )
Can you help me?

Why would you need six actors? Do you understand how variables work, and clones?
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Highscore and complex animation problem, please help!

Postby m93c » Tue Mar 12, 2013 6:52 pm

thank you for your answer!
Talking about highscore, I know that I have to use something similar but I have no idea of what I have to write in script editor :| Could you post an example to make me understand?

For animation instead.... I'm very confused! :lol: :lol: :lol:
It's only a month I use GE...
How can I tell the game to explode the balloon on the right, for example, only if the animation is, in this case, right?
User avatar
m93c
 
Posts: 14
Joined: Mon Mar 11, 2013 3:03 pm
Score: 0 Give a positive score

Re: Highscore and complex animation problem, please help!

Postby kickstart » Tue Mar 12, 2013 8:13 pm

m93c wrote:For animation instead.... I'm very confused! :lol: :lol: :lol:
It's only a month I use GE...
How can I tell the game to explode the balloon on the right, for example, only if the animation is, in this case, right?


What do you want the baloon to do? Explode at a certain time? Well first you would have to go under the actor and add the exploding animation, and then use the Change Animation function for the animation to change to the (explode) on collision with the wall. You would do something like this:

Actor Control(balloon) > Collision > Colission with the baloon (Event Actor) and the wall, and the event would be to Change Animation. You would have the animation change to explode. They you could you the destroy actor function after that to your liking.
kickstart
 
Posts: 97
Joined: Tue Jan 29, 2013 8:42 pm
Score: 6 Give a positive score

Re: Highscore and complex animation problem, please help!

Postby m93c » Wed Mar 13, 2013 5:45 pm

Sorry, I haven't explained very well.
Actually, when the game starts, I have three animations (sprites): front, left, right. The three balloons are connected to a basket in a single sprite. My idea is that when I collide with something, the actor changes his animation into another sprite that has only 2 balloons (with the exploded balloon on the collision side). The same with one balloon until I get game over (no balloons). I want to change the animation according to the side of the collision and keep it until I collide one more time.
So after the first collision I have the 3 animations (left, front, right) with only 2 balloons using other 3 sprites.
User avatar
m93c
 
Posts: 14
Joined: Mon Mar 11, 2013 3:03 pm
Score: 0 Give a positive score

Re: Highscore and complex animation problem, please help!

Postby kickstart » Wed Mar 13, 2013 6:34 pm

m93c wrote:Sorry, I haven't explained very well.
Actually, when the game starts, I have three animations (sprites): front, left, right. The three balloons are connected to a basket in a single sprite. My idea is that when I collide with something, the actor changes his animation into another sprite that has only 2 balloons (with the exploded balloon on the collision side). The same with one balloon until I get game over (no balloons). I want to change the animation according to the side of the collision and keep it until I collide one more time.
So after the first collision I have the 3 animations (left, front, right) with only 2 balloons using other 3 sprites.


Well, with the way I understand it, you should have one animation of the three balloons, and then if the collision happens, it would set off another animation of it exploding, and after that an animation of the two left. If a collision happens here, then the same thing happens with it ending to be only one, etc.
Last edited by kickstart on Wed Mar 13, 2013 7:40 pm, edited 2 times in total.
kickstart
 
Posts: 97
Joined: Tue Jan 29, 2013 8:42 pm
Score: 6 Give a positive score

Re: Highscore and complex animation problem, please help!

Postby skydereign » Wed Mar 13, 2013 7:30 pm

JetpackGrizzly wrote:Well, with the way I understand it, you should have one animation of the three balloons, and then if the collision happens, it would set off another anumation of it exploding, and after that an animation of the two left. If a collsion happens here, then the same thing happens with it ending to be only one, etc.

Yup, you can make it act like an hp bar if you want.

m93c wrote:Talking about highscore, I know that I have to use something similar but I have no idea of what I have to write in script editor :| Could you post an example to make me understand?

This example should do the trick. http://game-editor.com/forum/viewtopic.php?f=4&t=9097&p
Sorting is a step up in code use if you haven't done any programming before. So if that is the case, make sure to take some extra time to really understand how it works.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Highscore and complex animation problem, please help!

Postby kickstart » Wed Mar 13, 2013 7:39 pm

skydereign wrote:
JetpackGrizzly wrote:Well, with the way I understand it, you should have one animation of the three balloons, and then if the collision happens, it would set off another anumation of it exploding, and after that an animation of the two left. If a collsion happens here, then the same thing happens with it ending to be only one, etc.

Yup, you can make it act like an hp bar if you want.


Yes you could, and that would be using a canvas. It would act as a health bar, here is a tutorial here:
http://game-editor.com/forum/viewtopic.php?f=27&t=995&hilit=canvas
kickstart
 
Posts: 97
Joined: Tue Jan 29, 2013 8:42 pm
Score: 6 Give a positive score

Re: Highscore and complex animation problem, please help!

Postby m93c » Wed Mar 13, 2013 8:37 pm

skydereign wrote:This example should do the trick. viewtopic.php?f=4&t=9097&p
Sorting is a step up in code use if you haven't done any programming before. So if that is the case, make sure to take some extra time to really understand how it works.


I've already downloaded it but I can't understand what is the code that allows the score to "go down".....
I started studing C++ last week at university and the little I know doesn't allow me understand all the code I see, unfortunately...

Talking about animation and health bar I have understood that I have to connect sprites with health.
What about if I create a variable (health) and when I collide with any object it reduces of 1 for ex. ?
The animation will be connected with health and when I have 3/4 of life for example, it means that GE has to use 2 balloons animation instead of 3.
Am I right?
User avatar
m93c
 
Posts: 14
Joined: Mon Mar 11, 2013 3:03 pm
Score: 0 Give a positive score

Re: Highscore and complex animation problem, please help!

Postby skydereign » Wed Mar 13, 2013 8:48 pm

m93c wrote:I've already downloaded it but I can't understand what is the code that allows the score to "go down".....
I started studing C++ last week at university and the little I know doesn't allow me understand all the code I see, unfortunately...

Well, I was really meaning the bubble sort implementation by Bee-Ant in that topic. Though, the code in the actual demo should be pretty easy to understand (though not very good way of doing it). All it is doing is determining where the new score should be placed, relative to the current scores. Then it works backwards, setting the last score to the second last score, up until it reaches the newly placed high score. s[3] is the last score on the list, and if a new score is placed above it, then you don't need to keep track of it any more. So, you set it equal to s[2]. One thing though, if you got some code from a topic, and don't know how it works, you should ask for an explanation on that topic. It keeps things cleaner that way, and shows us what you are currently trying.

m93c wrote:The animation will be connected with health and when I have 3/4 of life for example, it means that GE has to use 2 balloons animation instead of 3.

I think you mean 2/3's will have 2 balloons. But that is the general idea. The only thing is, it isn't automatic, so you'll have to make the animation adjust based off of the value of hp. The first part of this page goes a little into how you would do that. http://game-editor.com/HP_Bar
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Highscore and complex animation problem, please help!

Postby m93c » Thu Mar 14, 2013 5:43 pm

ok, I solved the highscore problem! :D
Now, I don't know why, I can't save player's name :(
When I get game over, 2 Actors are created: "insertname" and "save".
In the first, obviously, I insert my name.
Clicking the second it should save the name in a variable called name[] (string var.) and another actor (firstname) on the scores panel should load that variable and copy the name stored in it.
I have done like the example posted by skydereign (viewtopic.php?f=4&t=9097&p) and I wrote this code in "save" actor:
this is when I get a score>highscore
...
...
strcpy(name[3], name[2]);
strcpy(name[2], name[1]);
strcpy(name[1], name[0]);
sprintf(insertname.text, name[0]); <--- also inverted
saveVars("Highscore.dat", "nscore");

and this in the actor that should copy that value:
loadVars("Highscore.dat", "nscore");
sprintf(name[0], firstname.text);

I saved scores and names in the same file "highscore.dat", is this wrong?
What should I do?

P.s.: sorry for the length of the post and for my ignorance
User avatar
m93c
 
Posts: 14
Joined: Mon Mar 11, 2013 3:03 pm
Score: 0 Give a positive score

Re: Highscore and complex animation problem, please help!

Postby kickstart » Thu Mar 14, 2013 6:21 pm

First off, I cannot help you with this problem, but I do have something to say. You do not need to save the files with a .dat extension, they do not need to have an extension at all. I do not know if you name it .dat, that it would mess up the file because it is trying to make itself a data file and not just a "file." This could be the problem, but I doubt it. Even if it is not the problem, I would suggest doing that anyways.
kickstart
 
Posts: 97
Joined: Tue Jan 29, 2013 8:42 pm
Score: 6 Give a positive score

Re: Highscore and complex animation problem, please help!

Postby skydereign » Thu Mar 14, 2013 7:18 pm

Your load has the strcpy reversed.
Code: Select all
strcpy(destination, "string to be copied");
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Highscore and complex animation problem, please help!

Postby m93c » Fri Mar 15, 2013 3:31 pm

I think the problem is I can't save the name inserted...
The text actor doesn't display any text or it disappears...
strcpy I think is ok, it should copy the precedent string into the following one.
Is there another way to do this?
User avatar
m93c
 
Posts: 14
Joined: Mon Mar 11, 2013 3:03 pm
Score: 0 Give a positive score

Re: Highscore and complex animation problem, please help!

Postby skydereign » Fri Mar 15, 2013 6:17 pm

Okay, so actually both your strcpy calls are backwards, since name[0] is the name the player inputs.
Code: Select all
strcpy(desintation, "string to be copied");
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Next

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron