Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[improvment] Mahjong app be able to adapt to different devices( pc, i…

…pad, apad, cellphone)
  • Loading branch information...
commit a35df26e14669a9c3bff26cd437ee1562660ca88 1 parent 5051721
@winbomb authored
View
129 plugins/engine2d.js
@@ -21,11 +21,12 @@ var game;
##register preload: opa[list(string)],opa[list(string)],( -> void) -> void
##args(imgIdents,audIdents,callback)
{
- AUD_CACHE = {};
var images = list2js(imgIdents);
var audios = list2js(audIdents);
- var countLoaded = 0;
- var countTotal = 0;
+ var imgLoaded=0,imgError=0,imgTotal=0;
+ var audLoaded=0,audError=0,audTotal=0;
+
+ var progressChanged = +new Date;
function incrementLoaded() {
countLoaded++;
@@ -44,24 +45,58 @@ var game;
function imgSuccessHandler() {
IMG_CACHE[this.key] = this;
- incrementLoaded();
+ imgLoaded++;
+ updateProgress();
+ progressChanged = +new Date;
}
+ //不知到为什么Firefox会触发两次canplay事件,
+ //如果不做判断,会出现countLoaded大于countTotal的事情。
function audSuccessHandler() {
- //不知到为什么Firefox会触发两次canplay事件,
- //如果不做判断,会出现countLoaded大于countTotal的事情。
if(!AUD_CACHE[this.key]){
AUD_CACHE[this.key] = this;
- incrementLoaded();
+ audLoaded++;
}
+ progressChanged = +new Date;
+ updateProgress();
+ }
+
+ function imgErrorHandler() {
+ imgError++;
+ progressChanged = +new Date;
+ updateProgress();
+ throw new Error('Error loading image: ' + this.src);
}
- function errorHandler() {
- incrementLoaded();
- throw new Error('Error loading ' + this.src);
+ function audErrorHandler() {
+ audError++;
+ progressChanged = +new Date;
+ updateProgress();
+ throw new Error('Error loading sound: ' + this.src);
+ }
+
+ var updateProgress = function(){
+ info = document.getElementById("loading_info");
+ if(!!info){
+ info.innerHTML = "loading game resource... [ "+(imgLoaded+audLoaded)+" / "+(imgTotal+audTotal)+" ]"
+ }
+ }
+
+ var statusCheck = function() {
+ var finished = ((imgLoaded + imgError >= imgTotal) && (audLoaded + audError >= audTotal));
+ if(finished){
+ return callback();
+ }
+
+ //如果图片加载完成,声音加载超时地话,也开始游戏
+ var noProgressTime = (+new Date) - progressChanged;
+ if((imgLoaded + imgError >= imgTotal) && noProgressTime >= 3000){
+ return callback();
+ }
+ setTimeout(statusCheck,1000);
}
- for (var i=0;i<images.length;i++) {
+ for (var i=0;i<images.length;i++) {
var key = images[i]
if (key.indexOf('png') == -1 &&
key.indexOf('jpg') == -1 &&
@@ -70,36 +105,31 @@ var game;
}
var img = new Image();
- countTotal++;
- img.addEventListener('load', imgSuccessHandler, true);
- img.addEventListener('error', errorHandler, true);
+ imgTotal++;
+ img.addEventListener('load', imgSuccessHandler, true);
+ img.addEventListener('error',imgErrorHandler, true);
img.src = key;
img.key = key;
}
-
+
if(window.HTMLAudioElement){
- try{
- var audio = document.createElement("audio");
- if(audio != null && audio.canPlayType && audio.canPlayType("audio/wav")){
- for( var i=0;i<audios.length;i++){
- var key = audios[i]
- if(key.indexOf('wav') == -1) continue;
-
- var audio = new Audio();
- audio.addEventListener('canplaythrough', audSuccessHandler, true);
- audio.addEventListener('error', errorHandler, true);
- audio.src = key;
- audio.key = key;
- audio.load();
-
- countTotal++;
- }
- }
- }catch(e){
- alert("Error: "+e);
- window.console.error("Error"+e);
- }
+ var audio = document.createElement("audio");
+ if(audio != null && !!audio.canPlayType && !!audio.canPlayType("audio/wav")){
+ for( var i=0;i<audios.length;i++){
+ var key = audios[i]
+ if(key.indexOf('wav') == -1) continue;
+ var audio = new Audio();
+ audio.addEventListener('canplaythrough', audSuccessHandler, true);
+ audio.addEventListener('error', audErrorHandler, true);
+ audio.src = key;
+ audio.key = key;
+ audio.load();
+
+ audTotal++;
+ }
+ }
}
+ setTimeout(statusCheck,1000);
}
##register get: string -> Image.image
@@ -123,16 +153,16 @@ var counter;
return function(){
if(counter > 0){
counter = counter - 1;
- ctx.clearRect(330+28,237+28,24,24);
+ ctx.clearRect(360+28,237+28,24,24);
ctx.restore();
ctx.save(ctx);
ctx.fillStyle = "#efea3a";
- ctx.fillRect(330+28,237+28,24,24);
+ ctx.fillRect(360+28,237+28,24,24);
ctx.fillStyle = "red";
ctx.font = "normal bold 24px serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
- ctx.fillText(counter,370,277);
+ ctx.fillText(counter,400,277);
ctx.restore();
window.setTimeout(arguments.callee,1000);
@@ -148,8 +178,8 @@ var counter;
counter = 0;
}
-##register show_menu: int -> void
-##args(opt_flag)
+##register show_menu: int,bool -> void
+##args(opt_flag,is_zh)
{
var ctx = document.getElementById("gmcanvas").getContext("2d");
var arr = [8,4,2,1]
@@ -186,12 +216,12 @@ var counter;
}
loop.call(this)(); */
- var img = get_img("menu_bar.png");
- for(var i=0, x=490; i<arr2.length; i++){
+ var img = (!is_zh)?get_img("en_menu_bar.png"):get_img("cn_menu_bar.png");
+ for(var i=0, x=550; i<arr2.length; i++){
if(arr2[i]){
- ctx.drawImage(img,60*i,0,60,60,x+60*i,475,60,60);
+ ctx.drawImage(img,60*i,0,60,60,x+60*i,435,60,60);
}else{
- ctx.drawImage(img,60*i,60,60,60,x+60*i,475,60,60);
+ ctx.drawImage(img,60*i,60,60,60,x+60*i,435,60,60);
}
}
}
@@ -214,15 +244,14 @@ var get_img = function(key){
##register play_sound: string -> void
##args(key)
{
- var snd = AUD_CACHE[key];
- if(snd){
+ if(AUD_CACHE[key]){
//注:如果不加snd.reload(),chrome好像无法重新播放声音,即只播放一次
//之后再不会播放,不知道啥原因,自从升级了chrome(18onlinux,21onwindows)
//就有这个问题。但不晓得这样每次播放都reload会不会带来系统负担。
//关注此问题!
- snd.load();
- snd.play();
- }
+ if(window.chrome) AUD_CACHE[key].load();
+ AUD_CACHE[key].play();
+ }
}
//两个参数,一个是cookie的名子,一个是值
View
BIN  resources/actions.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  resources/board.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  resources/cn_menu_bar.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
124 resources/css/game.css
@@ -0,0 +1,124 @@
+* {
+ margin: 0
+ padding: 0
+}
+
+body {
+ background: url("/resources/page_bg.jpg") repeat wheat;
+ color: #DDD;
+ font-size: 13px;
+ line-height: 120%;
+ text-align: center;
+}
+
+div {
+ display: block;
+}
+
+.game{
+ margin: 0 auto;
+}
+
+#container {
+ position: absolute;
+ width: 800px;
+ height: 600px;
+ left: 50%;
+ top: 50%;
+ margin-left: -400px;
+ margin-top: -300px;
+ border-color: #333333;
+ border-radius: 0.3em 0.3em 0.3em 0.3em;
+ border-style: solid;
+ border-width: 2px;
+ box-shadow: 0 0 5px blue, 0 25px 5px rgba(255, 255, 255, 0.1) inset;
+}
+
+#chat {
+ width: 225px;
+ text-align: left;
+ position: absolute;
+ bottom: 0px;
+ background: #5C5C5C;
+ background: rgba(92, 92, 92, 0.5);
+ border: 1px solid #444;
+ border-radius: 0.3em 0.3em 0.3em 0.3em;
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.7);
+}
+
+#chat_title {
+ padding: 8px;
+ background: #020202;
+ background: rgba(2, 2, 2, 0.5);
+ box-shadow: 0 17px 5px rgba(255, 255, 255, 0.1) inset;
+ -moz-box-shadow: 0 17px 5px rgba(255, 255, 255, 0.1) inset;
+ -webkit-box-shadow: 0 17px 5px rgba(255, 255, 255, 0.1) inset;
+ border-bottom: 1px solid black;
+}
+
+#chat ul {
+ margin: 0px;
+ padding: 0px;
+ color: white;
+ width: 100%;
+ min-height: 50px;
+ max-height: 200px;
+ overflow: auto;
+ list-style: none;
+ border-top: 1px solid #666;
+}
+
+#chat_box {
+ padding: 2px;
+}
+
+input.chat_textbox {
+ font-size: 1.4em;
+ margin: 0px;
+}
+
+#gmcanvas {
+ background: #258e80;
+}
+
+#gmloader {
+ background: url("/resources/loading.gif") center center no-repeat;
+ position: absolute;
+ margin-top: 260px;
+ margin-left: 300px;
+ height: 60px;
+}
+
+#loading_info {
+ position: relative;
+ top: 60px;
+ color: black;
+}
+
+#chat_messages {
+ clear: both;
+ border: 0px;
+ height: 360px;
+ width: 207px;
+ margin: 20px 0px 8px 10px;
+ color: #ffebc7;
+ overflow-y: scroll;
+ text-shadow: black 1px 1px 1px;
+}
+
+#chat_messages li {
+ list-style: none;
+ word-wrap: break-word;
+ text-align: left;
+ margin: 3px 0px;
+ font-size: 13px;
+}
+
+#chat_messages .author {
+ clear: both;
+ float: left;
+ font-size: 12px;
+ font-weight: bold;
+ margin-right: 5px;
+}
+
View
58 resources/css/game_small.css
@@ -0,0 +1,58 @@
+* {
+ margin: 0;
+ padding: 0;
+ -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
+}
+
+body {
+ background: wheat;
+ color: #DDD;
+ font-size: 13px;
+ line-height: 120%;
+ text-align: center;
+}
+
+div {
+ display: block;
+}
+
+.game {
+ margin: 0 auto;
+}
+
+#container {
+ position: absolute;
+ width: 800px;
+ height: 600px;
+ left: 50%;
+ top: 50%;
+ margin-left: -400px;
+ margin-top: -320px;
+}
+
+#chat {
+ display: none;
+}
+
+#gmcanvas {
+ background: #258e80;
+}
+
+#gmloader {
+ background: url("/resources/loading.gif") center center no-repeat;
+ position: absolute;
+ width: 300px;
+ height: 80px;
+ left: 50%;
+ top: 50%;
+ margin-top: -40px;
+ margin-left: -150px;
+}
+
+#loading_info {
+ position: relative;
+ margin-top: 60px;
+ color: black;
+}
+
+
View
0  resources/main.css → resources/css/main.css
File renamed without changes
View
87 resources/css/main_small.css
@@ -0,0 +1,87 @@
+* {margin:0;padding:0;}
+
+/* must declare 0 margins on everything, also for main layout components use padding, not
+vertical margins (top and bottom) to add spacing, else those margins get added to total height
+and your footer gets pushed down a bit more, creating vertical scroll bars in the browser */
+
+html, body {height: 100%;}
+
+#container {
+ height: 100%;
+ min-height: 400px;
+}
+
+#content {
+ overflow:auto;
+ padding-bottom: 60px;
+ height: 400px;
+} /* must be same height as the footer */
+
+
+#footer {
+ position: relative;
+ margin-top: -60px; /* negative value of footer height */
+ height: 60px;
+ clear:both;
+ text-align: center;
+ background-color: #AAA;
+ width: 100%;
+ padding-top: 10px;
+}
+
+/*Opera Fix*/
+body:before {/* thanks to Maleika (Kohoutec)*/
+ content:"";
+ height:100%;
+ float:left;
+ width:0;
+ margin-top:-32767px;/* thank you Erik J - negate effect of float*/
+}
+
+div {
+ display: block;
+}
+
+body,html {
+ margin: 0;
+ padding: 0;
+ font: 12px/1.5 arial;
+ height:100%;
+}
+
+body {
+ background: #0D1F29;
+ color: #DDD;
+ font-size: 13px;
+ line-height: 120%;
+ min-height: 580px0;
+ display: block;
+}
+
+#content {
+ padding: 10px;
+ background: url("/resources/dragon_small.jpg") no-repeat scroll center top #0C1E28;
+}
+
+#login_box {
+ position: relative;
+ margin: 0 auto;
+ width: 300px;
+ height: 240px;
+ top: 135px;
+ color: #EBEBEB;
+ font: 12px Arial, Helvetica, sans-serif;
+}
+
+.txt_user{
+ margin-top: 8px;
+ width: 96%;
+}
+.btn_play{
+ margin: 0px;
+ width: 100%;
+}
+
+#btn_group{
+ display: none;
+}
View
0  resources/page.css → resources/css/page.css
File renamed without changes
View
46 resources/css/page_small.css
@@ -0,0 +1,46 @@
+* {
+ margin: 0px;
+ padding: 0px;
+}
+
+body {
+ background: url("/resources/page_bg.jpg") repeat #0c1e28;
+}
+
+.dragon_bg {
+ background: url("/resources/dragon_small.jpg") no-repeat scroll center top #0C1E28;
+ margin: 0px auto;
+}
+
+#game_list {
+ background: #0C1E28;
+ margin: 10px auto;
+ width: 92%;
+ border: 3px solid red;
+ padding: 5px;
+}
+
+.quick-start {
+ clear: both;
+ float: right;
+ margin: 5px 0px;
+}
+
+.title {
+ color: WHITE;
+ float: right;
+}
+
+.tb_game_list {
+ background: WHITE;
+ width: 100%;
+ border: 1px solid RED;
+}
+
+.tb_game_list th, .tb_game_list td {
+ border-right: 1px solid black;
+ border-bottom: 1px solid black;
+ padding: 2px;
+ text-align: center;
+ vertical-align: middle;
+}
View
BIN  resources/dialog.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  resources/dragon_small.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
0  resources/menu_bar.png → resources/en_menu_bar.png
File renamed without changes
View
BIN  resources/exit.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  resources/loading.bak.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  resources/loading.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  resources/mahjong-48.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  resources/setting.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
153 resources/style.css
@@ -1,153 +0,0 @@
-* {
- margin: 0
- padding: 0
-}
-
-body {
- background: url("/resources/page_bg.jpg") repeat scroll center top #0c1e28;
- color: #DDD;
- font-size: 13px;
- line-height: 120%;
- text-align: center;
- height: 100%;
- min-height: 640px;
-}
-
-
-.text {
- /** background: url("/resources/input_field_left.png") top left no-repeat;
- padding-left: 6px;
- display: block;
- height: 50px; */
-
-}
-
-#gmloader {
- background: url("/resources/loading.gif") center center no-repeat;
- position: absolute;
- height: 620px;
- width: 740px;
-}
-
-#loading_info {
- position: relative;
- top: 350px;
-}
-
-.game {
- background: url("/resources/game_bg.png") top left no-repeat;
- margin: 5px auto;
- width: 990px;
- height: 645px;
- border-color: #333333;
- border-radius: 0.3em 0.3em 0.3em 0.3em;
- border-style: solid;
- border-width: 2px;
- box-shadow: 0 0 5px black, 0 25px 5px rgba(255, 255, 255, 0.1) inset;
-}
-
-.game .canvas {
- margin: 10px;
- float: left;
-}
-
-.game #gameinfo{
- width: 230px;
- height: 100%;
- float: right;
-}
-
-.game #players {
- margin-left: 8px;
- width: 210px;
- height: 100px;
-}
-
-.game #tb_players td {
- max-width: 160px;
- overflow: hidden;
- height: 23px;
- text-align: left;
-}
-
-.game #tb_players .self_row {
- border: 1px;
- background-color: red;
- font-size: 14px;
-}
-
-.game .chat{
- height: 410px
-}
-
-#chat_messages {
- clear: both;
- border: 0px;
- height: 360px;
- width: 207px;
- margin: 20px 0px 8px 10px;
- color: #ffebc7;
- overflow-y: scroll;
- text-shadow: black 1px 1px 1px;
-}
-
-#chat_messages li {
- list-style: none;
- word-wrap: break-word;
- text-align: left;
- margin: 3px 0px;
- font-size: 13px;
-}
-
-#chat_messages .author {
- clear: both;
- float: left;
- font-size: 12px;
- font-weight: bold;
- margin-right: 5px;
-}
-
-
-.game .chat .input {
- width: 93%;
- height: 40px;
- margin: 0 5px;
-}
-
-.game .chat #entry {
- float: left;
- width: 150px;
-}
-
-.game .chat #post {
- float: right;
-}
-
-#panel {
- height: 40px;
- margin-top: 3px;
- text-align: left;
-}
-
-#scores {
- height: 68px;
- padding: 5px 10px;
-}
-
-.score_left {
- float: left;
- max-width: 105px;
- overflow: hidden;
- height: 35px;
-}
-
-.score_middle {
- float: left;
- padding-left: 3px;
- padding-top: 14px;
-}
-
-.score_right {
- float: right;
- margin-right: 3px;
-}
View
1  src/bot.opa
@@ -72,6 +72,7 @@ server module Bot {
* 从手牌中选择一张弃掉
**/
function play(game,idx){
+ Log.debug("Bot","gameid = {game.id}, game.status = {game.status}");
deck = LowLevelArray.get(game.board.decks,idx);
//如果能胡,胡之
if(Board.can_hoo_self(deck)) Mahjong.request_action(game.id,idx,{hoo}) else {
View
310 src/game.opa
@@ -152,7 +152,7 @@ module Game {
Scheduler.timer(2000,function(){
timestamp = Date.in_milliseconds(Date.now());
Map.iter(function(_,game){
- if(timestamp - game.last_act >= 12000){
+ if(game.last_act != 0 && timestamp - game.last_act >= 12000){
match(game.status){
case {select_action}: Mahjong.default_action(game);
case {wait_for_resp}: Mahjong.do_action(game);
@@ -379,32 +379,46 @@ module Game {
}
}
}
+
+ // 获得鼠标点击事件在画布上的坐标
+ client function get_pos(event){
+ canvas_pos = Dom.get_position(#container);
+ mouse_pos = event.mouse_position_on_page;
+ s = Render.g_scale.get();
+ x = Float.to_int(Float.of_int(mouse_pos.x_px - canvas_pos.x_px) / s);
+ y = Float.to_int(Float.of_int(mouse_pos.y_px - canvas_pos.y_px) / s);
+ if(Render.g_rotate.get()){
+ x = x + 300; y = y + 400;
+ {x:y, y: Render.SRN_HEIGHT - x}
+ }else{
+ x = x + 400; y = y + 300;
+ ~{x,y}
+ }
+ }
/**
* 处理鼠标点击的事件
*/
- client function process(event){
- game = get_game();
- if(game.status == {prepare} || game.status == {wait_for_resp}
- || game.status == {show_result} || game.curr_turn == game.idx){
- // 获得鼠标点击事件在画布上的坐标
- canvas_pos = Dom.get_position(#gmcanvas);
- mouse_pos = event.mouse_position_on_page;
- x = mouse_pos.x_px - canvas_pos.x_px;
- y = mouse_pos.y_px - canvas_pos.y_px;
- x = x * 2;
- y = y * 2;
- pos = ~{x,y}
- action = Mahjong.get_action(pos,game);
- match(action){
- case {none}: void
- default: {
- Render.refresh();
- Mahjong.request_action(game.id,game.idx,action);
+ client function mouse_down(event){
+ pos = get_pos(event);
+ if(Button.is_pressed(pos,Render.btn_exit)){
+ //退出游戏
+ Client.goto("/hall");
+ }else{
+ game = get_game();
+ if(game.status == {prepare} || game.status == {wait_for_resp}
+ || game.status == {show_result} || game.curr_turn == game.idx){
+ action = Mahjong.get_action(pos,game);
+ match(action){
+ case {none}: void
+ default: {
+ Render.refresh();
+ Mahjong.request_action(game.id,game.idx,action);
+ }
}
}
- }
- }
+ }
+ }
/**
* 收到游戏消息后的处理函数
@@ -430,12 +444,10 @@ module Game {
case {GAME_RESTART: game_msg}:{
Render.update(game_msg);
Render.refresh();
- refresh_players(game_msg.pls);
}
case {PLAYER_CHANGE: game_msg}:{
Render.update(game_msg);
Render.refresh();
- refresh_players(game_msg.pls);
}
case {DISCARD_CARD: msg}:{ //玩家弃牌消息
play_sound("da.wav");
@@ -485,16 +497,15 @@ module Game {
case {none}: {
set_game(game);
Render.refresh();
- Render.show_draw_play(game,195,75);
+ Render.show_draw_play(game,225,75);
}
case ~{some}: {
players = Mahjong.update_scores(game.players,some);
set_game({game with ~players});
- refresh_players(players);
play_sound("countfan.wav");
Render.refresh();
- Render.show_result(game,some,195,75);
+ Render.show_result(game,some,225,75);
}
}
}
@@ -512,7 +523,6 @@ module Game {
});
set_game({game with ~players});
Render.refresh();
- refresh_players(players);
}
case {PLAYER_READY: ready_flags}:{
game = {get_game() with ~ready_flags};
@@ -532,53 +542,6 @@ module Game {
Dom.scroll_to_bottom(#chat_messages)
}
- client function game_ready(game,player){
- //加载资源
- imgs = ["table_bg.png","board.png","result.png","arrow.png","win.png","menu_bar.png","ting.png","dialog.png",
- "tiles.png","tiles_small.png","numbers.png","start.png","offline.png","player_frame_h.png","player_frame_v.png",
- "portrait.jpg","eswn.png","btn_tutor.png"];
- auds = ["start.wav","da.wav","pung.wav","countfan.wav","win.wav"];
- preload(imgs,auds,function(){
- Dom.set_value(#loading_info,"prepare game...");
- game_obs = Network.observe(game_msg_received,game.game_channel);
- chat_obs = Network.observe(user_update,game.chat_channel);
-
- ck_player = get_cookie("player");
- ck_coins = get_cookie("coins");
- coins = if(ck_player != player.name || String.is_empty(ck_coins)) DEFAULT_COINS else string_to_int(ck_coins);
- player = {player with coins: coins};
-
- game = update_player(game,player);
- set_game(game_obj(game,player));
- refresh_players(game.players);
-
- //离开页面的提示(对Opera无效)
- Dom.bind_beforeunload_confirmation(function(_){
- {some: "Are you sure to quit?"}
- });
- Dom.bind_unload_confirmation(function(_){
- Mahjong.quit(game.id,player.idx);
- Network.unobserve(game_obs);
- Network.unobserve(chat_obs);
- {none}
- });
-
- //广播游戏信息
- Network.broadcast({PLAYER_CHANGE: game_msg(game)},game.game_channel);
-
- //去掉#gamecanvas的loading样式
- Render.refresh();
- Dom.remove(#gmloader);
- });
-
- if(AUTO_READY || player.is_bot) Mahjong.set_ready(game,player.idx);
-
- //缩放Canvas到合适比例
- canvas = Canvas.get(#gmcanvas);
- ctx = Option.get(Canvas.get_context_2d(Option.get(canvas)));
- Canvas.scale(ctx,0.5,0.5);
- }
-
/**
* 获得空的座位
*/
@@ -628,77 +591,114 @@ module Game {
}}
},game.players,{none});
}
+
+ client function load_page(game,idx){
+ lang = I18n.lang();
+ if(String.has_prefix(lang,"zh") || String.has_prefix(lang,"jp")
+ || String.has_prefix(lang,"tw") || String.has_prefix(lang,"hk")){
+ Render.g_zh.set({true})
+ }else Render.g_zh.set({false})
+
+ //加载资源
+ imgs = ["actions.png","table_bg.png","board.png","result.png","arrow.png","win.png","en_menu_bar.png","cn_menu_bar.png",
+ "ting.png","dialog.png","tiles.png","tiles_small.png","numbers.png","start.png","offline.png","player_frame_h.png",
+ "player_frame_v.png","portrait.jpg","eswn.png","btn_tutor.png","exit.png","setting.png"];
+ auds = ["start.wav","da.wav","pung.wav","countfan.wav","win.wav"];
+
+ player = Option.get(LowLevelArray.get(game.players,idx));
+ preload(imgs,auds,function(){
+ Dom.set_value(#loading_info,"prepare game...");
+ game_obs = Network.observe(game_msg_received,game.game_channel);
+ chat_obs = Network.observe(user_update,game.chat_channel);
+
+ ck_player = get_cookie("player");
+ ck_coins = get_cookie("coins");
+ coins = if(ck_player != player.name || String.is_empty(ck_coins)) DEFAULT_COINS else string_to_int(ck_coins);
+ player = {player with coins: coins};
+
+ game = update_player(game,player);
+ set_game(game_obj(game,player));
+
+ //离开页面的提示(对Opera无效)
+ Dom.bind_beforeunload_confirmation(function(_){
+ {some: "Are you sure to quit?"}
+ });
+ Dom.bind_unload_confirmation(function(_){
+ Mahjong.quit(game.id,player.idx);
+ Network.unobserve(game_obs);
+ Network.unobserve(chat_obs);
+ {none}
+ });
+
+ //广播游戏信息
+ Network.broadcast({PLAYER_CHANGE: game_msg(game)},game.game_channel);
+
+ if(Render.g_zh.get()) Render.g_show_classic_tile.set({true});
+
+ //去掉#gamecanvas的loading样式
+ Render.adjust();
+ Render.refresh();
+ Dom.remove(#gmloader);
+ });
+
+ if(AUTO_READY || player.is_bot) Mahjong.set_ready(game,player.idx);
+ }
+
+ function game_ready(game,idx){
+ load_page(game,idx);
+
+ _ = ClientEvent.set_on_disconnect_client(function(ctx){
+ //如果ctx和game的第idx个client一致,说明这个玩家处于死链接状态,去除之。
+ with_game(game.id,function(game){
+ match(LowLevelArray.get(game.clients,idx)){
+ case {none}: void
+ case {some:c}:{
+ if(c.client == ctx.client && c.page == ctx.page){
+ Mahjong.quit(game.id,idx);
+ }
+ }
+ }
+ });
+ });
+
+ void;
+ }
/**
* 游戏视图
*/
function game_view(game,idx){
- //更新第idx个玩家的client_ctx
- player = Option.get(LowLevelArray.get(game.players,idx));
- Resource.styled_page("Mahjong",["/resources/style.css"],
+ player = Option.get(LowLevelArray.get(game.players,idx));
+ Resource.full_page("Mahjong",
<>
- <div class="game" onready={function(_){
- _ = ClientEvent.set_on_disconnect_client(function(ctx){
- //如果ctx和game的第idx个client一致,说明这个玩家处于死链接状态,去除之。
- with_game(game.id,function(game){
- match(LowLevelArray.get(game.clients,idx)){
- case {none}: void
- case {some:c}:{
- if(c.client == ctx.client && c.page == ctx.page){
- Mahjong.quit(game.id,idx);
- }
- }
- }
- });
- });
- game_ready(game,player);
- }}>
- <div class="canvas">
+ <div class="game" onready={function(_){game_ready(game,idx)}}>
+ <div id=#container>
<div id=#gmloader >
<p id=#loading_info>loading</p>
</div>
- <canvas id=#gmcanvas width="740" height="625"
- onmousedown={function(event){ process(event) }}>
+ <canvas id=#gmcanvas width="800" height="600"
+ onmousedown={function(event){mouse_down(event)}}>
"Your browser does not support html5 canvas element."
</canvas>
</div>
- <div id=#gameinfo>
- <div id=#panel>
- <div style="float:left;text-align:left;width:45%">
- <div>
- <input type="checkbox" style="margin:0px" onclick={function(_){Render.show_or_hide_number()}}/>
- <span>show number</span>
- </div>
- <div>
- <input type="checkbox" style="margin:0px" onclick={function(_){Render.change_tile_style()}}/>
- <span>classic tile</span>
- </div>
- </div>
- <div style="float:right;margin:4px">
- <input type="button" class="btn btn-info" value="Back" onclick={function(_){ Client.goto("/hall")} }/>
- </div>
- </div>
- <div id=#scores>
- <div class="score_left"><h2>{player.name}</h2></div>
- <div class="score_middle">[{Board.idx_to_place(player.idx)}]</div>
- <div class="score_right"><h2 id=#txt_score>{player.coins}</h2></div>
- </div>
- <div id=#players>
- <table id=#tb_players></table>
- </div>
- <div class="chat">
- <ul id="chat_messages"></ul>
- <div class="input">
- <input type="text" id=#entry class="input-large"
- onnewline={function(_){post_chat_msg(player.name,game.chat_channel)}} placeholder="Your Message Here"/>
- <input id=#post type="button" class="btn btn-primary" value="post"
- onclick={function(_){post_chat_msg(player.name,game.chat_channel)}}/>
- </div>
+ <div id="chat">
+ <div id="chat_title">Chat</div>
+ <div id="chat_box">
+ <ul id=#chat_messages></ul>
+ <input id=#entry type="text" class="chat_textbox"
+ onnewline={function(_){post_chat_msg(player.name,game.chat_channel)}}></input>
</div>
</div>
- </div>
- </>
- );
+ </div>
+ </>,
+ <>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
+ <link rel="stylesheet" type="text/css" href="/resources/css/game.css" media="only screen and (min-width:800px)">
+ <link rel="stylesheet" type="text/css" href="/resources/css/game_small.css"
+ media="only screen and (min-width:240px) and (max-width:800px)">
+ </>,
+ {success},[]
+ );
}
@async function post_chat_msg(author,channel){
@@ -709,35 +709,6 @@ module Game {
}
}
- client function refresh_players(players){
- Dom.remove_content(#tb_players);
- LowLevelArray.iteri(function(i,player){
- match(player){
- case {none}: void
- case ~{some}: {
- self_idx = get_game().idx;
- table_row = if(self_idx == i) {
- //更新得分
- set_cookie("player",some.name);
- set_cookie("coins",int_to_string(some.coins));
- #txt_player = "{some.name}"
- #txt_score = "{some.coins}";
- <tr class="self_row">
- <td width="160px"> {some.name} </td>
- <td width="80px"> {some.coins} </td>
- </tr>
- }else {
- <tr>
- <td width="160px"> {some.name} </td>
- <td width="80px"> {some.coins} </td>
- </tr>
- }
- #tb_players =+ table_row
- }
- }
- },players);
- }
-
/** 开始游戏 */
function start(game){
idx = mod(game.dealer / 10000,4);
@@ -787,6 +758,25 @@ module Game {
ok_flags:0, change_flag:{true}} |> Mahjong.reset_actions(_);
}
+ function reset(game){
+ {game with
+ status: {prepare},
+ winners: [],
+ curr_turn: 0,
+ last_act: 0,
+ ready_flags: 0,
+ ok_flags: 0,
+ round: 1,
+ dealer: 1,
+ change_flag: {false},
+ curr_card: {none},
+ players: LowLevelArray.create(4,{none}),
+ clients: LowLevelArray.create(4,{none}),
+ actions: LowLevelArray.create(4,{none}),
+ board: Board.create()
+ }
+ }
+
/** 获取某个玩家的deck */
exposed function get_player_deck(game_id,player){
match(get(game_id)){
View
56 src/login.opa
@@ -60,12 +60,6 @@ function is_logged_in(){
}
}
-A = function(user_compat){
- "U"
-}
-
-
-
module Login {
function get_agent(user_compat){
@@ -107,50 +101,21 @@ module Login {
if(not(String.is_empty(login_name))){
Dom.set_value(#username,login_name);
}
- jlog("width = {Client.width()}, height = {Client.height()}");
}
function login_view(){
- /** r = Resource.styled_page("China Mahjong", ["/resources/main.css"],
- <>
- <div id="container" onready={function(_){page_ready()}}>
- <div id="content">
- <div id=#login_box>
- <h1> Login </h1>
- <input id=#username type="text" class="input-xlarge" placeholder="Enter a nickname"
- onnewline={function(_){attempt_login()}}/>
- <button class="btn btn-primary btn-large" style="margin-top:10px" onclick={function(_){attempt_login()}}>Play</button>
- <hr style="margin-bottom:5px">
- <p>Note: This game need HTML5 canvas support, please use IE9+, Firefox4+, Chrome10+, Opera11+, Safari5+</p>
- <div style="padding:0px 5px">
- <button class="btn btn-info" style="float:left;width:60px;"
- onclick={function(_){Tutor.show_tutor()}}>Tutorial</button>
- <button class="btn btn-info" style="width:120px">Add to Chrome</button>
- <a class="btn btn-info" style="float:right;width:105px;"
- href="https://github.com/winbomb/mahjong" target="_blank">Fork on Github</a>
- </div>
- </div>
- </div>
- <div id="footer">
- <p>Build with <a target="_blank" href="http://www.opalang.org">Opa</a></p>
- <p>Any Feedback, please mail to: <a href="mailto:li.wenbo@whu.edu.cn">li.wenbo@whu.edu.cn</a></p>
- </div>
- </div>
- </>
- ); */
-
Resource.full_page("China Mahjong",
<>
<div id="container" onready={function(_){page_ready()}}>
<div id="content">
<div id=#login_box>
<h1> Login </h1>
- <input id=#username type="text" class="input-xlarge" placeholder="Enter a nickname"
+ <input id=#username type="text" class="input-xlarge txt_user" placeholder="Enter a nickname"
onnewline={function(_){attempt_login()}}/>
- <button class="btn btn-primary btn-large" style="margin-top:10px" onclick={function(_){attempt_login()}}>Play</button>
+ <button class="btn btn-primary btn-large btn_play" onclick={function(_){attempt_login()}}>Play</button>
<hr style="margin-bottom:5px">
<p>Note: This game need HTML5 canvas support, please use IE9+, Firefox4+, Chrome10+, Opera11+, Safari5+</p>
- <div style="padding:0px 5px">
+ <div id=#btn_group style="padding:0px 5px">
<button class="btn btn-info" style="float:left;width:60px;"
onclick={function(_){Tutor.show_tutor()}}>Tutorial</button>
<button class="btn btn-info" style="width:120px">Add to Chrome</button>
@@ -158,16 +123,19 @@ module Login {
href="https://github.com/winbomb/mahjong" target="_blank">Fork on Github</a>
</div>
</div>
- </div>
- <div id="footer">
- <p>Build with <a target="_blank" href="http://www.opalang.org">Opa</a></p>
- <p>Any Feedback, please mail to: <a href="mailto:li.wenbo@whu.edu.cn">li.wenbo@whu.edu.cn</a></p>
- </div>
+ </div>
+ </div>
+ <div id="footer">
+ <p>Build with <a target="_blank" href="http://www.opalang.org">Opa</a></p>
+ <p>Any Feedback, please mail to: <a href="mailto:li.wenbo@whu.edu.cn">li.wenbo@whu.edu.cn</a></p>
</div>
</>,
<>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
- <link rel="stylesheet" type="text/css" href="/resources/main.css">
+ <link rel="stylesheet" type="text/css" href="/resources/css/main_small.css"
+ media="only screen and (min-width:240px) and (max-width:800px)">
+ <link rel="stylesheet" type="text/css" href="/resources/css/main.css" media="only screen and (min-width:800px)">
+ <link rel="apple-touch-icon" sizes="72x72" href="/resources/mahjong-48.png" />
</>,
{success},[]
);
View
67 src/mahjong.opa
@@ -192,14 +192,14 @@ module Mahjong {
client function get_clicked_card(deck,pos){
done = List.length(deck.donecards);
hand = List.length(deck.handcards);
- start_x = 28 + 140*done;
- b_bound = Button.bound(pos,start_x,545,45*hand+30,70);
+ start_x = 5 + 165*done;
+ b_bound = Button.bound(pos,start_x,505,55*hand+20,90);
if(not(b_bound)) {none} else{
- if((pos.x >= start_x + (hand - 1)*45 + 30) && (pos.x <= start_x + hand*45 + 30)){
+ if((pos.x >= start_x + (hand - 1)*55 + 20) && (pos.x <= start_x + hand*55 + 20)){
List.get(hand-1,deck.handcards)
}else{
- n = (pos.x - start_x) / 45;
+ n = (pos.x - start_x) / 55;
List.get(n,deck.handcards);
}
}
@@ -212,7 +212,7 @@ module Mahjong {
deck = LowLevelArray.get(game.board.decks,idx);
card_cnt = List.length(deck.handcards) + List.length(deck.donecards)*3
if(card_cnt <= 13){
- Log.warning("Mahjong","Try to discard card, but only has 13 cards.");
+ Log.warning("Mahjong","GameId = {game.id}, idx = {idx}. Try to discard card, but only has 13 cards.");
}else{
game = {game with board: Board.discard(game.board,idx,card),
status:{wait_for_resp},
@@ -405,6 +405,7 @@ module Mahjong {
default: {client:"",page:0}
}
+ Log.debug("Mahjong","QUIT: gameid = {game_id}, idx = {idx}");
if(ctx.client == clnt.client && ctx.page == clnt.page){
ready_flags = clear_flag(game.ready_flags,idx);
game = {game with ~ready_flags, change_flag:{true}}
@@ -416,8 +417,8 @@ module Mahjong {
//如果游戏的player都离开了,则结束游戏。
if(Game.get_online_cnt(game.players) == 0){
- game = {game with ready_flags:0,players: LowLevelArray.create(4,{none})}; //清空玩家
- restart(game);
+ game = Game.reset(game) |> update(_);
+ Network.broadcast({GAME_RESTART: Game.game_msg(game)},game.game_channel)
}
} else {
players = LowLevelArray.mapi(game.players)(function(i,p){
@@ -432,12 +433,10 @@ module Mahjong {
//如果游戏的player都离开了,则结束游戏。
if(Game.get_online_cnt(game.players) == 0){
- game = {game with ready_flags:0,players: LowLevelArray.create(4,{none})}; //清空玩家
- restart(game);
+ game = Game.reset(game) |> update(_);
+ Network.broadcast({GAME_RESTART: Game.game_msg(game)},game.game_channel)
}
}
- }else{
- jlog("QUIT Canceled.");
}
});
}
@@ -622,29 +621,35 @@ module Mahjong {
/** 下一个玩家 */
function next_turn(game_id){
with_game(game_id,function(game){
- //如果已经没有牌了,游戏结束,流局
- if(List.length(game.board.card_pile) == 0) draw_play(game) else {
- //将当前牌加入到弃牌堆
- board = match(game.curr_card){
- case {none}: game.board
- case {some:card}: Board.add_to_discards(game.board,game.curr_turn,card)
- }
+ //第一个判断online人数是因为玩家quit游戏之后,可能还有定时器的next_turn没有执行
+ //如果不做判断,很可能这个next_turn将会改变原来game变量的值。
+ if(Game.get_online_cnt(game.players) == 0) void else {
+ //如果已经没有牌了,游戏结束,流局
+ if(List.length(game.board.card_pile) == 0) draw_play(game) else {
+ //将当前牌加入到弃牌堆
+ board = match(game.curr_card){
+ case {none}: game.board
+ case {some:card}: Board.add_to_discards(game.board,game.curr_turn,card)
+ }
- //更新游戏状态
- game = {game with ~board, status:{select_action}, curr_turn: Board.get_next_idx(game.curr_turn)}
- game = {game with board: Board.deal_card(game.board,game.curr_turn), curr_card: {none}} |> update(_);
+ //更新游戏状态
+ game = {game with ~board, status:{select_action}, curr_turn: Board.get_next_idx(game.curr_turn)}
+ game = {game with board: Board.deal_card(game.board,game.curr_turn), curr_card: {none}} |> update(_);
- //广播游戏消息
- Network.broadcast({NEXT_TURN: Game.game_msg(game)},game.game_channel);
+ //广播游戏消息
+ Network.broadcast({NEXT_TURN: Game.game_msg(game)},game.game_channel);
- //如果当前玩家为状态不为{online},则1s钟之后自动弃牌
- match(LowLevelArray.get(game.players,game.curr_turn)){
- case {none}: Scheduler.sleep(1000,function(){ default_action(game)});
- case {some:player}:{
- if(player.is_bot == {false} && player.status != {online}) {
- Scheduler.sleep(1000,function(){ default_action(game)});
- }else{
- if(player.is_bot) Scheduler.sleep(1000,function(){Bot.play(game,game.curr_turn)});
+ //如果当前玩家为状态不为{online},则1s钟之后自动弃牌
+ match(LowLevelArray.get(game.players,game.curr_turn)){
+ case {none}: Scheduler.sleep(1000,function(){
+ default_action(game)
+ });
+ case {some:player}:{
+ if(player.is_bot == {false} && player.status != {online}) {
+ Scheduler.sleep(1000,function(){ default_action(game)});
+ }else{
+ if(player.is_bot) Scheduler.sleep(1000,function(){Bot.play(game,game.curr_turn)});
+ }
}
}
}
View
11 src/page.opa
@@ -94,7 +94,7 @@ module Page {
}
function game_list_view(){
- Resource.styled_page("Welcome to play China Mahjong",["/resources/page.css"],
+ Resource.full_page("China Mahjong",
<>
<div class="dragon_bg"></div>
<div id="game_list" onready={function(_){ page_ready()}} >
@@ -135,7 +135,14 @@ module Page {
</table>
</div>
</div>
- </>
+ </>,
+ <>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
+ <link rel="stylesheet" type="text/css" href="/resources/css/page.css" media="only screen and (min-width:800px)">
+ <link rel="stylesheet" type="text/css" href="/resources/css/page_small.css"
+ media="only screen and (min-width:240px) and (max-width:800px)">
+ </>,
+ {success},[]
);
}
}
View
284 src/render.opa
@@ -55,9 +55,6 @@ get_game = %%engine2d.get_game%%;
PREFIX = "/resources/"
-SCR_WD = 740; //游戏屏幕的宽度(原始比例)
-SCR_HT = 625; //游戏屏幕的高度(原始比例)
-
client function get_ctx(id){
canvas = Canvas.get(id);
Option.get(Canvas.get_context_2d(Option.get(canvas)));
@@ -99,13 +96,22 @@ client module Render {
//等待时间
WAIT_TIME = 10
- Button.t btn_peng = Button.simple(490,475,60,60,"碰"); //碰
- Button.t btn_gang = Button.simple(550,475,60,60,"杠"); //杠
- Button.t btn_hoo = Button.simple(610,475,60,60,"胡"); //胡
- Button.t btn_cancel = Button.simple(670,475,60,60,"放弃"); //放弃
- Button.t btn_ready = Button.simple(330,555,150,57,"准备"); //准备
- Button.t btn_hide_result = Button.simple(333,423,75,45,"确定"); //关闭结算
- Button.t btn_tutor = Button.simple(600,555,100,100,"指导"); //关闭结算
+ Button.t btn_peng = Button.simple(550,435,60,60,"碰"); //碰
+ Button.t btn_gang = Button.simple(610,435,60,60,"杠"); //杠
+ Button.t btn_hoo = Button.simple(670,435,60,60,"胡"); //胡
+ Button.t btn_cancel = Button.simple(730,435,60,60,"放弃"); //放弃
+ Button.t btn_ready = Button.simple(330,510,150,57,"准备"); //准备
+ Button.t btn_hide_result = Button.simple(363,423,75,45,"确定"); //关闭结算
+ Button.t btn_tutor = Button.simple(680,555,100,100,"指导"); //关闭结算
+ Button.t btn_exit = Button.simple(765,2,32,32,"退出"); //退出游戏
+
+ SRN_WIDTH = 800; //游戏屏幕的宽度(原始比例)
+ SRN_HEIGHT = 600; //游戏屏幕的高度(原始比例)
+
+ // 缩放比例 ( <= 1.0)
+ g_scale = Mutable.make(float 1.0);
+ g_rotate= Mutable.make(bool {false});
+ g_zh = Mutable.make(bool {false});
/** 是否在麻将牌上显示数字 */
g_show_number = Mutable.make(bool {false});
@@ -120,11 +126,12 @@ client module Render {
g_show_classic_tile.set(not(g_show_classic_tile.get()));
refresh();
}
-
start_timer = %%engine2d.start_timer%%
stop_timer = %%engine2d.stop_timer%%
- show_menu = %%engine2d.show_menu%%
+ function show_menu(flag){
+ %%engine2d.show_menu%%(flag,g_zh.get());
+ }
/** 获取card所对应的图案在png文件中的坐标 */
function get_x(card){ (card.point - 1) * 40}
@@ -136,6 +143,8 @@ client module Render {
}
}
+
+
function get_dealer(game){
//绘制当前局数和庄家
if(game.dealer >= 0 && game.dealer <= 9999) "EAST" else{
@@ -148,6 +157,47 @@ client module Render {
}
}
}
+
+ /** 调整页面的展示 */
+ function adjust(){
+ //缩放Canvas到合适比例
+ width = Client.width(); height = Client.height();
+ if(width >= SRN_WIDTH && height >= SRN_HEIGHT) void else{
+ if(width <= height){
+ g_scale.set(Float.of_int(width) / Float.of_int(SRN_HEIGHT));
+ g_rotate.set({true});
+
+ ctx = get_ctx(#gmcanvas);
+ Canvas.translate(ctx, SRN_WIDTH, 0);
+ Canvas.rotate(ctx, Math.PI / 2.0);
+ x_scale = Float.of_int(SRN_HEIGHT) / Float.of_int(SRN_WIDTH);
+ Canvas.scale(ctx,x_scale,1.0/x_scale);
+
+ h2 = Float.to_int(Float.of_int(SRN_WIDTH) * g_scale.get());
+ Dom.set_width(#gmcanvas,width);
+ Dom.set_height(#gmcanvas,h2);
+ Dom.set_width(#container,width);
+ Dom.set_height(#container,h2);
+ Dom.set_style(#container,[{margin: {t:some({px:0-h2/2}),l:some({px:0-width/2}),b:{none},r:{none}}}]);
+
+ }else{
+ scale_x = Float.of_int(width) / Float.of_int(SRN_WIDTH);
+ scale_y = Float.of_int(height) / Float.of_int(SRN_HEIGHT);
+ scale = if(scale_x <= scale_y) scale_x else scale_y;
+
+ w2 = Float.to_int(Float.of_int(SRN_WIDTH)*scale)
+ h2 = Float.to_int(Float.of_int(SRN_HEIGHT)*scale)
+ Dom.set_width(#gmcanvas, w2);
+ Dom.set_height(#gmcanvas,h2);
+ Dom.set_width(#container,w2);
+ Dom.set_height(#container,h2);
+ Dom.set_style(#container,[{margin: {t:some({px:0-h2/2}),l:some({px:0-w2/2}),b:{none},r:{none}}}]);
+
+ g_scale.set(scale);
+ g_rotate.set({false});
+ }
+ }
+ }
function refresh(){
ctx = get_ctx(#gmcanvas);
@@ -162,8 +212,8 @@ client module Render {
if(game.status == {prepare} || ( game.status == {show_result} && game.is_ok)){
draw_prepare(ctx,game,game.idx); //绘制牌堆
if(not(test_flag(game.ready_flags,game.idx))){
- Canvas.draw_image(ctx,get("start.png"),330,555); //绘制“准备”按钮
- Canvas.draw_image(ctx,get("btn_tutor.png"),620,510); //绘制“指导”按钮
+ Canvas.draw_image(ctx,get("start.png"),330,510); //绘制“准备”按钮
+ Canvas.draw_image(ctx,get("btn_tutor.png"),680,475); //绘制“指导”按钮
}
}else{
draw_discards(ctx,game.discards,game.idx); //绘制玩家弃牌
@@ -175,14 +225,18 @@ client module Render {
Canvas.set_fill_style(ctx,BLUE);
Canvas.set_font(ctx,"normal bold 18px serif");
- Canvas.fill_text(ctx,"ROUND {game.round} {get_dealer(game)}",5,25);
+ Canvas.fill_text(ctx,"ROUND {game.round}",10,25);
+ Canvas.fill_text(ctx,"{get_dealer(game)} x {mod(game.dealer,10000)}",10,50);
+
+ //绘制关闭按钮和设置按钮
+ Canvas.draw_image(ctx,get("exit.png"),760,2);
//绘制调试信息
if(DEBUG) show_game_info(ctx,game);
}
function clear_bg(ctx,game){
- Canvas.clear_rect(ctx,0,0,740,625);
+ Canvas.clear_rect(ctx,0,0,SRN_WIDTH,SRN_HEIGHT);
if(Game.in_process(game)) draw_left_time(ctx,0);
}
@@ -207,7 +261,7 @@ client module Render {
* 绘制玩家信息
*/
function draw_player_info(ctx,game){
- INFO_POS = [{x:110,y:498},{x:50,y:298},{x:680,y:25},{x:685,y:298}]
+ INFO_POS = [{x:110,y:455},{x:50,y:298},{x:700,y:35},{x:745,y:298}]
Canvas.save(ctx)
Canvas.set_fill_style(ctx,{color:Color.rgb(13,30,40)})
Canvas.set_font(ctx,"normal bold 14px serif");
@@ -223,8 +277,8 @@ client module Render {
case ~{some}:{
match(rel_pos){
case 3: {
- Canvas.draw_image(ctx,get("player_frame_v.png"),640,215);
- Canvas.draw_image(ctx,get("portrait.jpg"),659,227);
+ Canvas.draw_image(ctx,get("player_frame_v.png"),700,215);
+ Canvas.draw_image(ctx,get("portrait.jpg"),719,227);
Canvas.draw_image_full(ctx,get("eswn.png"),30*i,0,30,30,pos.x+10,pos.y+40,30,30);
if(is_dealer){
Canvas.draw_image_full(ctx,get("eswn.png"),120,0,30,30,pos.x-45,pos.y+40,30,30);
@@ -233,8 +287,8 @@ client module Render {
if(some.status != {online}) Canvas.draw_image(ctx,get("offline.png"),645,220)
}
case 2: {
- Canvas.draw_image(ctx,get("player_frame_h.png"),575,0);
- Canvas.draw_image(ctx,get("portrait.jpg"),587,10);
+ Canvas.draw_image(ctx,get("player_frame_h.png"),pos.x-105,pos.y-30);
+ Canvas.draw_image(ctx,get("portrait.jpg"),pos.x-93,pos.y-20);
Canvas.draw_image_full(ctx,get("eswn.png"),30*i,0,30,30,pos.x+20,pos.y+45,30,30);
if(is_dealer){
Canvas.draw_image_full(ctx,get("eswn.png"),120,0,30,30,pos.x-40,pos.y+45,30,30);
@@ -253,8 +307,8 @@ client module Render {
if(some.status != {online}) Canvas.draw_image(ctx,get("offline.png"),10,220)
}
default: {
- Canvas.draw_image(ctx,get("player_frame_h.png"),5,470);
- Canvas.draw_image(ctx,get("portrait.jpg"),17,480);
+ Canvas.draw_image(ctx,get("player_frame_h.png"),5,pos.y-25);
+ Canvas.draw_image(ctx,get("portrait.jpg"),17,pos.y-15);
Canvas.draw_image_full(ctx,get("eswn.png"),30*i,0,30,30,pos.x+55,pos.y+10,30,30);
if(is_dealer){
Canvas.draw_image_full(ctx,get("eswn.png"),120,0,30,30,pos.x+55,pos.y-25,30,30);
@@ -288,10 +342,10 @@ client module Render {
case ~{some}:{
rel_pos = Board.get_rel_pos(idx,some.idx)
match(rel_pos){
- case 1: ignore(for(0,function(n){ draw_wall(ctx,1,178,146+20*n,{true}); n+1; }, _ <= 13))
- case 2: ignore(for(0,function(n){ draw_wall(ctx,2,223+24*n, 71,{true}); n+1; }, _ <= 13))
- case 3: ignore(for(0,function(n){ draw_wall(ctx,3,585,147+20*n,{true}); n+1; }, _ <= 13))
- case _: ignore(for(0,function(n){ draw_wall(ctx,0,223+24*n,479,{true}); n+1; }, _ <= 13))
+ case 1: ignore(for(0,function(n){ draw_wall(ctx,1,158,130+20*n,{true}); n+1; }, _ <= 13))
+ case 2: ignore(for(0,function(n){ draw_wall(ctx,2,225+24*n, 71,{true}); n+1; }, _ <= 13))
+ case 3: ignore(for(0,function(n){ draw_wall(ctx,3,605,130+20*n,{true}); n+1; }, _ <= 13))
+ case _: ignore(for(0,function(n){ draw_wall(ctx,0,225+24*n,445,{true}); n+1; }, _ <= 13))
}
if(test_flag(game.ready_flags,some.idx)){
Canvas.set_font(ctx,"normal bold 24px serif");
@@ -404,17 +458,17 @@ client module Render {
match(rel_pos){
case 1: {
Canvas.rotate(ctx,Math.PI / 2.0)
- Canvas.draw_image(ctx,get("arrow.png"),237,-410);
+ Canvas.draw_image(ctx,get("arrow.png"),237,-440);
}
case 2: {
Canvas.rotate(ctx,Math.PI);
- Canvas.draw_image(ctx,get("arrow.png"),-330-80,-237-80);
+ Canvas.draw_image(ctx,get("arrow.png"),-360-80,-237-80);
}
case 3: {
Canvas.rotate(ctx,Math.PI / -2.0)
- Canvas.draw_image(ctx,get("arrow.png"),-237-80,330);
+ Canvas.draw_image(ctx,get("arrow.png"),-237-80,360);
}
- default: Canvas.draw_image(ctx,get("arrow.png"),330,237);
+ default: Canvas.draw_image(ctx,get("arrow.png"),360,237);
}
Canvas.restore(ctx);
@@ -430,11 +484,11 @@ client module Render {
}
case 2: {
draw_dialog(ctx,2);
- draw_card(ctx,some,348,72);
+ draw_card(ctx,some,368,87);
}
case 1: {
draw_dialog(ctx,1);
- draw_card(ctx,some,188,233);
+ draw_card(ctx,some,188,235);
}
default:{
draw_dialog(ctx,0);
@@ -458,34 +512,34 @@ client module Render {
match(rel_pos){
case 1:{
List.iteri(function(i,card){
- if(i <= 9) draw_down_card_left(ctx,card,199,161+i*22,{false}) else{
- draw_down_card_left(ctx,card,235,177+(i-10)*22,{false})
+ if(i <= 9) draw_down_card_left(ctx,card,230,161+i*22,{false}) else{
+ draw_down_card_left(ctx,card,265,177+(i-10)*22,{false})
}
},List.rev(discards));
}
case 2:{
List.iteri(function(i,card){
- if(i <= 9) draw_down_card_oppt(ctx,card,473-i*25,107,{false}) else{
- draw_down_card_oppt(ctx,card,443-(i-10)*25,137,{false})
+ if(i <= 9) draw_down_card_oppt(ctx,card,503-i*25,127,{false}) else{
+ draw_down_card_oppt(ctx,card,473-(i-10)*25,157,{false})
}
},List.rev(discards));
}
case 3:{
List.iteri(function(i,card){
match(i){
- case 0: draw_down_card_right(ctx,card,506,358,{false});
- case 10: draw_down_card_right(ctx,card,470,344,{false});
+ case 0: draw_down_card_right(ctx,card,536,358,{false});
+ case 10: draw_down_card_right(ctx,card,500,344,{false});
case x: {
- if(x <= 9) draw_down_card_right_half(ctx,card,506,358-i*22) else {
- draw_down_card_right_half(ctx,card,470,344-(i-10)*22);
+ if(x <= 9) draw_down_card_right_half(ctx,card,536,358-i*22) else {
+ draw_down_card_right_half(ctx,card,500,344-(i-10)*22);
}
}}
},List.rev(discards));
}
case _:{
List.iteri(function(i,card){
- if(i <= 9) draw_down_card_self(ctx,card,244+25*i,406) else{
- draw_down_card_self_half(ctx,card,270+25*(i-10),376)
+ if(i <= 9) draw_down_card_self(ctx,card,274+25*i,386) else{
+ draw_down_card_self_half(ctx,card,300+25*(i-10),356)
}
},List.rev(discards));
}}
@@ -508,7 +562,7 @@ client module Render {
List.iteri(function(i,pattern){
rel_pos = Board.get_rel_pos(game.idx,pattern.source);
rel_pos = mod(rel_pos + 3, 4)
- y = 85 + i*82
+ y = 65 + i*82
match(pattern.kind){
case {Soft_Gang}: draw_gang(ctx,1,pattern.cards,100,y,rel_pos, {false});
case {Hard_Gang}: draw_gang(ctx,1,pattern.cards,100,y,rel_pos, {true});
@@ -516,7 +570,7 @@ client module Render {
}
},deck.donecards);
- start_y = 85 + 82*List.length(deck.donecards);
+ start_y = 65 + 82*List.length(deck.donecards);
if(SHOW_TILE || game.status == {game_over} || game.status == {show_result}){
List.iteri(function(n,c){ draw_down_card_left(ctx,c,100,start_y+22*n,{false}); },deck.handcards);
}else{
@@ -525,6 +579,7 @@ client module Render {
}
case 2:{
//绘制成牌
+ TX = 598; TY = 25;
List.iteri(function(i,pattern){
rel_pos = Board.get_rel_pos(game.idx,pattern.source);
rel_pos = match(rel_pos){
@@ -532,41 +587,42 @@ client module Render {
case 2: 0
case x: x
}
- x = 567 - (i+1)*85
+ x = TX - (i+1)*85
match(pattern.kind){
- case {Soft_Gang}: draw_gang(ctx,2,pattern.cards,x,5,rel_pos,{false});
- case {Hard_Gang}: draw_gang(ctx,2,pattern.cards,x,5,rel_pos,{true});
- default: draw_peng(ctx,2,pattern.cards,x,12,rel_pos);
+ case {Soft_Gang}: draw_gang(ctx,2,pattern.cards,x,TY,rel_pos,{false});
+ case {Hard_Gang}: draw_gang(ctx,2,pattern.cards,x,TY,rel_pos,{true});
+ default: draw_peng(ctx,2,pattern.cards,x,TY+7,rel_pos);
}
},deck.donecards);
//绘制手牌
- start_x = 545 - 85*List.length(deck.donecards) - 25*card_cnt;
+ start_x = TX - 22 - 85*List.length(deck.donecards) - 25*card_cnt;
if(SHOW_TILE || game.status == {game_over} || game.status == {show_result}){
- List.iteri(function(n,c){ draw_down_card_oppt(ctx,c,start_x+25*n,5,{false}); },deck.handcards);
+ List.iteri(function(n,c){ draw_down_card_oppt(ctx,c,start_x+25*n,TY,{false}); },deck.handcards);
}else{
- ignore(for(0,function(n){ draw_covered(ctx,2,start_x+25*n,5); n+1;}, _ <= card_cnt-1))
+ ignore(for(0,function(n){ draw_covered(ctx,2,start_x+25*n,TY); n+1;}, _ <= card_cnt-1))
}
}
case 3:{
//绘制成牌
+ TX = 660; TY = 465;
List.iteri(function(i,pattern){
rel_pos = Board.get_rel_pos(game.idx,pattern.source);
rel_pos = 3 - rel_pos
- y = 465 - 82*(i+1)
+ y = TY - 82*(i+1)
match(pattern.kind){
- case {Soft_Gang}: draw_gang(ctx,3,pattern.cards,600,y,rel_pos,{false});
- case {Hard_Gang}: draw_gang(ctx,3,pattern.cards,600,y,rel_pos,{true});
- default: draw_peng(ctx,3,pattern.cards,600,y,rel_pos);
+ case {Soft_Gang}: draw_gang(ctx,3,pattern.cards,TX,y,rel_pos,{false});
+ case {Hard_Gang}: draw_gang(ctx,3,pattern.cards,TX,y,rel_pos,{true});
+ default: draw_peng(ctx,3,pattern.cards,TX,y,rel_pos);
}
},deck.donecards);
//绘制手牌
- start_y = 465 - 82*List.length(deck.donecards) - 22*(card_cnt+1)
+ start_y = TY - 82*List.length(deck.donecards) - 22*(card_cnt+1)
if(SHOW_TILE || game.status == {game_over} || game.status == {show_result}){
- List.iteri(function(n,c){ draw_down_card_right(ctx,c,600,start_y+22*n,{false}); },deck.handcards);
+ List.iteri(function(n,c){ draw_down_card_right(ctx,c,TX,start_y+22*n,{false}); },deck.handcards);
}else{
- ignore(for(0,function(n){ draw_covered(ctx,3,600,start_y+22*n); n+1;}, _ <= card_cnt-1))
+ ignore(for(0,function(n){ draw_covered(ctx,3,TX,start_y+22*n); n+1;}, _ <= card_cnt-1))
}
}
default: void
@@ -577,11 +633,10 @@ client module Render {
function draw_self_cards(ctx,game){
deck = game.deck;
//绘制成牌
- offset_x = 28 - List.length(deck.donecards)*5;
- y = 545
+ y = 507
List.iteri(function(i,pattern){
rel_pos = Board.get_rel_pos(game.idx,pattern.source);
- x = offset_x + i*140;
+ x = 5 + i*165;
match(pattern.kind){
case {Soft_Gang}: draw_gang(ctx,0,pattern.cards,x,y,rel_pos,{false})
case {Hard_Gang}: draw_gang(ctx,0,pattern.cards,x,y,rel_pos,{true})
@@ -590,17 +645,17 @@ client module Render {
},game.deck.donecards);
//再绘制手牌
- start_x = offset_x + List.length(deck.donecards) * 140;
+ start_x = List.length(deck.donecards) * 165 + 5;
card_cnt = List.length(deck.handcards) + List.length(deck.donecards)*3;
List.iteri(function(i,card){
x = if(i == List.length(deck.handcards) - 1 && card_cnt == 14
&& game.status == {select_action} && game.curr_turn == game.idx){
- start_x + 45*i + 30;
- }else{ start_x + 45*i}
+ start_x + 55*i + 20;
+ }else{ start_x + 55*i}
if(game.status != {game_over} && game.status != {show_result}) draw_card(ctx,card,x,y) else draw_down_card(ctx,card,x,y,{false});
},deck.handcards);
- if(game.is_ting) Canvas.draw_image(ctx,get("ting.png"),303,500);
+ if(game.is_ting) Canvas.draw_image(ctx,get("ting.png"),303,475);
}
/**
@@ -617,17 +672,17 @@ client module Render {
case "2": {
match(rel_pos){
case 1: draw_wall(ctx,rel_pos,164,130+20*i,{true});
- case 2: draw_wall(ctx,rel_pos,202+i*24,53 ,{true});
- case 3: draw_wall(ctx,rel_pos,548,130+20*i,{true});
- case _: draw_wall(ctx,rel_pos,202+i*24,445,{true});
+ case 2: draw_wall(ctx,rel_pos,232+i*24,73 ,{true});
+ case 3: draw_wall(ctx,rel_pos,608,130+20*i,{true});
+ case _: draw_wall(ctx,rel_pos,232+i*24,425,{true});
}
}
case "1": {
match(rel_pos){
case 1: draw_wall(ctx,rel_pos,164,136+20*i,{false});
- case 2: draw_wall(ctx,rel_pos,202+i*24,58 ,{false});
- case 3: draw_wall(ctx,rel_pos,548,136+20*i,{false});
- case _: draw_wall(ctx,rel_pos,202+i*24,450,{false});
+ case 2: draw_wall(ctx,rel_pos,232+i*24,78 ,{false});
+ case 3: draw_wall(ctx,rel_pos,608,136+20*i,{false});
+ case _: draw_wall(ctx,rel_pos,232+i*24,430,{false});
}
}
default: void
@@ -706,14 +761,14 @@ client module Render {
match(is_v){
case {true}:{
match(is_two){
- case {true}: Canvas.draw_image_full(ctx,get("board.png"),37,112,24,42,x,y,24,42); //竖直两个
- case {false}: Canvas.draw_image_full(ctx,get("board.png"),62,118,24,36,x,y,24,36); //竖直一个
+ case {true}: Canvas.draw_image_full(ctx,get("board.png"),37,162,24,42,x,y,24,42); //竖直两个
+ case {false}: Canvas.draw_image_full(ctx,get("board.png"),62,168,24,36,x,y,24,36); //竖直一个
}
}
case {false}:{
match(is_two){
- case {true}: Canvas.draw_image_full(ctx,get("board.png"),0,155,28,32,x,y,28,32); //水平两个
- case {false}: Canvas.draw_image_full(ctx,get("board.png"),29,155,28,26,x,y,28,26); //水平一个
+ case {true}: Canvas.draw_image_full(ctx,get("board.png"),0,205,28,32,x,y,28,32); //水平两个
+ case {false}: Canvas.draw_image_full(ctx,get("board.png"),29,205,28,26,x,y,28,26); //水平一个
}
}}
}
@@ -723,8 +778,8 @@ client module Render {
*/
function draw_card(ctx,card,x,y){
Canvas.save(ctx)
- Canvas.draw_image_full(ctx,get("board.png"),0,0,45,71,x,y,45,71)
- Canvas.draw_image_full(ctx,get("tiles.png"),get_x(card),get_y(card),40,50,x+2,y+20,40,50);
+ Canvas.draw_image_full(ctx,get("board.png"),0,0,55,84,x,y,55,84)
+ Canvas.draw_image_full(ctx,get("tiles.png"),get_x(card),get_y(card),40,50,x+5,y+28,40,50);
//在牌面上显示数字
if(g_show_number.get()){
@@ -736,9 +791,9 @@ client module Render {
//绘制蒙上的牌(玩家手牌,没胡的时候是看不见的)
function draw_covered(ctx,rel_pos,x,y){
match(rel_pos){
- case 1: Canvas.draw_image_full(ctx,get("board.png"),28,70,16,40,x,y,16,40);
- case 2: Canvas.draw_image_full(ctx,get("board.png"),62,74,27,37,x,y,27,37);
- case 3: Canvas.draw_image_full(ctx,get("board.png"),45,70,16,40,x,y,16,40);
+ case 1: Canvas.draw_image_full(ctx,get("board.png"),28,120,16,40,x,y,16,40);
+ case 2: Canvas.draw_image_full(ctx,get("board.png"),62,124,27,37,x,y,27,37);
+ case 3: Canvas.draw_image_full(ctx,get("board.png"),45,120,16,40,x,y,16,40);
default: void
}
}
@@ -756,9 +811,9 @@ client module Render {
/** 绘制自己手牌或成牌中放倒的牌 */
function draw_down_card(ctx,card,x,y,is_covered){
match(is_covered){
- case {true}: Canvas.draw_image_full(ctx,get("board.png"),95,0,45,68,x,y,45,68)
+ case {true}: Canvas.draw_image_full(ctx,get("board.png"),150,0,55,82,x,y,55,82)
case {false}: {
- Canvas.draw_image_full(ctx,get("board.png"),46,0,45,68,x,y,45,68)
+ Canvas.draw_image_full(ctx,get("board.png"),75,0,55,82,x,y,55,82)
Canvas.draw_image_full(ctx,get("tiles.png"),get_x(card),get_y(card),40,50,x+3,y+3,40,50);
}
}
@@ -766,22 +821,22 @@ client module Render {
/** 绘制自己弃牌放倒的牌 */
function draw_down_card_self(ctx,card,x,y){
- Canvas.draw_image_full(ctx,get("board.png"),0,71,27,40,x,y,27,40);
+ Canvas.draw_image_full(ctx,get("board.png"),0,121,27,40,x,y,27,40);
draw_card_img(ctx,card,x,y,0);
}
/** 绘制自己弃牌放倒的牌(一半) */
function draw_down_card_self_half(ctx,card,x,y){
- Canvas.draw_image_full(ctx,get("board.png"),0,71,27,30,x,y,27,30);
+ Canvas.draw_image_full(ctx,get("board.png"),0,121,27,30,x,y,27,30);
draw_card_img(ctx,card,x,y,0);
}
/** 绘制左侧放到的牌 */
function draw_down_card_left(ctx,card,x,y,is_covered){
match(is_covered){
- case {true}: Canvas.draw_image_full(ctx,get("board.png"),60,155,36,33,x,y,36,33);
+ case {true}: Canvas.draw_image_full(ctx,get("board.png"),60,205,36,33,x,y,36,33);
case {false}: {
- Canvas.draw_image_full(ctx,get("board.png"),0,112,36,33,x,y,36,33);
+ Canvas.draw_image_full(ctx,get("board.png"),0,162,36,33,x,y,36,33);
draw_card_img(ctx,card,x,y,1);
}
}
@@ -790,9 +845,9 @@ client module Render {
/** 绘制右边放到的牌 */
function draw_down_card_right(ctx,card,x,y,is_covered){
match(is_covered){
- case {true}: Canvas.draw_image_full(ctx,get("board.png"),60,155,36,33,x,y,36,33);
+ case {true}: Canvas.draw_image_full(ctx,get("board.png"),60,205,36,33,x,y,36,33);
case {false}: {
- Canvas.draw_image_full(ctx,get("board.png"),0,112,36,33,x,y,36,33);
+ Canvas.draw_image_full(ctx,get("board.png"),0,162,36,33,x,y,36,33);
draw_card_img(ctx,card,x,y,-1);
}
}
@@ -800,16 +855,16 @@ client module Render {
/** 绘制右边放到的牌(一半)*/
function draw_down_card_right_half(ctx,card,x,y){
- Canvas.draw_image_full(ctx,get("board.png"),0,112,36,22,x,y,36,22);
+ Canvas.draw_image_full(ctx,get("board.png"),0,162,36,22,x,y,36,22);
draw_card_img(ctx,card,x,y,-1);
}
/** 绘制对家放倒的牌 */
function draw_down_card_oppt(ctx,card,x,y,is_covered){
match(is_covered){
- case {true}: Canvas.draw_image_full(ctx,get("board.png"),62,118,24,36,x,y,24,36);
+ case {true}: Canvas.draw_image_full(ctx,get("board.png"),62,168,24,36,x,y,24,36);
case {false}: {
- Canvas.draw_image_full(ctx,get("board.png"),0,71,27,40,x,y,27,40);
+ Canvas.draw_image_full(ctx,get("board.png"),0,121,27,40,x,y,27,40);
draw_card_img(ctx,card,x,y,2);
}
}
@@ -854,15 +909,15 @@ client module Render {
function draw_dialog(ctx,rel_pos){
match(rel_pos){
case 3: {
- Canvas.translate(ctx,740,0);
+ Canvas.translate(ctx,SRN_WIDTH,0);
Canvas.scale(ctx,-1.0,1.0);
- Canvas.draw_image(ctx,get("dialog.png"),160,225);
- Canvas.translate(ctx,740,0);
+ Canvas.draw_image(ctx,get("dialog.png"),210,225);
+ Canvas.translate(ctx,SRN_WIDTH,0);
Canvas.scale(ctx,-1.0,1.0);
}
case 2: {
Canvas.rotate(ctx,Math.PI);
- Canvas.draw_image(ctx,get("dialog.png"),-420,-150);
+ Canvas.draw_image(ctx,get("dialog.png"),-450,-180);
Canvas.rotate(ctx,-Math.PI);
}
case 1: Canvas.draw_image(ctx,get("dialog.png"),160,225);
@@ -873,35 +928,26 @@ client module Render {
/** 绘制玩家的动作 */
function draw_act(rel_pos,act){
ctx = get_ctx(#gmcanvas)
- act_string = match(act){
- case {peng}: "PUNG"
- case {gang}: "KONG"
- case {gang_self}: "KONG"
- case {hoo}: "HOOO"
- default: "----"
+
+ x = match(act){
+ case {peng}: 0
+ case {gang}: 115
+ case {gang_self}: 115
+ case {hoo}: 230
+ default: 0
}
+ y = if(g_zh.get()) 0 else 120;
Canvas.save(ctx);
Canvas.set_fill_style(ctx,RED);
Canvas.set_text_align(ctx,{align_center});
Canvas.set_font(ctx,"normal bold 24px serif");
+ draw_dialog(ctx,rel_pos);
match(rel_pos){
- case 3: {
- draw_dialog(ctx,3);
- Canvas.fill_text(ctx,"{act_string}",530,275)
- }
- case 2: {
- draw_dialog(ctx,2);
- Canvas.fill_text(ctx,"{act_string}",370,120)
- }
- case 1: {
- draw_dialog(ctx,1);
- Canvas.fill_text(ctx,"{act_string}",210,275)
- }
- default: {
- draw_dialog(ctx,0);
- Canvas.fill_text(ctx,"{act_string}",370,440)
- }
+ case 3: Canvas.draw_image_full(ctx,get("actions.png"),x,y,115,120,480,220,115,120);
+ case 2: Canvas.draw_image_full(ctx,get("actions.png"),x,y,115,120,335, 75,115,120);
+ case 1: Canvas.draw_image_full(ctx,get("actions.png"),x,y,115,120,160,220,115,120);
+ case _: Canvas.draw_image_full(ctx,get("actions.png"),x,y,115,120,315,390,115,120);
}
Canvas.restore(ctx);
}
@@ -923,7 +969,7 @@ client module Render {
Canvas.set_font(ctx,"normal bold 24px serif");
Canvas.set_text_align(ctx,{align_center});
Canvas.set_text_baseline(ctx,{middle});
- Canvas.fill_text(ctx,"{i}",370,277);
+ Canvas.fill_text(ctx,"{i}",400,277);
Canvas.restore(ctx);
}
Please sign in to comment.
Something went wrong with that request. Please try again.