How to create Achievements in games in AS3?

Started by
6 comments, last by jeteran 11 years, 8 months ago
Hi everybody.

I'm developing a small game and I thought that I can create some achievements to make it more cool.

Do you know any good tutorial / guide that I can lear how to create them in AS3?

I haven't yet research about it, but I think that, based on my xp, a good way to make them appear is by the use of flags; something like, for example: create a counter that sums the total of doors opened. When that counters hits 100, pull the flag doorsAchievement = true. That counter and flags are global vars.

What do you think about it? Is something like that or am I away from what really is?

Thanks so much for your time guys.

JET
Advertisement
Yep, you're on the right track: all you need to do is keep track of any statistic (kills, doors opened, times the player has jumped, fastest time through a level, whatever) you think might be an interesting basis to award one or more achievements, and then award the achievement when that stat reaches a certain value. If you proceed with your current line of thinking you should be able to implement a working system with little trouble.

For best flexibility you'll want probably want to consider tracking a few different kinds of data:

  • Simple counters. Used as you described to count the number of times something happens. Common examples might be kill counts, pick-ups, or repeating some action a certain number of times. All you need to do is increment the stored value, and once it reaches a certain threshold the achievement is unlocked.
  • Timers. If your game has sections or levels, you can time how long the player takes to complete each, and store the lowest value each time. You can then set goal times, and perhaps even have different rankings for bronze, silver and gold completion times. This is marginally more complicated than just counting a value, but not overly difficult as long as you have access to some sort of timing function, and it's a pretty popular type of achievement in games where it is appropriate.
  • Conditions under which a certain goal is accomplished. You might for example have an achievement for completing an entire level using only the most basic weapon. This is again a little more complicated than either timing or value-counters, but can potentially offer more interesting goals. You would most likely implement this using a series of flags; considering my example of completing a level using only the basic weapon, you would store a boolean value that is initially set to false and changed to true as soon as the weapon is changed. At the end of the level or game play section, you then check if your boolean has been toggled and award the achievement if appropriate. Obviously this type of achievement is very specific to your game play, and harder to generalise than the above options.


If you're developing Flash games, it's worth noting that you could choose to embed an existing system such as the Mochi Achievements API (check the developer section, they have a number of other useful tools as well.), or if you're publishing on certain platforms they might provide their own achievements API such as the one provided by Kongregate. Even if you choose not to make use of these options, it might be worth having a look at the functionality provided to get ideas for your own system.


Hope that's helpful! cool.png

- Jason Astle-Adams

Well, an achievement list is nothing more than stored values and often graphics changing one image file to another - or - (if simplified) from one stored value to another.

As a side note, I've just watched a lecture on data structures and algorithms, in which the tutor talked about looking at the problem in the simplest possible way. If your algorithm is way off, then it's gonna be a nightmare to process no matter how hard you optimize your program or hardware. But even a great algorithm can be the wrong one, if it boils down to you overthinking the problem.


More on-topic:

Supposing someone wants a fancy image-based achievement system like in WoW, here's a rough algorithm:

1. Add the basic "zero-achievements-awarded" pane (whatever graphics).
2. Add collapsibility to the pane (or separate windows for each category and link them together).
3. Add a 1D locational array to each page of achievements.
4. Give each array item a separate instance of a global variable (let's call it gloVar), set to 0 by default.
5. Add darkImageX to achX (etc for all possible achievements).
6. Add preconditions to each achievement (visually and syntaxically).

Now, to make achievements actually work in WoW:

7. When all preconditions are met, replace darkImageX with litupImageX and run the ImageXtoast animation in the main game window.
8. Set the array item's individual gloVar to 1.
9. Have achX swap place with the array item above it, if {varBinary == 0} - OR - the array item above achX has a name earlier in the alphabet. Else, do nothing more.
10. Update any group achievements that may be attached to this achievement.
11. Done.

I think paired If statements are the way to go. (1) If (action == true) {varCounter++} and (2) if (varCounter == 100) {update achX} (using pseudo-syntax here).

====================

I'm not familiar with AS3 myself, but hopefully my reply nonetheless added something useful. Good luck on the system though.

Cheers.

- Awl you're base are belong me! -

- I don't know, I'm just a noob -


Yep, you're on the right track: all you need to do is keep track of any statistic (kills, doors opened, times the player has jumped, fastest time through a level, whatever) you think might be an interesting basis to award one or more achievements, and then award the achievement when that stat reaches a certain value. If you proceed with your current line of thinking you should be able to implement a working system with little trouble.


WOW I'm impress jbadams, thank you sooo much for your support; your words are truly gold.

I will work in what you told me; sounds very interesting to implement statistics in the game and be tracked. And speaking about it, I LOVE statistics and want to implement them in the game; I have some Qs about it but I will make them in another post.

It's very good the way you told me to track the data in the game, sounds like a good way to have a great game design to me !! I'm going to analise it very carefuly !!

I'm going to try both APIs to see which one is close to my needs; even tho, I'll try to do it by myself, is not that rocket science (or why I'm an Engineer? ;) )

Once again, thank you so much jbadams !!!


Well, an achievement list is nothing more than stored values and often graphics changing one image file to another - or - (if simplified) from one stored value to another.

As a side note, I've just watched a lecture on data structures and algorithms, in which the tutor talked about looking at the problem in the simplest possible way. If your algorithm is way off, then it's gonna be a nightmare to process no matter how hard you optimize your program or hardware. But even a great algorithm can be the wrong one, if it boils down to you overthinking the problem.


Hey DrMadolite, thanks too for your great response !!

About your side note, did you see that lecture online? Will be cool if I can have a look at it; I have a BS in CS so I think won't be much of a problem ;)


1. Add the basic "zero-achievements-awarded" pane (whatever graphics).

About this, you mean like a place in the game where the progress of achievements appear? (I remember about Dwarfs?! or Left 4 Dead, they track the progress of the achvs) In the case of Dwarfs?! , once you get an achv, pop ups a nice note saying that you got it; feels good to see it !!


I'm not familiar with AS3 myself, but hopefully my reply nonetheless added something useful. Good luck on the system though.

Yes I understand completly what you told me, you did a nice work xplaining it !!

Thank you so much for your support guys, it's really nice and happy to be sorrounded by creative and happy-to-help people like you !!

I will work on all this !!

Happy week !!

About your side note, did you see that lecture online? Will be cool if I can have a look at it; I have a BS in CS so I think won't be much of a problem ;)


Let me link the youtube channel instead, since it's a lengthy college course (if you wanna see all the videos):
https://www.youtube....r/UNSWelearning


About this, you mean like a place in the game where the progress of achievements appear?


Yes, the frame or window showing you the list of achievement obtainable or obtained. An achievement pane is essentially the same as a game screen, except that the entities/files used are 2D images and text rather than mobs, loot and buildings.

Cheers. smile.png

- Awl you're base are belong me! -

- I don't know, I'm just a noob -


Let me link the youtube channel instead, since it's a lengthy college course (if you wanna see all the videos):
https://www.youtube....r/UNSWelearning


Truly awesome, thanks DrMadolite, it's very valuable. I use the Khan Academy to be in touch with math, check it out here:
http://www.khanacademy.org/


Yes, the frame or window showing you the list of achievement obtainable or obtained. An achievement pane is essentially the same as a game screen, except that the entities/files used are 2D images and text rather than mobs, loot and buildings.

Thanks for the xplanation, I will work on this.

Thanks for your support !!
KA bookmarked smile.png

I'm doing Game Programming bachelor's in about 6 or 18 months, so I need to brush up on some math. Revisit some of the high school stuff and then learning more about vectors, logarithmics and other related stuff.

Cheers.

- Awl you're base are belong me! -

- I don't know, I'm just a noob -


I'm doing Game Programming bachelor's in about 6 or 18 months, so I need to brush up on some math. Revisit some of the high school stuff and then learning more about vectors, logarithmics and other related stuff.


Good to hear DrMadolite, yes KA it's a GREAT starting point, hope you like it !!

Let's keep in touch, and thanks once again for your help !!

This topic is closed to new replies.

Advertisement