Project1
标题:
股票(债券系统)
[打印本页]
作者:
yangff
时间:
2008-5-30 05:30
标题:
股票(债券系统)
由于对title(加载脚本)load、save(存储数据)进行修改,导致冲突。故分开发代码。
没有范例,以后也不会有。
没有截图,就是一个土到垃圾的窗口。
就是这样。
2、3、4楼请不要站
我发代码
作者:
yangff
时间:
2008-5-30 05:31
Scene_Gu8
class Scene_Gu
def main
@spriteset = Spriteset_Map.new
$window_gu = Window_Gu.new
@index = 1
Audio.bgs_stop
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
$window_gu.update
# 如果画面被切换就中断循环
if Input.trigger?(Input::B)#$scene != self
break
end
end
# 装备过渡
Graphics.freeze
$window_gu.dispose
$scene = Scene_Map.new
end
end
复制代码
作者:
yangff
时间:
2008-5-30 05:31
Class_Gu
$最大波动 = 20
$最小波动 = 5
class Class_Gu
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_accessor :shellmonny # 股价
attr_accessor :getgu # 持股
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def init
@shellmonny = 100
@getgu = 0
end
def buy
if $game_party.gold > @shellmonny
$game_party.gain_gold(-@shellmonny)
@getgu += 1
end
end
def shell
if @getgu >= 1
$game_party.gain_gold(@shellmonny)
@getgu -= 1
end
end
#--------------------------------------------------------------------------
# ● 刷新对像
#--------------------------------------------------------------------------
def updata
rnd = rand($最大波动-($最小波动+1))+($最小波动-1)
if rand(2) == 1
@shellmonny = @shellmonny + rnd
else
@shellmonny = @shellmonny - rnd
end
end
end
class Window_Gu < Window_Base
#窗口对象开始
#--------------------------------------------------------------------------
# ● 初始化窗口对像
#--------------------------------------------------------------------------
def initialize
super(4*32, 4*32, 7*32-16, 4*32)
self.contents = Bitmap.new(width - 32, height - 32)
@index = 1
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
cx = contents.text_size($data_system.words.gold).width
cc = contents.text_size($Gu.shellmonny.to_s).width
@cp = contents.text_size($Gu.getgu.to_s).width
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, 120-cx-2, 32, "今日股价:", 2)
self.contents.draw_text(32, 0, 120-cx-2, 32, $Gu.shellmonny.to_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(124+cc, 0, cx, 32, $data_system.words.gold, 2)
self.contents.draw_text(4, 32, 60-cx-2, 32, "买入", 2)
self.contents.draw_text(4+64+4,32,@cp,32,$Gu.getgu.to_s,2)
self.contents.draw_text(4+64+@cp+4, 32, 60-cx-2, 32, "卖出", 2)
#~ @x = 4
#~ @y = 32
end
def update
super
if Input.repeat?(Input::LEFT)
@index= @index-1
if @index <= 0
@index = 2
end
end
if Input.repeat?(Input::RIGHT)
@index = @index+1
if @index >= 3
@index = 1
end
end
if @index == 1
self.cursor_rect.set(4, 32, 64, 32)
end
if @index == 2
self.cursor_rect.set(4+64+@cp+4, 32, 64, 32)
end
if Input.trigger?(Input::C)
if @index == 1
$Gu.buy
else
$Gu.shell
end
#画面再生成
refresh
end
end
end
复制代码
作者:
yangff
时间:
2008-5-30 05:31
追加定义
class Scene_Title
#--------------------------------------------------------------------------
# ● 命令 : 新游戏
#--------------------------------------------------------------------------
def command_new_game
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 停止 BGM
Audio.bgm_stop
# 重置测量游戏时间用的画面计数器
Graphics.frame_count = 0
# 生成各种游戏对像
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen = Game_Screen.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
##########################################################
### 追加脚本 ###
##########################################################
$Gu = Class_Gu.new
$Gu.init
$Gu.updata
##########################################################
# 设置初期同伴位置
$game_party.setup_starting_members
# 设置初期位置的地图
$game_map.setup($data_system.start_map_id)
# 主角向初期位置移动
$game_player.moveto($data_system.start_x, $data_system.start_y)
# 刷新主角
$game_player.refresh
# 执行地图设置的 BGM 与 BGS 的自动切换
$game_map.autoplay
# 刷新地图 (执行并行事件)
$game_map.update
# 切换地图画面
$scene = Scene_Map.new
end
end
class Scene_Save < Scene_File
def write_save_data(file)
# 生成描绘存档文件用的角色图形
characters = []
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
characters.push([actor.character_name, actor.character_hue])
end
# 写入描绘存档文件用的角色数据
Marshal.dump(characters, file)
# 写入测量游戏时间用画面计数
Marshal.dump(Graphics.frame_count, file)
# 增加 1 次存档次数
$game_system.save_count += 1
# 保存魔法编号
# (将编辑器保存的值以随机值替换)
$game_system.magic_number = $data_system.magic_number
# 写入各种游戏对像
Marshal.dump($game_system, file)
Marshal.dump($game_switches, file)
Marshal.dump($game_variables, file)
Marshal.dump($game_self_switches, file)
Marshal.dump($game_screen, file)
Marshal.dump($game_actors, file)
Marshal.dump($game_party, file)
Marshal.dump($game_troop, file)
Marshal.dump($game_map, file)
Marshal.dump($game_player, file)
Marshal.dump($Gu, file)
end
end
class Scene_Load < Scene_File
def read_save_data(file)
# 读取描绘存档文件用的角色数据
characters = Marshal.load(file)
# 读取测量游戏时间用画面计数
Graphics.frame_count = Marshal.load(file)
# 读取各种游戏对像
$game_system = Marshal.load(file)
$game_switches = Marshal.load(file)
$game_variables = Marshal.load(file)
$game_self_switches = Marshal.load(file)
$game_screen = Marshal.load(file)
$game_actors = Marshal.load(file)
$game_party = Marshal.load(file)
$game_troop = Marshal.load(file)
$game_map = Marshal.load(file)
$game_player = Marshal.load(file)
$Gu = Marshal.load(file)
# 魔法编号与保存时有差异的情况下
# (加入编辑器的编辑过的数据)
if $game_system.magic_number != $data_system.magic_number
# 重新装载地图
$game_map.setup($game_map.map_id)
$game_player.center($game_player.x, $game_player.y)
end
# 刷新同伴成员
$game_party.refresh
end
end
class Scene_Map
def transfer_player
# 清除主角场所移动调试标志
$Gu.updata
$game_temp.player_transferring = false
# 移动目标与现在的地图有差异的情况下
if $game_map.map_id != $game_temp.player_new_map_id
# 设置新地图
$game_map.setup($game_temp.player_new_map_id)
end
# 设置主角位置
$game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
# 设置主角朝向
case $game_temp.player_new_direction
when 2 # 下
$game_player.turn_down
when 4 # 左
$game_player.turn_left
when 6 # 右
$game_player.turn_right
when 8 # 上
$game_player.turn_up
end
# 矫正主角姿势
$game_player.straighten
# 刷新地图 (执行并行事件)
$game_map.update
# 在生成活动块
@spriteset.dispose
@spriteset = Spriteset_Map.new
# 处理过渡中的情况下
if $game_temp.transition_processing
# 清除过渡处理中标志
$game_temp.transition_processing = false
# 执行过渡
Graphics.transition(20)
end
# 执行地图设置的 BGM、BGS 的自动切换
$game_map.autoplay
# 设置画面
Graphics.frame_reset
# 刷新输入信息
Input.update
end
end
复制代码
作者:
yangff
时间:
2008-5-30 05:32
代码发完了。
切换场景股价调整一次
$scene = Scene_Gu.new
唤出股票窗口
作者:
link006007
时间:
2008-5-30 05:35
股票... 股票.... 股票..... 股票。。。
不如直接出个赌博系统
ps : 你就不会放在一个楼哦
作者:
yangff
时间:
2008-5-30 05:57
以下引用
link006007于2008-5-29 21:35:49
的发言:
股票... 股票.... 股票..... 股票。。。
不如直接出个赌博系统
ps : 你就不会放在一个楼哦
修改方便 {/dy}
我就是专门利己,毫不利人的大坏蛋 {/hx}
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1