Hi,
I've created a simple points system; you can give the player points based on things they do, track, and total them (all through code). It also plays audio when you get points. It's useful for games like mine, actually
Sample use:
PointsSystem.add_points("Kicked the cat", -100)PointsSystem.add_points("Defeat the hidden chicken boss", 370)It has a couple of caveats presently:
- Points/events are unique, meaning you can't add the same event twice.
- It uses system sounds for audio (but it's configurable).
You can find the latest version, always,
on GitHub over here. Here's a version, which I hope I remember to update:
Spoiler#==============================================================================## -- A simple points system; get or lose points from events.# -- Points are via "events" which are a name + score, eg.# -- "break the statue" => 100 points# -- Author: ashes999 (ashes999@yahoo.com)# -- Version 1.0module PointsSystem # Start: variables you can customize # These map to system sounds. POSITIVE_SOUND = 21 # shop NEGATIVE_SOUND = 3 # buzzer # End variables. Please don't touch anything below this line. # Key => event name, value => score @@points_scored = {} def self.add_points(event, score) @@points_scored[event] = score if (score >= 0) then play_sound
positive) else play_sound
negative) end end def self.total_points sum = 0 @@points_scored.map { |k, v| sum += v } return sum end def self.points_breakdown return @@points_scored end # key =>
ositive or :negative def self.play_sound(key) Sound.play_system_sound(POSITIVE_SOUND) if key ==
ositive Sound.play_system_sound(NEGATIVE_SOUND) if key == :negative endend
It's nothing glamorous, I promise
本贴来自国际rpgmaker官方论坛作者:ashes999处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:
https://forums.rpgmakerweb.com/threads/simple-points-system.28812/