设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
楼主: frantice
打印 上一主题 下一主题

[RM脚本] 脚本以及工程预留帖

 关闭 [复制链接]
头像被屏蔽

Lv1.梦旅人 (禁止发言)

涅磐之男

梦石
0
星屑
50
在线时间
0 小时
注册时间
2006-6-30
帖子
67
31
发表于 2006-7-23 02:46:40 | 只看该作者
关于blackjack(21点纸牌游戏) 脚本翻译及完美化

更新结果:
1,修正字体问题
2,翻译游戏语句
3,新建立@help.window
4,修正0赌本也可开始赌博问题
5,中文RM可使用.

游戏中可通过$scene = Scene_Blackjack.new呼唤此游戏
感谢原作者,感谢frantice为我们提供如此多精美的脚本,谢谢!
如需此游戏介绍,请跟贴或短信告知.

贴出更新脚本:
  1. $fontface = Font.default_name
  2. $fontsize = 22


  3. #游戏中可通过$scene = Scene_Blackjack.new呼唤此游戏

  4. class Scene_Blackjack

  5. def main
  6. @help_window = Window_Help.new
  7. @table_window = Window_Table.new
  8. @bet_window = Window_Bet.new
  9. @bet_window.index = 0
  10. @money_window = Window_Money.new
  11. @hitstay_window = Window_HitStay.new
  12. @hitstay_window.active = false
  13. @cards = []
  14. @graphic = []
  15. @card_used = 0
  16. variable_init
  17. shuffle2
  18. val_graphic
  19. shuffle
  20. Graphics.transition
  21. loop do
  22. Graphics.update
  23. Input.update
  24. update
  25. if $scene != self
  26. break
  27. end
  28. end
  29. Graphics.freeze

  30. @help_window.dispose
  31. @table_window.dispose
  32. @bet_window.dispose
  33. @money_window.dispose
  34. @hitstay_window.dispose
  35. end

  36. def update
  37. @table_window.update
  38. @bet_window.update
  39. @help_window.update
  40. @money_window.update
  41. @hitstay_window.update
  42. if @bet_window.active
  43. update_bet
  44. return
  45. end
  46. if @hitstay_window.active
  47. update_hitstay
  48. return
  49. end
  50. end

  51. def update_bet
  52. @help_window.set_text("请选择你想投入的赌本。")
  53. if Input.trigger?(Input::B)
  54. $game_system.se_play($data_system.cancel_se)
  55. @bet_window.index = 5
  56. return
  57. end
  58. if Input.trigger?(Input::C)
  59. case @bet_window.index
  60. when 0
  61. @bet = 25
  62. if ($game_party.gold >= @bet) and ((@currentbet+@bet) <= 500)
  63. $game_system.se_play($data_system.decision_se)
  64. bet
  65. else
  66. $game_system.se_play($data_system.buzzer_se)
  67. return
  68. end
  69. when 1
  70. @bet = 50
  71. if ($game_party.gold >= @bet) and ((@currentbet+@bet) <= 500)
  72. $game_system.se_play($data_system.decision_se)
  73. bet
  74. else
  75. $game_system.se_play($data_system.buzzer_se)
  76. return
  77. end
  78. when 2
  79. @bet = 100
  80. if ($game_party.gold >= @bet) and ((@currentbet+@bet) <= 500)
  81. $game_system.se_play($data_system.decision_se)
  82. bet
  83. else
  84. $game_system.se_play($data_system.buzzer_se)
  85. return
  86. end
  87. when 3
  88. @bet = 500
  89. if ($game_party.gold >= @bet) and ((@currentbet+@bet) <= 500)
  90. $game_system.se_play($data_system.decision_se)
  91. bet
  92. else
  93. $game_system.se_play($data_system.buzzer_se)
  94. return
  95. end
  96. when 4
  97. if @bet == 0
  98. $game_system.se_play($data_system.buzzer_se)
  99. else
  100. $game_system.se_play($data_system.decision_se)
  101. start_blackjack
  102. end
  103. when 5
  104. $game_system.se_play($data_system.cancel_se)
  105. $game_party.gain_gold(@currentbet)
  106. $scene = Scene_Map.new
  107. end
  108. end
  109. end

  110. def update_hitstay
  111. if Input.trigger?(Input::B)
  112. $game_system.se_play($data_system.cancel_se)
  113. @hitstay_window.index = 1
  114. return
  115. end
  116. if Input.trigger?(Input::C)
  117. case @hitstay_window.index
  118. when 0
  119. hit
  120. when 1
  121. stay
  122. end
  123. end

  124. end

  125. def bet

  126. $game_party.lose_gold(@bet)
  127. @currentbet += @bet
  128. @money_window.refresh(@currentbet)
  129. end

  130. def start_blackjack
  131. @help_window.set_text("请选择摸牌或保留。")
  132. @bet_window.active = false
  133. @m_hand1 = @cards[@card_used]
  134. @graphic1 = @graphic[@card_used]
  135. check_cards
  136. @card_used +=1
  137. @m_hand2 = @cards[@card_used]
  138. @graphic2 = @graphic[@card_used]
  139. check_cards
  140. @card_used +=1
  141. @d_hand1 = @cards[@card_used]
  142. @d_graphic1 = @graphic[@card_used]
  143. check_cards
  144. @card_used +=1
  145. @d_hand2 = @cards[@card_used]
  146. @d_graphic2 = @graphic[@card_used]
  147. @m_total = @m_hand1+@m_hand2
  148. @d_total = @d_hand1+@d_hand2
  149. if @m_hand1 == 1
  150. @m_ace =1
  151. @m_hand1=@m_hand1+10
  152. @m_total=@m_hand1 + @m_hand2
  153. end
  154. if @m_hand2 == 1
  155. if @m_hand1 != 11
  156. @m_ace = 1
  157. @m_hand2 = @m_hand2+10
  158. @m_total = @m_hand1+@m_hand2
  159. else
  160. @m_hand2 = 1
  161. @m_total = @m_hand1+@m_hand2
  162. end
  163. end

  164. if @d_hand1 == 1
  165. @d_ace =1
  166. @d_hand1=@d_hand1+10
  167. @d_total=@d_hand1 + @d_hand2
  168. end
  169. if @d_hand2 == 1
  170. if @d_hand1 != 11
  171. @d_ace = 1
  172. @d_hand2 = @d_hand2+10
  173. @d_total = @d_hand1+@d_hand2
  174. else
  175. @d_card2 = 1
  176. @d_total = @d_hand1+@d_hand2
  177. end
  178. end
  179. draw_cards

  180. check_win

  181. end

  182. def shuffle
  183. j = 51
  184. k = 0
  185. temp = 0
  186. temp2 = 0

  187. while (j>=0)
  188. k = rand(j)

  189. temp = @cards[j]
  190. temp2 = @graphic[j]
  191. @cards[j] = @cards[k]
  192. @graphic[j] = @graphic[k]
  193. @cards[k] = temp
  194. @graphic[k] = temp2

  195. j-=1

  196. end

  197. end

  198. def shuffle2
  199. @cards = [1,2,3,4,5,6,7,8,9,10,10,10,10,
  200. 1,2,3,4,5,6,7,8,9,10,10,10,10,
  201. 1,2,3,4,5,6,7,8,9,10,10,10,10,
  202. 1,2,3,4,5,6,7,8,9,10,10,10,10,
  203. 0,0]
  204. end

  205. def val_graphic
  206. for i in 0...53
  207. @graphic[i] = i
  208. end
  209. end

  210. def check_cards
  211. if @card_used == 52
  212. shuffle
  213. @card_used = 0
  214. end
  215. end

  216. def draw_cards
  217. @table_window.refresh(@m_hand1,@graphic1,
  218. @m_hand2,@graphic2,
  219. @m_hand3,@graphic3,
  220. @m_hand4,@graphic4,
  221. @m_hand5,@graphic5,
  222. @d_hand1,52,
  223. @d_hand2,@d_graphic2,
  224. @d_hand3,@d_graphic3,
  225. @d_hand4,@d_graphic4,
  226. @d_hand5,@d_graphic5,
  227. @m_total)
  228. end

  229. def draw_real_cards
  230. @table_window.refresh(@m_hand1,@graphic1,
  231. @m_hand2,@graphic2,
  232. @m_hand3,@graphic3,
  233. @m_hand4,@graphic4,
  234. @m_hand5,@graphic5,
  235. @d_hand1,@d_graphic1,
  236. @d_hand2,@d_graphic2,
  237. @d_hand3,@d_graphic3,
  238. @d_hand4,@d_graphic4,
  239. @d_hand5,@d_graphic5,
  240. @m_total)
  241. end

  242. def variable_init
  243. @bet = 0
  244. @currentbet = 0
  245. @dummy_gold = 0
  246. @m_hand1 = 0
  247. @graphic1 = 53
  248. @m_hand2 = 0
  249. @graphic2 = 53
  250. @m_hand3 = 0
  251. @graphic3 = 53
  252. @m_hand4 = 0
  253. @graphic4 = 53
  254. @m_hand5 = 0
  255. @graphic5 = 53
  256. @d_hand1 = 0
  257. @d_graphic1 = 53
  258. @d_hand2 = 0
  259. @d_graphic2 = 53
  260. @d_hand3 = 0
  261. @d_graphic3 = 53
  262. @d_hand4 = 0
  263. @d_graphic4 = 53
  264. @d_hand5 = 0
  265. @d_graphic5 = 53
  266. @m_ace = 0
  267. @d_ace = 0
  268. @test = 0
  269. end

  270. def hit
  271. check_cards
  272. @card_used +=1
  273. if @m_hand3 == 0
  274. @m_hand3 = @cards[@card_used]
  275. @graphic3 = @graphic[@card_used]
  276. elsif @m_hand4 == 0 and @m_hand3 != 0
  277. @m_hand4 = @cards[@card_used]
  278. @graphic4 = @graphic[@card_used]
  279. elsif @m_hand5 == 0 and @m_hand4 != 0
  280. @m_hand5 = @cards[@card_used]
  281. @graphic5 = @graphic[@card_used]
  282. end

  283. if @cards[@card_used] == 1
  284. if @m_total <=10
  285. @m_ace = 1
  286. @m_total += 11
  287. else
  288. @m_total += 1
  289. end
  290. else
  291. @m_total += @cards[@card_used]
  292. end

  293. check_win2


  294. end

  295. def stay
  296. while (@d_total<=@m_total)
  297. check_cards
  298. @card_used +=1
  299. if @d_hand3 == 0
  300. @d_hand3 = @cards[@card_used]
  301. @d_graphic3 = @graphic[@card_used]
  302. elsif @d_hand4 == 0 and @m_hand3 != 0
  303. @d_hand4 = @cards[@card_used]
  304. @d_graphic4 = @graphic[@card_used]
  305. elsif @d_hand5 == 0 and @m_hand4 != 0
  306. @d_hand5 = @cards[@card_used]
  307. @d_graphic5 = @graphic[@card_used]
  308. end

  309. if @cards[@card_used] == 1
  310. if @d_total <=10
  311. @d_ace = 1
  312. @d_total += 11
  313. else
  314. @d_total += 1
  315. end
  316. else
  317. @d_total += @cards[@card_used]
  318. end
  319. end
  320. check_win3
  321. end

  322. def check_win
  323. if @test == 0
  324. if @m_total == 21 and @d_total != 21
  325. draw_real_cards
  326. win
  327. elsif @m_total != 21 and @d_total == 21
  328. draw_real_cards
  329. lose
  330. elsif @m_total == 21 and @d_total == 21
  331. draw_real_cards
  332. tie
  333. else
  334. @test = 1
  335. @hitstay_window.active = true
  336. end
  337. end
  338. end

  339. def check_win2
  340. if @m_total >= 22 and @m_ace == 1
  341. @m_total -= 10
  342. @m_ace = 0
  343. draw_cards
  344. elsif @m_total >= 22
  345. draw_real_cards
  346. lose
  347. elsif @m_total == 21
  348. draw_real_cards
  349. win
  350. elsif @m_total <=20
  351. draw_cards
  352. @hitstay_window.active = true
  353. end
  354. end

  355. def check_win3
  356. if @d_total >= 22 and @d_ace == 1
  357. @d_total -= 10
  358. @d_ace = 0
  359. draw_real_cards
  360. elsif @d_total >= 22
  361. draw_real_cards
  362. win
  363. elsif @d_total == 21
  364. draw_real_cards
  365. lose
  366. elsif @d_total > @m_total and @d_total <= 20
  367. draw_real_cards
  368. lose
  369. elsif @d_total == @m_total
  370. draw_real_cards
  371. tie
  372. elsif @d_total < @m_total
  373. draw_real_cards
  374. win
  375. end
  376. end

  377. def win
  378. $game_party.gain_gold(@currentbet*2)
  379. @help_window.set_text("你赢了!")
  380. delay(3)
  381. $scene = Scene_Map.new
  382. end

  383. def lose
  384. @help_window.set_text("你输了…")
  385. delay(3)
  386. $scene = Scene_Map.new
  387. end

  388. def tie
  389. $game_party.gain_gold(@currentbet)
  390. @help_window.set_text("Tie!")
  391. delay(3)
  392. $scene = Scene_Map.new
  393. end

  394. def delay(seconds)
  395. for i in 0...(seconds * 10)
  396. sleep 0.1
  397. Graphics.update
  398. end
  399. end

  400. end



  401. class Window_Table < Window_Base

  402. def initialize
  403. super(0, 64, 512, 416)
  404. self.contents = Bitmap.new(width - 32, height - 32)
  405. self.contents.font.name = $fontface
  406. self.contents.font.size = $fontsize
  407. refresh
  408. end
  409. #--------------------------------------------------------------------------
  410. def refresh(hand1 = 0, graphic1 = 53,
  411. hand2 = 0, graphic2 = 53,
  412. hand3 = 0, graphic3 = 53,
  413. hand4 = 0, graphic4 = 53,
  414. hand5 = 0, graphic5 = 53,
  415. d_hand1 = 0, d_graphic1 = 53,
  416. d_hand2 = 0, d_graphic2 = 53,
  417. d_hand3 = 0, d_graphic3 = 53,
  418. d_hand4 = 0, d_graphic4 = 53,
  419. d_hand5 = 0, d_graphic5 = 53,
  420. total = 0)

  421. @hand1 = hand1
  422. @hand2 = hand2
  423. @hand3 = hand3
  424. @hand4 = hand4
  425. @hand5 = hand5
  426. @d_hand1 = d_hand1
  427. @d_hand2 = d_hand2
  428. @d_hand3 = d_hand3
  429. @d_hand4 = d_hand4
  430. @d_hand5 = d_hand5
  431. @graphic1 = graphic1
  432. @graphic2 = graphic2
  433. @graphic3 = graphic3
  434. @graphic4 = graphic4
  435. @graphic5 = graphic5
  436. @d_graphic1 = d_graphic1
  437. @d_graphic2 = d_graphic2
  438. @d_graphic3 = d_graphic3
  439. @d_graphic4 = d_graphic4
  440. @d_graphic5 = d_graphic5
  441. @total = total

  442. self.contents.clear

  443. self.contents.draw_text(32, 320, 128, 32, "你现在的点数: " + @total.to_s)

  444. graphic
  445. end

  446. def graphic
  447. x = 0
  448. y = 0
  449. @frame_width = 71
  450. @frame_height = 96
  451. if @graphic1 !=nil
  452. @xpos1 = @graphic1*@frame_width
  453. else
  454. @xpos1 = 52
  455. end
  456. if @graphic2 !=nil
  457. @xpos2 = @graphic2*@frame_width
  458. else
  459. @xpos2 = 52
  460. end
  461. if @graphic3 !=nil
  462. @xpos3 = @graphic3*@frame_width
  463. else
  464. @xpos3 = 52
  465. end
  466. if @graphic4 !=nil
  467. @xpos4 = @graphic4*@frame_width
  468. else
  469. @xpos4 = 52
  470. end
  471. if @graphic5 !=nil
  472. @xpos5 = @graphic5*@frame_width
  473. else
  474. @xpos5 = 52
  475. end
  476. if @d_graphic1 !=nil
  477. @xposd1 = @d_graphic1*@frame_width
  478. else
  479. @xposd1 = 52
  480. end
  481. if @graphic2 !=nil
  482. @xposd2 = @d_graphic2*@frame_width
  483. else
  484. @xposd2 = 52
  485. end
  486. if @d_graphic3 !=nil
  487. @xposd3 = @d_graphic3*@frame_width
  488. else
  489. @xposd3 = 52
  490. end
  491. if @graphic4 !=nil
  492. @xposd4 = @d_graphic4*@frame_width
  493. else
  494. @xposd4 = 52
  495. end
  496. if @d_graphic5 !=nil
  497. @xposd5 = @d_graphic5*@frame_width
  498. else
  499. @xposd5 = 52
  500. end
  501. bitmap = RPG::Cache.picture("cards")
  502. src_rect_hand1 = Rect.new(@xpos1, 0, @frame_width, @frame_height)
  503. src_rect_hand2 = Rect.new(@xpos2, 0, @frame_width, @frame_height)
  504. src_rect_hand3 = Rect.new(@xpos3, 0, @frame_width, @frame_height)
  505. src_rect_hand4 = Rect.new(@xpos4, 0, @frame_width, @frame_height)
  506. src_rect_hand5 = Rect.new(@xpos5, 0, @frame_width, @frame_height)
  507. src_rect_d_hand1 = Rect.new(@xposd1, 0, @frame_width, @frame_height)
  508. src_rect_d_hand2 = Rect.new(@xposd2, 0, @frame_width, @frame_height)
  509. src_rect_d_hand3 = Rect.new(@xposd3, 0, @frame_width, @frame_height)
  510. src_rect_d_hand4 = Rect.new(@xposd4, 0, @frame_width, @frame_height)
  511. src_rect_d_hand5 = Rect.new(@xposd5, 0, @frame_width, @frame_height)
  512. self.contents.blt(0,192,bitmap,src_rect_hand1)
  513. self.contents.blt(96,192,bitmap,src_rect_hand2)
  514. self.contents.blt(96*2,192,bitmap,src_rect_hand3)
  515. self.contents.blt(96*3,192,bitmap,src_rect_hand4)
  516. self.contents.blt(96*4,192,bitmap,src_rect_hand5)
  517. self.contents.blt(0,0,bitmap,src_rect_d_hand1)
  518. self.contents.blt(96,0,bitmap,src_rect_d_hand2)
  519. self.contents.blt(96*2,0,bitmap,src_rect_d_hand3)
  520. self.contents.blt(96*3,0,bitmap,src_rect_d_hand4)
  521. self.contents.blt(96*4,0,bitmap,src_rect_d_hand5)

  522. end


  523. end


  524. class Window_Bet < Window_Selectable
  525. # ------------------------------------
  526. def initialize
  527. super(512, 64, 128, 224)
  528. self.contents = Bitmap.new(width - 32, height - 32)
  529. self.contents.font.name = $fontface
  530. self.contents.font.size = $fontsize
  531. @column_max = 1
  532. refresh
  533. self.index = 0
  534. end
  535. # ------------------------------------

  536. def refresh
  537. if self.contents != nil
  538. self.contents.dispose
  539. self.contents = nil
  540. end
  541. @data = []
  542. @item_max = 6
  543. if @item_max > 0
  544. self.contents = Bitmap.new(width - 32, row_max * 32)
  545. for i in 0...@item_max
  546. draw_item(i)
  547. end
  548. end
  549. end
  550. # ------------------------------------
  551. def draw_item(index)
  552. x = 4
  553. y = index * 32
  554. rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  555. self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  556. case index
  557. when 0
  558. self.contents.draw_text(x , y, 128, 32, "25", 0)
  559. when 1
  560. self.contents.draw_text(x , y, 128, 32, "50", 0)
  561. when 2
  562. self.contents.draw_text(x , y, 128, 32, "100", 0)
  563. when 3
  564. self.contents.draw_text(x , y, 128, 32, "500", 0)
  565. when 4
  566. self.contents.draw_text(x , y, 128, 32, "完成", 0)
  567. when 5
  568. self.contents.draw_text(x , y, 128, 32, "退出", 0)
  569. end
  570. end
  571. # ------------------------------------
  572. def update_help
  573. @help_window.set_text("" )
  574. end
  575. end


  576. class Window_Money < Window_Base
  577. # ------------------------------------
  578. def initialize
  579. super(512, 288, 128, 96)
  580. self.contents = Bitmap.new(width - 32, height - 32)
  581. self.contents.font.name = $fontface
  582. self.contents.font.size = $fontsize
  583. @bet = 0
  584. refresh(@bet)
  585. end
  586. # ------------------------------------
  587. def refresh(bet)
  588. @bet = bet
  589. self.contents.clear
  590. self.contents.font.color = normal_color
  591. self.contents.draw_text(0, 0, 96, 32, $game_party.gold.to_s,2)
  592. self.contents.draw_text(0, 32, 96, 32, @bet.to_s, 2)
  593. end
  594. end


  595. class Window_HitStay < Window_Selectable
  596. # ------------------------------------
  597. def initialize
  598. super(512, 384, 128, 96)
  599. self.contents = Bitmap.new(width - 32, height - 32)
  600. self.contents.font.name =$fontface
  601. self.contents.font.size = $fontsize
  602. @column_max = 1
  603. refresh
  604. self.index = 0
  605. end
  606. # ------------------------------------

  607. def refresh
  608. if self.contents != nil
  609. self.contents.dispose
  610. self.contents = nil
  611. end
  612. @data = []
  613. @item_max = 2
  614. if @item_max > 0
  615. self.contents = Bitmap.new(width - 32, row_max * 32)
  616. for i in 0...@item_max
  617. draw_item(i)
  618. end
  619. end
  620. end
  621. # ------------------------------------
  622. def draw_item(index)
  623. x = 4
  624. y = index * 32
  625. rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  626. self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  627. case index
  628. when 0
  629. self.contents.draw_text(x , y, 128, 32, "摸牌", 0)
  630. when 1
  631. self.contents.draw_text(x , y, 128, 32, "保留", 0)
  632. end
  633. end
  634. # ------------------------------------
  635. def update_help
  636. @help_window.set_text("" )
  637. end
  638. end

复制代码


工程下载:http://rpg.blue/upload_program/files/blackjack.exe

签名被屏蔽
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-11-16 08:09

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表