Code edit (2 edits merged)
Please save this source code
User prompt
Ana menü ekranındaki butonu biraz daha büyült ve yazıyı da biraz daha büyült.
User prompt
Yükleme ekranından sonra aynı anda arka arkaya bir sürü müzik çalmaya başlıyor. Bunu önlemen lazım. Sadece 1 kere çalmaya başlasın ve döngü olarak devam etsin istiyorum. Müzik, yükleme ekranı gittikten sonra çalmaya başlamalı anında.
User prompt
Böyle yapmamız bir işe yaramadı çünkü galiba yükleme ekranı ana menü ekranından ayrı bir ekran olduğu için ana menü ekranına gelmeden ses dosyası yüklenmiyor. Ana menü ekranının üstünde göstermemiz gerekiyor galiba yükleme ekranını, bu esnada müzik kaynakları yükleniyor olacak.
Code edit (1 edits merged)
Please save this source code
User prompt
Ana menü ekranından önce bir ekran daha koyarsak (yükleme ekranı olacak) ve bu ekranda arkaplan kırmızı olsa ve ekranın ortasında üstte "novatekLogosu" asseti olsa. Bu logonun altında "Loading..." yazsa ve bu yazının da altında "For the best gaming experience, please wait until the game's graphic and audio resources are fully loaded." yazsa ve bu yazının da altında ortada dönen bir "yuklemeCubugu" olsa, bu ekran 10 saniye boyunca dursa (oyunu başlattıktan sonra) ve sonrasında kaybolsa ve ana menü ekranına gelsem sonrasında bir anda müzik çalmaya başlar çünkü yüklenmiş olarak diye düşünmekteyim. Yükleme ekranında bu müzik çalmaya başlamayacak. Bunu uygula koduma. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
anaMenuEkraniMuzigi ve oyunSonuEkraniMuzigi müziklerine gerek kalmadı. Benim oyunum açıldığından itibaren yani ana menü ekranından itibaren sürekli olarak döngü şeklinde oyunEkraniMuzigi çalsın.
User prompt
Ana menü ekranındaki arkaplan "anaMenuEkraniArkaplani" olsun. Oyun ekranındaki arkaplan "oyunEkraniArkaplani" olsun. Oyun sonu ekranındaki arkaplan "oyunSonuEkraniArkaplani" olsun. Ana menü ekranında "anaMenuEkraniMuzigi" çalsın döngü şeklinde. Oyun ekranında "oyunEkraniMuzigi" çalsın döngü şeklinde. Oyun sonu ekranında "oyunSonuEkraniMuzigi" çalsın döngü şeklinde.
User prompt
Zar seçtiğim zaman 1 kere "zarSecmeSesi" çalmalı. Zar seçmeyi bıraktığım zaman 1 kere "zarBirakmaSesi" çalmalı. TUT ve DEVAM ET butonuna bastığım zaman 1 kere "tutVeDevamEtSesi" sesi çalmalı. TUT ve TURU SONLANDIR butonuna bastığım zaman 1 kere "tutVeTuruSonlandirSesi" çalmalı.
User prompt
Ama şu anda seçtiğim zar sanki elimde kalıyormuş da sonraki zarları TUT ve DEVAM ET ile attıktan sonra onlardan gelen zarları da seçip önceki seçtiğim zarlarla birlikte total bir kombinasyon yapıyormuşum gibi oluyor ve bunu istemiyorum. Ben bir zarı ya da zarları seçip TUT ve DEVAM ET dediğim zaman o zarlardan gelen puanı geçici olarak kazanmalıyım yani bir yere not edilmeli fakat o puanı henüz kazanmamış olacağım, kendi turumda elde ettiğim tüm puanları TUT ve TURU SONLANDIR dersem kalıcı olarak kazanmış olurum ancak ve sıra rakibe geçer.
User prompt
Ama şu anda TUT ve DEVAM ET dediğim zaman seçmiş olduğum zar da sanki tekrar fırlatılmış gibi dönüp hızlıca değişiyor. Seçtiğim zarın sabit kalması gerekiyor.
User prompt
TUT ve DEVAM ET tuşuna bastığım zaman zarlar 3 saniye boyunca dönüyormuş gibi hızlıca değişsin sürekli ve 3 saniyenin sonunda dursun. Zarlar dönüyorken (hızlıca değişiyorken) onları seçemiyor olmalıyım, durmaları gerekiyor.
User prompt
Ama şu anda kazandığımda ya da kaybettiğimde karşıma direkt "You Win! Play again" şeklinde bir yazı geliyor. Oyun sonu ekranım gelmiyor. Oyun sonu ekranımın gelmesini istiyorum.
User prompt
Oyuna başladığım zaman karşıma ilk olarak arkaplanı yeşil olan bir ana menü ekranı gelsin. Bu ekranın ortasında "Oyunu Başlat" butonu olsun ve bu butona basınca oyun başlasın. Bu butona basmazsam oyun başlamasın. Kazandığım ya da kaybettiğim zamanda da karşıma arkaplanı turuncu olan bir oyun sonu ekranı gelsin. Bu ekranın ortasında "Ana Menüye Dön" butonu olsun ve bu butona basınca ana menüye dönülsün ve oyun baştan başlatılmış gibi her şey sıfırlansın ve temizlensin.
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'forEach')' in or related to this line: 'map[this.value].forEach(function (idx, i) {' Line Number: 289
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'selected')' in or related to this line: 'if (d.selected) {' Line Number: 507
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'selected')' in or related to this line: 'if (d.selected) {' Line Number: 507
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'selected')' in or related to this line: 'if (d.selected) {' Line Number: 507
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'selected')' in or related to this line: 'if (d.selected) {' Line Number: 507
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'selected')' in or related to this line: 'if (d.selected) {' Line Number: 507
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'selected')' in or related to this line: 'if (d.selected) {' Line Number: 507
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'selected')' in or related to this line: 'if (d.selected) {' Line Number: 507
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'selected')' in or related to this line: 'if (d.selected) {' Line Number: 507
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Initialize Game ****/ // Kanvas boyutları /* --- Oyun nesnesi --- */ var game = new LK.Game({ backgroundColor: 0x1a1a1a }); /**** * Game Code ****/ /* --- Zar sınıfı --- */ /*********************************************************** * 1. KISIM — VARLIKLAR, GENEL TANIMLAR, Dice SINIFI ************************************************************/ // Custom background images for each screen // Music for each screen function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) { throw o; } } } }; } function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) { return _arrayLikeToArray(r, a); } var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) { n[e] = r[e]; } return n; } function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) { return; } f = !1; } else { for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) { ; } } } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) { return; } } finally { if (o) { throw n; } } } return a; } } function _arrayWithHoles(r) { if (Array.isArray(r)) { return r; } } function _classCallCheck(a, n) { if (!(a instanceof n)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } } function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) { return t; } var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) { return i; } throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) { return e; } if (void 0 !== e) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(t); } function _assertThisInitialized(e) { if (void 0 === e) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return e; } function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); } function _inherits(t, e) { if ("function" != typeof e && null !== e) { throw new TypeError("Super expression must either be null or a function"); } t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); } function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } var W = 2048, H = 2732; var Dice = /*#__PURE__*/function (_Container) { function Dice() { var _this; _classCallCheck(this, Dice); _this = _callSuper(this, Dice); /** Zar yüzü (1-6) */ _this.value = 1; /** Seçili mi? */ _this.selected = false; // Kasa _this.face = _this.attachAsset('diceFace', { anchorX: .5, anchorY: .5 }); // 6 pip _this.pip = []; for (var i = 0; i < 6; i++) { var dot = _this.attachAsset("pip".concat(i), { anchorX: .5, anchorY: .5, width: 32, height: 32, color: 0x222222, shape: 'ellipse' }); dot.visible = false; _this.pip.push(dot); } _this.updateFace(); return _this; } /** Değeri ayarla + yüzü güncelle */ _inherits(Dice, _Container); return _createClass(Dice, [{ key: "setValue", value: function setValue(v) { this.value = v; this.updateFace(); } /** Pip’leri göster/gizle */ }, { key: "updateFace", value: function updateFace() { var _this2 = this; this.pip.forEach(function (p) { return p.visible = false; }); var map = { 1: [2], 2: [0, 5], 3: [0, 2, 5], 4: [0, 1, 4, 5], 5: [0, 1, 2, 4, 5], 6: [0, 1, 3, 4, 5, 6] }; var pos = [[-40, -40], [40, -40], [0, 0], [-40, 40], [40, 40], [-40, 0], [40, 0]]; map[this.value].forEach(function (idx, i) { var _pos$idx = _slicedToArray(pos[idx], 2), x = _pos$idx[0], y = _pos$idx[1]; var d = _this2.pip[i]; d.x = x; d.y = y; d.visible = true; }); } }]); }(Container); /* --- Global durum --- */ var PLAYER = 0, NPC = 1; var scores = [0, 0], turnScore = 0, current = PLAYER, gameOver = false; var dice = []; // Aktif zarlar var selectedDiceIdx = []; // Seçili zar indeksleri var diceGroup = null, selectedDiceGroup = null; /* --- Diziyi yeniden numaralandır + doğru tıklama --- */ function renumberDice() { for (var i = 0; i < dice.length; i++) { var d = dice[i]; d.idx = i; // güncel indis d.down = function () { toggleSelect(this.idx); }; // <— closure sorunu yok } } /*********************************************************** * 2. KISIM — SKOR HESABI ve KOMBİNASYON YARDIMCILARI ************************************************************/ /* Farkle puan tablosu */ function calcScoreFarkle(vals) { var cnt = Array(7).fill(0); vals.forEach(function (v) { return cnt[v]++; }); var score = 0, used = []; /* Full straight 1-6 */ if (vals.length === 6 && [1, 2, 3, 4, 5, 6].every(function (v) { return cnt[v] === 1; })) { return { score: 1500, used: [0, 1, 2, 3, 4, 5] }; } /* Partial straight 1-5 */ if (vals.length === 5 && [1, 2, 3, 4, 5].every(function (v) { return cnt[v]; })) { return { score: 500, used: [0, 1, 2, 3, 4] }; } /* Partial straight 2-6 */ if (vals.length === 5 && [2, 3, 4, 5, 6].every(function (v) { return cnt[v]; })) { return { score: 750, used: [0, 1, 2, 3, 4] }; } /* 3-6 aynı zar kümeleri */ for (var v = 1; v <= 6; v++) { if (cnt[v] >= 3) { var base = v === 1 ? 1000 : v * 100; var factor = [1, 2, 4, 8][cnt[v] - 3]; score += base * factor; var need = cnt[v]; vals.forEach(function (val, i) { if (val === v && need) { used.push(i); need--; } }); cnt[v] = 0; // tekil sayılmasın } } /* Tekil 1 & 5 */ vals.forEach(function (v, i) { if (used.includes(i)) { return; } if (v === 1) { score += 100; used.push(i); } if (v === 5) { score += 50; used.push(i); } }); return { score: score, used: used }; } /* Seçim geçerli mi? */ function isValidSelection(selVals) { var r = calcScoreFarkle(selVals); return r.score > 0 && r.used.length === selVals.length; } /* Belirli uzunlukta kombinasyonları döndür */ function getCombinations(arr, k) { var out = []; (function helper(start, path) { if (path.length === k) { out.push(path.slice()); return; } for (var i = start; i < arr.length; i++) { path.push(arr[i]); helper(i + 1, path); path.pop(); } })(0, []); return out; } /* Kalan zarlarla **hiç** skor yapılabilir mi? */ function canMakeAnyScore(vals) { if (!vals.length) { return false; } for (var i = 1; i <= vals.length; i++) { var combs = getCombinations(vals, i); var _iterator = _createForOfIteratorHelper(combs), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var c = _step.value; if (isValidSelection(c)) { return true; } } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } } return false; } /*********************************************************** * 3. KISIM — GUI, HUD ve ZAR YÖNETİMİ ************************************************************/ /* --- Butonlar --- */ var rollBtn = new Container(); rollBtn.attachAsset('btnBlue', { anchorX: .5, anchorY: .5 }); var rollTxt = new Text2('TUT ve DEVAM ET', { size: 40, fill: '#fff' }); rollTxt.anchor.set(.5, .5); rollBtn.addChild(rollTxt); LK.gui.bottom.addChild(rollBtn); rollBtn.x = -460; rollBtn.y = -140; var bankBtn = new Container(); bankBtn.attachAsset('btnRed', { anchorX: .5, anchorY: .5 }); var bankTxt = new Text2('TUT ve TURU SONLANDIR', { size: 40, fill: '#fff' }); bankTxt.anchor.set(.5, .5); bankBtn.addChild(bankTxt); LK.gui.bottom.addChild(bankBtn); bankBtn.x = 50; bankBtn.y = -140; /* --- Reset & Pozisyon --- */ function resetDice() { var n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 6; if (diceGroup) { diceGroup.destroy(); } if (selectedDiceGroup) { selectedDiceGroup.destroy(); } dice = []; selectedDiceIdx = []; diceGroup = new Container(); selectedDiceGroup = new Container(); game.addChild(diceGroup); game.addChild(selectedDiceGroup); var startX = W / 2 - (n - 1) * 220 / 2, y = H / 2; for (var i = 0; i < n; i++) { var d = new Dice(); d.x = startX + i * 220; d.y = y; d.setValue(1 + Math.floor(Math.random() * 6)); diceGroup.addChild(d); dice.push(d); } renumberDice(); updateDicePositions(); updateHUD(); } /* Seç/Aç seçimi */ function toggleSelect(idx) { if (gameOver || current !== PLAYER) { return; } var d = dice[idx]; if (d.selected) { d.selected = false; selectedDiceIdx = selectedDiceIdx.filter(function (i) { return i !== idx; }); // Play zarBirakmaSesi when deselecting var birakmaSesi = LK.getSound && LK.getSound('zarBirakmaSesi'); if (birakmaSesi && birakmaSesi.play) birakmaSesi.play(); } else { d.selected = true; if (!selectedDiceIdx.includes(idx)) { selectedDiceIdx.push(idx); } // Play zarSecmeSesi when selecting var secmeSesi = LK.getSound && LK.getSound('zarSecmeSesi'); if (secmeSesi && secmeSesi.play) secmeSesi.play(); } updateDicePositions(); updateHUD(); } /* Konumları güncelle */ function updateDicePositions() { if (!diceGroup || !selectedDiceGroup) { return; } diceGroup.removeChildren(); selectedDiceGroup.removeChildren(); var sel = selectedDiceIdx.slice(); // kopya var unsel = []; for (var i = 0; i < dice.length; i++) { var d = dice[i]; if (d && d.selected) { selectedDiceGroup.addChild(d); } else if (d) { unsel.push(i); diceGroup.addChild(d); } // Defensive: skip if d is undefined } /* Seçili zarlar aşağıda */ var selStart = W / 2 - (sel.length - 1) * 220 / 2, selY = H / 2 + 250; sel.forEach(function (idx, i) { var d = dice[idx]; d.x = selStart + i * 220; d.y = selY; d.face.alpha = .6; }); /* Diğer zarlar ortada */ var unStart = W / 2 - (unsel.length - 1) * 220 / 2, y = H / 2; unsel.forEach(function (idx, i) { var d = dice[idx]; d.x = unStart + i * 220; d.y = y; d.face.alpha = 1; }); } /*********************************************************** * 4. KISIM — OYUN DÖNGÜSÜ, NPC, HUD, BAŞLAT ************************************************************/ /* --- HUD --- */ var playerScoreTxt, npcScoreTxt, turnTxt; function updateHUD() { /* Buton aktifliği */ var selVals = selectedDiceIdx.map(function (i) { return dice[i].value; }); var valid = isValidSelection(selVals); rollBtn.alpha = bankBtn.alpha = valid ? 1 : 0.4; rollBtn.interactive = bankBtn.interactive = valid && current === PLAYER && !gameOver; /* Metinler */ if (!playerScoreTxt) { playerScoreTxt = new Text2('', { size: 70, fill: '#fff' }); playerScoreTxt.anchor.set(0, 0); LK.gui.top.addChild(playerScoreTxt); playerScoreTxt.x = -690; playerScoreTxt.y = 150; npcScoreTxt = new Text2('', { size: 70, fill: '#fff' }); npcScoreTxt.anchor.set(0, 0); LK.gui.top.addChild(npcScoreTxt); npcScoreTxt.x = -690; npcScoreTxt.y = 220; turnTxt = new Text2('', { size: 90, fill: '#ffe066', fontWeight: 'bold' }); turnTxt.anchor.set(0, 0); LK.gui.top.addChild(turnTxt); turnTxt.x = -340; turnTxt.y = 30; } playerScoreTxt.setText("1. Oyuncu: ".concat(scores[PLAYER])); npcScoreTxt.setText("2. Oyuncu: ".concat(scores[NPC])); turnTxt.setText(current === PLAYER ? 'Sıra: 1. Oyuncuda' : 'Sıra: 2. Oyuncuda'); } /* --- Tur Aksiyonları --- */ function rollAll() { if (gameOver || current !== PLAYER) { return; } dice.forEach(function (d) { if (!d.selected) { d.setValue(1 + Math.floor(Math.random() * 6)); } }); updateDicePositions(); updateHUD(); var unselVals = dice.filter(function (d) { return !d.selected; }).map(function (d) { return d.value; }); if (!canMakeAnyScore(unselVals)) { LK.effects.flashScreen(0xff0000, 600); LK.setTimeout(function () { turnScore = 0; endTurn(); }, 700); } } function keepAndContinue() { if (gameOver || current !== PLAYER) { return; } var selVals = selectedDiceIdx.map(function (i) { return dice[i].value; }); if (!isValidSelection(selVals)) { return; } turnScore += calcScoreFarkle(selVals).score; /* Seçili zarları kaldır */ dice = dice.filter(function (d, i) { return !selectedDiceIdx.includes(i); }).map(function (d) { return d; }); selectedDiceIdx = []; if (dice.length === 0) { resetDice(6); } // Hot dice else { dice.forEach(function (d) { d.selected = false; d.setValue(1 + Math.floor(Math.random() * 6)); }); renumberDice(); updateDicePositions(); } updateHUD(); var unselVals = dice.map(function (d) { return d.value; }); if (!canMakeAnyScore(unselVals)) { LK.effects.flashScreen(0xff0000, 600); LK.setTimeout(function () { turnScore = 0; endTurn(); }, 700); } } function keepAndEndTurn() { if (gameOver || current !== PLAYER) { return; } var selVals = selectedDiceIdx.map(function (i) { return dice[i].value; }); if (!isValidSelection(selVals)) { return; } turnScore += calcScoreFarkle(selVals).score; endTurn(); } function endTurn() { scores[current] += turnScore; if (scores[current] >= 2000) { showWinner(); return; } current = current === PLAYER ? NPC : PLAYER; turnScore = 0; resetDice(6); updateHUD(); if (current === NPC) { LK.setTimeout(npcTurn, 800); } } /* --- NPC Basit AI --- */ function npcTurn() { if (gameOver || current !== NPC) { return; } dice.forEach(function (d) { d.selected = false; d.setValue(1 + Math.floor(Math.random() * 6)); }); updateDicePositions(); /* En yüksek puanlı kombinasyonu bul */ var vals = dice.map(function (d) { return d.value; }); var bestScore = 0, bestSel = []; for (var i = 1; i <= vals.length; i++) { var _iterator2 = _createForOfIteratorHelper(getCombinations(vals, i)), _step2; try { for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { var comb = _step2.value; if (isValidSelection(comb)) { var s = calcScoreFarkle(comb).score; if (s > bestScore) { bestScore = s; bestSel = comb; } } } } catch (err) { _iterator2.e(err); } finally { _iterator2.f(); } } if (bestScore === 0) { LK.effects.flashScreen(0xff0000, 600); LK.setTimeout(function () { turnScore = 0; endTurn(); }, 700); return; } /* Zarları seç */ var _iterator3 = _createForOfIteratorHelper(dice), _step3; try { for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { var d = _step3.value; d.selected = bestSel.includes(d.value); } } catch (err) { _iterator3.e(err); } finally { _iterator3.f(); } updateDicePositions(); /* Strateji: ≥400 puan veya 1 zar kalınca bank */ if (bestScore >= 400 || dice.length - bestSel.length <= 1) { turnScore += bestScore; endTurn(); } else { turnScore += bestScore; dice = dice.filter(function (d) { return !d.selected; }); selectedDiceIdx = []; renumberDice(); if (dice.length === 0) { resetDice(6); } else { dice.forEach(function (d) { d.selected = false; d.setValue(1 + Math.floor(Math.random() * 6)); }); } updateDicePositions(); updateHUD(); var unselVals = dice.map(function (d) { return d.value; }); if (!canMakeAnyScore(unselVals)) { LK.effects.flashScreen(0xff0000, 600); LK.setTimeout(function () { turnScore = 0; endTurn(); }, 700); return; } LK.setTimeout(npcTurn, 800); } } /* --- Kazanan ekranı --- */ function showWinner() { gameOver = true; var winnerText = current === PLAYER ? 'Kazandın!' : 'NPC Kazandı!'; showGameOverScreen(winnerText); } /* --- Buton Olayları --- */ rollBtn.down = function () { if (current === PLAYER) { var tutDevamSesi = LK.getSound && LK.getSound('tutVeDevamEtSesi'); if (tutDevamSesi && tutDevamSesi.play) tutDevamSesi.play(); keepAndContinue(); } }; bankBtn.down = function () { if (current === PLAYER) { var tutTuruSonlandirSesi = LK.getSound && LK.getSound('tutVeTuruSonlandirSesi'); if (tutTuruSonlandirSesi && tutTuruSonlandirSesi.play) tutTuruSonlandirSesi.play(); keepAndEndTurn(); } }; /* --- Başlat --- */ function startGame() { scores = [0, 0]; turnScore = 0; current = PLAYER; gameOver = false; // Set oyunEkraniArkaplani as background if (game._oyunBg) { game._oyunBg.destroy(); game._oyunBg = null; } var oyunBg = LK.getAsset('oyunEkraniArkaplani', { anchorX: 0, anchorY: 0, x: 0, y: 0, width: W, height: H }); game.addChildAt(oyunBg, 0); game._oyunBg = oyunBg; // Play oyunEkraniMuzigi (looping) LK.playMusic('oyunEkraniMuzigi'); resetDice(6); updateHUD(); } // --- Ana Menü ve Oyun Sonu Ekranları --- var mainMenuContainer = null; var gameOverContainer = null; // Ana Menü Ekranını Göster function showMainMenu() { // Temizle if (mainMenuContainer) { mainMenuContainer.destroy(); mainMenuContainer = null; } if (gameOverContainer) { gameOverContainer.destroy(); gameOverContainer = null; } // Oyun alanını temizle if (diceGroup) { diceGroup.destroy(); diceGroup = null; } if (selectedDiceGroup) { selectedDiceGroup.destroy(); selectedDiceGroup = null; } dice = []; selectedDiceIdx = []; // Skor metinlerini gizle if (playerScoreTxt) playerScoreTxt.visible = false; if (npcScoreTxt) npcScoreTxt.visible = false; if (turnTxt) turnTxt.visible = false; // Butonları pasifleştir rollBtn.visible = false; bankBtn.visible = false; // Remove oyun ekranı arkaplanı if exists if (game._oyunBg) { game._oyunBg.destroy(); game._oyunBg = null; } // Ana Menü Container mainMenuContainer = new Container(); mainMenuContainer.width = W; mainMenuContainer.height = H; // Arkaplan (anaMenuEkraniArkaplani) var bg = LK.getAsset('anaMenuEkraniArkaplani', { anchorX: 0, anchorY: 0, x: 0, y: 0, width: W, height: H }); mainMenuContainer.addChild(bg); // Play oyunEkraniMuzigi (looping) LK.playMusic('oyunEkraniMuzigi'); // "Oyunu Başlat" Butonu var startBtn = new Container(); startBtn.attachAsset('btnBlue', { anchorX: 0.5, anchorY: 0.5 }); var startTxt = new Text2('Oyunu Başlat', { size: 60, fill: '#fff' }); startTxt.anchor.set(0.5, 0.5); startBtn.addChild(startTxt); startBtn.x = W / 2; startBtn.y = H / 2; startBtn.interactive = true; startBtn.down = function () { hideMainMenu(); startGame(); }; mainMenuContainer.addChild(startBtn); game.addChild(mainMenuContainer); } // Ana Menü Ekranını Gizle function hideMainMenu() { if (mainMenuContainer) { mainMenuContainer.destroy(); mainMenuContainer = null; } // Skor metinlerini göster if (playerScoreTxt) playerScoreTxt.visible = true; if (npcScoreTxt) npcScoreTxt.visible = true; if (turnTxt) turnTxt.visible = true; // Butonları göster rollBtn.visible = true; bankBtn.visible = true; } // Oyun Sonu Ekranını Göster function showGameOverScreen(winnerText) { // Temizle if (gameOverContainer) { gameOverContainer.destroy(); gameOverContainer = null; } if (mainMenuContainer) { mainMenuContainer.destroy(); mainMenuContainer = null; } // Oyun alanını temizle if (diceGroup) { diceGroup.destroy(); diceGroup = null; } if (selectedDiceGroup) { selectedDiceGroup.destroy(); selectedDiceGroup = null; } dice = []; selectedDiceIdx = []; // Skor metinlerini gizle if (playerScoreTxt) playerScoreTxt.visible = false; if (npcScoreTxt) npcScoreTxt.visible = false; if (turnTxt) turnTxt.visible = false; // Butonları pasifleştir rollBtn.visible = false; bankBtn.visible = false; // Remove oyun ekranı arkaplanı if exists if (game._oyunBg) { game._oyunBg.destroy(); game._oyunBg = null; } // Oyun Sonu Container gameOverContainer = new Container(); gameOverContainer.width = W; gameOverContainer.height = H; // Arkaplan (oyunSonuEkraniArkaplani) var bg = LK.getAsset('oyunSonuEkraniArkaplani', { anchorX: 0, anchorY: 0, x: 0, y: 0, width: W, height: H }); gameOverContainer.addChild(bg); // Play oyunEkraniMuzigi (looping) LK.playMusic('oyunEkraniMuzigi'); // Kazanan/Kaybeden Metni var resultTxt = new Text2(winnerText || 'Oyun Bitti', { size: 80, fill: '#fff' }); resultTxt.anchor.set(0.5, 0.5); resultTxt.x = W / 2; resultTxt.y = H / 2 - 120; gameOverContainer.addChild(resultTxt); // "Ana Menüye Dön" Butonu var menuBtn = new Container(); menuBtn.attachAsset('btnRed', { anchorX: 0.5, anchorY: 0.5 }); var menuTxt = new Text2('Ana Menüye Dön', { size: 60, fill: '#fff' }); menuTxt.anchor.set(0.5, 0.5); menuBtn.addChild(menuTxt); menuBtn.x = W / 2; menuBtn.y = H / 2 + 60; menuBtn.interactive = true; menuBtn.down = function () { hideGameOverScreen(); showMainMenu(); }; gameOverContainer.addChild(menuBtn); game.addChild(gameOverContainer); } // Oyun Sonu Ekranını Gizle function hideGameOverScreen() { if (gameOverContainer) { gameOverContainer.destroy(); gameOverContainer = null; } // Skor metinlerini göster if (playerScoreTxt) playerScoreTxt.visible = true; if (npcScoreTxt) npcScoreTxt.visible = true; if (turnTxt) turnTxt.visible = true; // Butonları göster rollBtn.visible = true; bankBtn.visible = true; } // --- Kazanan ekranı override --- // Yükleme ekranı için sınıf ve gösterme fonksiyonu var loadingContainer = null; var loadingTimeout = null; // Tween plugin import // Yükleme ekranını göster function showLoadingScreen() { // Temizle if (loadingContainer) { loadingContainer.destroy(); loadingContainer = null; } if (mainMenuContainer) { mainMenuContainer.destroy(); mainMenuContainer = null; } if (gameOverContainer) { gameOverContainer.destroy(); gameOverContainer = null; } // Oyun alanını temizle if (diceGroup) { diceGroup.destroy(); diceGroup = null; } if (selectedDiceGroup) { selectedDiceGroup.destroy(); selectedDiceGroup = null; } dice = []; selectedDiceIdx = []; // Skor metinlerini gizle if (playerScoreTxt) playerScoreTxt.visible = false; if (npcScoreTxt) playerScoreTxt.visible = false; if (turnTxt) turnTxt.visible = false; // Butonları pasifleştir rollBtn.visible = false; bankBtn.visible = false; // Remove oyun ekranı arkaplanı if exists if (game._oyunBg) { game._oyunBg.destroy(); game._oyunBg = null; } loadingContainer = new Container(); loadingContainer.width = W; loadingContainer.height = H; // Kırmızı arkaplan var bg = LK.getAsset('loadingBgRed', { anchorX: 0, anchorY: 0, x: 0, y: 0, width: W, height: H, color: 0xff0000, shape: 'box' }); loadingContainer.addChild(bg); // Novatek logosu (ortada üstte) var logo = LK.getAsset('novatekLogosu', { anchorX: 0.5, anchorY: 0, x: W / 2, y: 320 }); loadingContainer.addChild(logo); // "Loading..." yazısı var loadingTxt = new Text2('Loading...', { size: 90, fill: '#fff' }); loadingTxt.anchor.set(0.5, 0); loadingTxt.x = W / 2; loadingTxt.y = 320 + (logo.height || 220) + 60; loadingContainer.addChild(loadingTxt); // Alt açıklama yazısı var infoTxt = new Text2("For the best gaming experience, please wait until the game's graphic and audio resources are fully loaded.", { size: 48, fill: '#fff', wordWrap: true, wordWrapWidth: 1400, align: 'center' }); infoTxt.anchor.set(0.5, 0); infoTxt.x = W / 2; infoTxt.y = loadingTxt.y + loadingTxt.height + 40; loadingContainer.addChild(infoTxt); // Dönen yükleme çubuğu var spinner = LK.getAsset('yuklemeCubugu', { anchorX: 0.5, anchorY: 0.5, x: W / 2, y: infoTxt.y + infoTxt.height + 120 }); loadingContainer.addChild(spinner); // Spinner animasyonu (dönme) spinner.rotation = 0; var _spinTween = function spinTween() { tween(spinner, { rotation: spinner.rotation + Math.PI * 2 }, { duration: 1200, easing: tween.linear, onFinish: _spinTween }); }; _spinTween(); game.addChild(loadingContainer); // 10 saniye sonra ana menüye geç loadingTimeout = LK.setTimeout(function () { if (loadingContainer) { loadingContainer.destroy(); loadingContainer = null; } showMainMenu(); }, 10000); } // Oyun başında yükleme ekranını göster showLoadingScreen(); /* --- Responsive HUD --- */ if (!window._frvr_gui_resize_hooked) { window._frvr_gui_resize_hooked = true; LK.on('resize', function () { if (npcScoreTxt) { npcScoreTxt.x = LK.gui.top.width - 120; } if (turnTxt) { turnTxt.x = LK.gui.top.width / 2; } }); }
===================================================================
--- original.js
+++ change.js
@@ -1,5 +1,10 @@
/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
* Initialize Game
****/
// Kanvas boyutları
/* --- Oyun nesnesi --- */
@@ -1018,10 +1023,126 @@
rollBtn.visible = true;
bankBtn.visible = true;
}
// --- Kazanan ekranı override ---
-// Oyun başında ana menüyü göster
-showMainMenu();
+// Yükleme ekranı için sınıf ve gösterme fonksiyonu
+var loadingContainer = null;
+var loadingTimeout = null;
+// Tween plugin import
+// Yükleme ekranını göster
+function showLoadingScreen() {
+ // Temizle
+ if (loadingContainer) {
+ loadingContainer.destroy();
+ loadingContainer = null;
+ }
+ if (mainMenuContainer) {
+ mainMenuContainer.destroy();
+ mainMenuContainer = null;
+ }
+ if (gameOverContainer) {
+ gameOverContainer.destroy();
+ gameOverContainer = null;
+ }
+ // Oyun alanını temizle
+ if (diceGroup) {
+ diceGroup.destroy();
+ diceGroup = null;
+ }
+ if (selectedDiceGroup) {
+ selectedDiceGroup.destroy();
+ selectedDiceGroup = null;
+ }
+ dice = [];
+ selectedDiceIdx = [];
+ // Skor metinlerini gizle
+ if (playerScoreTxt) playerScoreTxt.visible = false;
+ if (npcScoreTxt) playerScoreTxt.visible = false;
+ if (turnTxt) turnTxt.visible = false;
+ // Butonları pasifleştir
+ rollBtn.visible = false;
+ bankBtn.visible = false;
+ // Remove oyun ekranı arkaplanı if exists
+ if (game._oyunBg) {
+ game._oyunBg.destroy();
+ game._oyunBg = null;
+ }
+ loadingContainer = new Container();
+ loadingContainer.width = W;
+ loadingContainer.height = H;
+ // Kırmızı arkaplan
+ var bg = LK.getAsset('loadingBgRed', {
+ anchorX: 0,
+ anchorY: 0,
+ x: 0,
+ y: 0,
+ width: W,
+ height: H,
+ color: 0xff0000,
+ shape: 'box'
+ });
+ loadingContainer.addChild(bg);
+ // Novatek logosu (ortada üstte)
+ var logo = LK.getAsset('novatekLogosu', {
+ anchorX: 0.5,
+ anchorY: 0,
+ x: W / 2,
+ y: 320
+ });
+ loadingContainer.addChild(logo);
+ // "Loading..." yazısı
+ var loadingTxt = new Text2('Loading...', {
+ size: 90,
+ fill: '#fff'
+ });
+ loadingTxt.anchor.set(0.5, 0);
+ loadingTxt.x = W / 2;
+ loadingTxt.y = 320 + (logo.height || 220) + 60;
+ loadingContainer.addChild(loadingTxt);
+ // Alt açıklama yazısı
+ var infoTxt = new Text2("For the best gaming experience, please wait until the game's graphic and audio resources are fully loaded.", {
+ size: 48,
+ fill: '#fff',
+ wordWrap: true,
+ wordWrapWidth: 1400,
+ align: 'center'
+ });
+ infoTxt.anchor.set(0.5, 0);
+ infoTxt.x = W / 2;
+ infoTxt.y = loadingTxt.y + loadingTxt.height + 40;
+ loadingContainer.addChild(infoTxt);
+ // Dönen yükleme çubuğu
+ var spinner = LK.getAsset('yuklemeCubugu', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: W / 2,
+ y: infoTxt.y + infoTxt.height + 120
+ });
+ loadingContainer.addChild(spinner);
+ // Spinner animasyonu (dönme)
+ spinner.rotation = 0;
+ var _spinTween = function spinTween() {
+ tween(spinner, {
+ rotation: spinner.rotation + Math.PI * 2
+ }, {
+ duration: 1200,
+ easing: tween.linear,
+ onFinish: _spinTween
+ });
+ };
+ _spinTween();
+ game.addChild(loadingContainer);
+ // 10 saniye sonra ana menüye geç
+ loadingTimeout = LK.setTimeout(function () {
+ if (loadingContainer) {
+ loadingContainer.destroy();
+ loadingContainer = null;
+ }
+ showMainMenu();
+ }, 10000);
+}
+// Oyun başında yükleme ekranını göster
+showLoadingScreen();
/* --- Responsive HUD --- */
if (!window._frvr_gui_resize_hooked) {
window._frvr_gui_resize_hooked = true;
LK.on('resize', function () {
Yeşil casino masa arkaplanı. Dikdörtgen.
Casino oyunum için buton olarak kullanmalık dikdörtgen (köşeleri yumuşatılmış, edge). Yazısız.. In-Game asset. 2d. High contrast. No shadows
Bu sefer zar 1 yerine zar 2 olsun. Delik kırmızı değil siyah olsun.
Zar 2 değil 3 olsun.
Zar 4 olsun. Deliklerinin içi dolu siyah olsun.
Zar 2 değil, zar 5 olsun.
Zar 6 olsun. İçindeki deliklerin içi dolu siyah olsun.
Zar 6 değil, zar joker olsun. Yani zarın üstünde joker sembolü olsun.
Zar 4 değil, zar 1 olsun. İçi siyah değil kırmızı olsun.
Casino tarzında yatay dikdörtgen (köşeleri yumuşatılmış, edge). İçi sarı, dışında kırmızı şerit var. Sol üst köşesinde bir çift zar var. Yazısız.. In-Game asset. 2d. High contrast. No shadows. Casino
oyunEkraniMuzigi
Music
zarBirakmaSesi
Sound effect
zarSecmeSesi
Sound effect
tutVeDevamEtSesi
Sound effect
tutVeTuruSonlandirSesi
Sound effect
ilkSenBasliyorsunSesi
Sound effect
rakibinSirasiSesi
Sound effect
siraSendeSesi
Sound effect
iflasBenSesi
Sound effect
iflasRakipSesi
Sound effect
senKazandinSesi
Sound effect
kaybettinSesi
Sound effect
pasButonuSesi
Sound effect
klavyeTusunaBasmaSesi
Sound effect
oyunuBaslatButonuSesi
Sound effect
anaMenuyeDonButonuSesi
Sound effect
hesabiSifirlaButonuSesi
Sound effect
yuklemeEkraniSesi
Sound effect
ilkRakipBasliyorSesi
Sound effect