Black Jack game: ignoring buttons events on pauses
parent
4a01fa1c6c
commit
c882c52b27
|
|
@ -1746,7 +1746,7 @@
|
||||||
"name": "Black Jack game",
|
"name": "Black Jack game",
|
||||||
"shortName":"Black Jack game",
|
"shortName":"Black Jack game",
|
||||||
"icon": "blackjack.png",
|
"icon": "blackjack.png",
|
||||||
"version":"0.01",
|
"version":"0.02",
|
||||||
"description": "Simple implementation of card game Black Jack",
|
"description": "Simple implementation of card game Black Jack",
|
||||||
"tags": "game",
|
"tags": "game",
|
||||||
"allow_emulator":true,
|
"allow_emulator":true,
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
0.01: New game! BTN4- Hit card, BTN5- Stand
|
0.01: New game! BTN4- Hit card, BTN5- Stand
|
||||||
|
0.02: ignore buttons on pauses
|
||||||
|
|
@ -18,6 +18,7 @@ const Diamonds = { width : 48, height : 48, bpp : 4,
|
||||||
var deck = [];
|
var deck = [];
|
||||||
var player = {Hand:[]};
|
var player = {Hand:[]};
|
||||||
var computer = {Hand:[]};
|
var computer = {Hand:[]};
|
||||||
|
var ctx = {ready:true};
|
||||||
|
|
||||||
function createDeck() {
|
function createDeck() {
|
||||||
var suits = ["Spades", "Hearts", "Diamonds", "Clubs"];
|
var suits = ["Spades", "Hearts", "Diamonds", "Clubs"];
|
||||||
|
|
@ -44,6 +45,7 @@ function shuffle(a) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function EndGameMessdage(msg){
|
function EndGameMessdage(msg){
|
||||||
|
ctx.ready = false;
|
||||||
g.drawString(msg, 155, 200);
|
g.drawString(msg, 155, 200);
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
startGame();
|
startGame();
|
||||||
|
|
@ -52,6 +54,7 @@ function EndGameMessdage(msg){
|
||||||
}
|
}
|
||||||
|
|
||||||
function hitMe() {
|
function hitMe() {
|
||||||
|
if (!ctx.ready) return;
|
||||||
player.Hand.push(deck.pop());
|
player.Hand.push(deck.pop());
|
||||||
renderOnScreen(1);
|
renderOnScreen(1);
|
||||||
var playerWeight = calcWeight(player.Hand, 0);
|
var playerWeight = calcWeight(player.Hand, 0);
|
||||||
|
|
@ -97,6 +100,8 @@ function calcWeight(hand, hideCard) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function stand(){
|
function stand(){
|
||||||
|
if (!ctx.ready) return;
|
||||||
|
ctx.ready = false;
|
||||||
function sleepFor( sleepDuration ){
|
function sleepFor( sleepDuration ){
|
||||||
console.log("Sleeping...");
|
console.log("Sleeping...");
|
||||||
var now = new Date().getTime();
|
var now = new Date().getTime();
|
||||||
|
|
@ -156,6 +161,7 @@ function renderOnScreen(HideCard) {
|
||||||
function dealHands() {
|
function dealHands() {
|
||||||
player.Hand= [];
|
player.Hand= [];
|
||||||
computer.Hand= [];
|
computer.Hand= [];
|
||||||
|
ctx.ready = false;
|
||||||
|
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
player.Hand.push(deck.pop());
|
player.Hand.push(deck.pop());
|
||||||
|
|
@ -175,6 +181,7 @@ function dealHands() {
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
computer.Hand.push(deck.pop());
|
computer.Hand.push(deck.pop());
|
||||||
renderOnScreen(1);
|
renderOnScreen(1);
|
||||||
|
ctx.ready = true;
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue