=encoding euc-jp =head1 NAME =begin original Games::Cards::Tk - Package to write Tk ports for Games::Cards card games =end original Games::Cards::Tk - Games::CardsのTk用パッケージ =head1 概要 See L for all the non-GUI aspects of writing card games. use Games::Cards; use Games::Cards::Tk; # Create a canvas and print background etc. $My_Game->set_canvas($c); # my game will use canvas $c # ... do lots of things you do in Games::Cards anyway # Cards' Tk images will be moved automatically! $Stock->give_cards($Waste, 3); # Mark clicked card $card = $My_Game->get_card_by_tag("current"); $card->mark; =head1 説明 =head2 警告!!! =begin original This module is doubleplus alpha. It's entirely possible that large parts of it will be changing as I learn more Tk, and if you try to write a game that's much different from the included games, it may break. There's still some stuff that needs to be better modularized, abstracted, and otherwise made into good code. However, the current games seem to be pretty good for a first try, and I'd like to get comments in case I'm doing anything really stupid. =end original このモジュールはアルファ版++である。このモジュールの大部分は私がTkを学ぶにつれ変更されていく可能性が高い。そしてもしあなたがこのパッケージに含まれているのとは全然違ったゲームを書こうとするなら、このモジュールは破綻するかもしれない。よりよいモジュール化、抽象化、そして、よりよいコードへとする必要のあることはまだ残っている。だが、現在のゲームは、最初の試みとしては非常にうまくいっているようにみえる。私が本当に馬鹿なことをしているようなら、ぜひコメントを頂きたい。 =head2 概観 =begin original Each class in Games::Cards had a corresponding Games::Cards::Tk class. The classes are meant to be exactly the same, except that the Tk ones also take care of moving actual card images around the screen. =end original Games::Cardsの全てのクラスは、対応するGames::Cards::Tkクラスを持っている。 クラスは、Tkのクラスを除いて正確に同じものを意味し、画面上を移動するカードの画像も扱う。 =begin original The card images used were created by Oliver Xymoron (oxymoron@waste.org). =end original 利用したカード画像は、Oliver Xymoron (oxymoron@waste.org)によって作成された。 =head2 Games::Cards::Tk::Game =begin original This class ends up holding information - such as the canvas that the game is played on, card images - and methods like finding a card given its tag. =end original このクラスはつまるところ、情報 -- ゲームを行うキャンバス、カードの画像など -- と、タグ付けされたカードを見つけ出すなどのメソッドを保持する。 =over 4 =item card_width =item card_height =begin original The size of card images =end original カード画像の大きさ =item load_card_images =begin original Loads the card images and stores them to draw later. =end original カード画像のロードと後で描画するための保持。 =item card_image =begin original Returns the card image associated with this card. =end original このカードに関連付けられた画像を返す。 =item get_card_by_tag =begin original Given a tag, return the Card (on this Games' canvas) that has that tag, if any. =end original タグを与えると、そのタグを持っている(このGameのキャンバス上にある)Cardを返す。 =item get_card_by_tag =begin original Given a tag, return the CardSet (on this Games' canvas) that has that tag, if any. =end original タグを与えると、そのタグを持っている(このGameのキャンバス上にある)CardSetを返す。 [訳補足:get_cardset_by_tagが正しい] =item get_marked_card =begin original Is a card marked? If so, return it. =end original カードがマーク付けられているかチェック。もしそうなら、それを返す。 =item get_clicked_cardset =begin original Return the set which was clicked on. Do so by looking for the "current" tag, but note that that tag may apply either to a CardSet or to a Card in that set. =end original クリックされたセットを返す。 =item canvas =item set_canvas(Canvas) =begin original Return/set the Tk::Canvas associated with this Game =end original このゲームに関連付けられたTk::Canvasを返す。あるいはセットする。 =back =head2 Games::Cards::Tk::Card =begin original A Card is represented in GC::Tk as two rectangles, the front and back, which are always moved around together. The card is "turned over" by raising the front or back rectangle (but the face_up/face_down methods do that automatically for you). =end original CardはGC::Tkにおいて二つの矩形、すなわち前側と後ろ側を表す。これは常に一緒に移動する。前側、あるいは後ろ側の矩形を起こすことによってカードを「ひっくり返す」ことができる(face_up/face_downメソッドはこれを自動でやってくれる)。 =begin original Lots of methods are basically the same as Games::Cards::Card methods. We just have to add some GUI changes. But there are also some Tk-specific methods. =end original メソッドの多くは基本的にGames::Cards::Cardのメソッドと同じものである。我々はいくつかのGUI用の変更を付け加えるだけでいい。しかしまた、Tkに特化したメソッドもある。 =over 4 =item Tk_truename =begin original This returns a Tk tag that's guaranteed to belong to just one Card. (However, note this tag will include the card's front and back rectangles.) =end original このメソッドはひとつのCardに属することを保証するTkタグを返す(しかし、このタグはそのカードの前後の矩形を含むことに注意)。 =begin original Tk_truename_front and Tk_truename_back return tags that will access just the front or back image. =end original Tk_truename_frontとTk_truename_backはそれぞれ前側・後ろ側の画像にアクセスするタグを返す。 =item draw =begin original Draw a card for the first time. Note that this draws the front and back rectangle. The card is placed at 0,0. =end original 最初にカードを描画する。このメソッドは前川と後ろ側の矩形を描画することに注意すること。カードは0,0の位置に置かれる。 =item mark =begin original Mark a card. This is currently done by placing a black rectangle around it. =end original カードにマークする。現状ではカードの周囲に黒い矩形を置くことによって達成される。 =item unmark =begin original Unmark a card that was marked with the "mark" method. =end original "mark"メソッドでマークされたカードを解除する。 =item place(X, Y) =begin original Put a Card's images at X, Y. =end original Card画像をX,Yに置く。 =item redraw =begin original Redraw (i.e. raise) the card & make sure you're showing front/back correctly. =end original カードを再描画(つまりraise)し、正しく前後を表示してることを確認する。 =back =head2 Games::Cards::Tk::Deck =begin original This class exists but isn't terribly interesting. The main point is that by calling this class' new instead of Games::Cards::Deck::new, you automatically get a deck filled with Games::Cards::Tk::Cards instead of regular cards. =end original このクラスはそれほど興味深いものではない。主要なポイントは、Games::Cards::Deck::newの代わりにこのクラスのnewを呼ぶことによって、通常のカードではなくGames::Cards::Tk::Cardsで詰まったデッキを自動で得ることができるということだ。 =head2 Class Games::Cards::Tk::CardSet =begin original This class has extra methods to do Tk stuff to CardSets, i.e. drawing columns, rows, piles, hands of cards. =end original このクラスはTk用CardSetを扱うための追加メソッドを用意している。すなわち、カードの列・行・山・手持ちを描画する。 =begin original There are a few extra fields in the Tk version of the class: =end original Tk用の追加メソッド: =over 4 =item delta_x =begin original x distance between right side of one card and the next in the Set. 0 if you want the cards to totally overlap, some number of pixels smaller than a card if you want them to overlap some, larger than cardsize if you want them to not overlap at all. =end original CardSet内における、カードの右側とその隣のカードの右側との距離x。カードを完全に重ねたいなら値は0になる。ある程度重ねたいならカードサイズよりピクセルを小さく。全く重ねたくないならカードサイズより大きな値を。 =item border_x =begin original A column may be slightly wider/higher than the cards in it, for example. =end original 例えば、セット内のカードよりも少し幅広/長高な列。 =back =begin original Also delta_y and border_y. Fields are changed by the "attributes" method. =end original delta_yとborder_yもある。"attributes"メソッドを使ってフィールドの値は変更される。 =over 4 =item attributes(HASHREF) =begin original This is a copout way of setting a bunch of CardSet attributes in one shot. Settable attributes include: delta_x/y and border_x/y. Hashref's keys are attributes and values are things to set them to. =end original これは一発でCardSetの属性をセットするうまいやり方だ。セット可能な属性:delta_x/yとborder_x/y。ハッシュリファレンスのキーは属性名で、値はセットするべきもの。 =item redraw =begin original Redraw the Cards in this CardSet. This is the reason you have to set things like delta_y and border_x. =end original このCardSetにあるCardの再描写。これがdelta_yとborder_xのようなものをセットしなければならない理由だ。